NCEPLIBS-bufr 11.7.1
ufbin3.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 2003-11-04
3
4C> THIS SUBROUTINE READS SPECIFIED VALUES FROM THE CURRENT
5C> BUFR DATA SUBSET WITHIN INTERNAL ARRAYS. THE DATA VALUES
6C> CORRESPOND TO MNEMONICS WHICH ARE PART OF A MULTIPLE-REPLICATION
7C> SEQUENCE WITHIN ANOTHER MULTIPLE-REPLICATION SEQUENCE. THE INNER
8C> SEQUENCE IS USUALLY ASSOCIATED WITH DATA "LEVELS" AND THE OUTER
9C> SEQUENCE WITH DATA "EVENTS". THE BUFR FILE IN LOGICAL UNIT LUNIT
10C> MUST HAVE BEEN OPENED FOR INPUT VIA A PREVIOUS CALL TO BUFR ARCHIVE
11C> LIBRARY SUBROUTINE OPENBF. IN ADDITION, THE DATA SUBSET MUST HAVE
12C> SUBSEQUENTLY BEEN READ INTO THE INTERNAL BUFR ARCHIVE LIBRARY
13C> ARRAYS VIA CALLS TO BUFR ARCHIVE LIBRARY SUBROUTINE READMG OR
14C> READERME FOLLOWED BY A CALL TO BUFR ARCHIVE LIBRARY SUBROUTINE
15C> READSB (OR VIA A SINGLE CALL TO BUFR ARCHIVE LIBRARY
16C> SUBROUTINE READNS). THIS SUBROUTINE IS DESIGNED TO READ EVENT
17C> INFORMATION FROM "PREPFITS" TYPE BUFR FILES (BUT NOT FROM
18C> "PREPBUFR" TYPE FILES!!). PREPFITS FILES HAVE THE FOLLOWING BUFR
19C> TABLE EVENT STRUCTURE (NOTE SIXTEEN CHARACTERS HAVE BEEN REMOVED
20C> FROM THE LAST COLUMN TO ALLOW THE TABLE TO FIT IN THIS DOCBLOCK):
21C>
22C> | ADPUPA | HEADR {PLEVL}
23C> |----------|----------------
24C> | HEADR | SID XOB YOB DHR ELV TYP T29 ITP
25C> | PLEVL | CAT PRC PQM QQM TQM ZQM WQM CDTP_QM [OBLVL]
26C> | OBLVL | SRC FHR <PEVN> <QEVN> <TEVN> <ZEVN> <WEVN> <CEVN>
27C> | OBLVL | <CTPEVN>
28C> | PEVN | POB PMO
29C> | QEVN | QOB
30C> | TEVN | TOB
31C> | ZEVN | ZOB
32C> | WEVN | UOB VOB
33C> | CEVN | CAPE CINH LI
34C> | CTPEVN | CDTP GCDTT TOCC
35C>
36C> NOTE THAT THE ONE-BIT DELAYED REPLICATED SEQUENCES "<xxxx>" ARE
37C> NESTED INSIDE THE EIGHT-BIT DELAYED REPLIATION EVENT SEQUENCES
38C> "[yyyy]". THE ANALOGOUS BUFR ARCHIVE LIBRARY SUBROUTINE UFBEVN
39C> DOES NOT WORK PROPERLY ON THIS TYPE OF EVENT STRUCTURE. IT WORKS
40C> ONLY ON THE EVENT STRUCTURE FOUND IN "PREPBUFR" TYPE BUFR FILES
41C> (SEE UFBEVN FOR MORE DETAILS). IN TURN, UFBIN3 DOES NOT WORK
42C> PROPERLY ON THE EVENT STRUCTURE FOUND IN PREPBUFR FILES (ALWAYS USE
43C> UFBEVN IN THIS CASE). ONE OTHER DIFFERENCE BETWEEN UFBIN3 AND
44C> UFBEVN IS THAT UFBIN3 RETURNS THE MAXIMUM NUMBER OF EVENTS FOUND
45C> FOR ALL DATA VALUES SPECIFIED AS AN OUTPUT ARGUMENT (JRET). UFBEVN
46C> DOES NOT DO THIS, BUT RATHER IT STORES THIS VALUE INTERNALLY IN
47C> COMMON BLOCK /UFBN3C/.
48C>
49C> PROGRAM HISTORY LOG:
50C> 2003-11-04 J. WOOLLEN -- ORIGINAL AUTHOR (WAS IN VERIFICATION
51C> VERSION)
52C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
53C> DOCUMENTATION; OUTPUTS MORE COMPLETE
54C> DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
55C> ABNORMALLY OR UNUSUAL THINGS HAPPEN
56C> 2009-04-21 J. ATOR -- USE ERRWRT
57C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
58C>
59C> USAGE: CALL UFBIN3 (LUNIT, USR, I1, I2, I3, IRET, JRET, STR)
60C> INPUT ARGUMENT LIST:
61C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
62C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR (MUST BE AT
63C> LEAST AS LARGE AS THE NUMBER OF BLANK-SEPARATED
64C> MNEMONICS IN STR)
65C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
66C> I3 - INTEGER: LENGTH OF THIRD DIMENSION OF USR (MAXIMUM
67C> VALUE IS 255)
68C> STR - CHARACTER*(*): STRING OF BLANK-SEPARATED TABLE B
69C> MNEMONICS IN ONE-TO-ONE CORRESPONDENCE WITH FIRST
70C> DIMENSION OF USR
71C> - THERE ARE THREE "GENERIC" MNEMONICS NOT RELATED
72C> TO TABLE B, THESE RETURN THE FOLLOWING
73C> INFORMATION IN CORRESPONDING USR LOCATION:
74C> 'NUL' WHICH ALWAYS RETURNS BMISS ("MISSING")
75C> 'IREC' WHICH ALWAYS RETURNS THE CURRENT BUFR
76C> MESSAGE (RECORD) NUMBER IN WHICH THIS
77C> SUBSET RESIDES
78C> 'ISUB' WHICH ALWAYS RETURNS THE CURRENT SUBSET
79C> NUMBER OF THIS SUBSET WITHIN THE BUFR
80C> MESSAGE (RECORD) NUMBER 'IREC'
81C>
82C> OUTPUT ARGUMENT LIST:
83C> USR - REAL*8: (I1,I2,I3) STARTING ADDRESS OF DATA VALUES
84C> READ FROM DATA SUBSET
85C> IRET - INTEGER: NUMBER OF "LEVELS" OF DATA VALUES READ FROM
86C> DATA SUBSET (MUST BE NO LARGER THAN I2)
87C> JRET - INTEGER: MAXIMUM NUMBER OF "EVENTS" FOUND FOR ALL DATA
88C> VALUES SPECIFIED AMONGST ALL LEVELS READ FROM DATA
89C> SUBSET (MUST BE NO LARGER THAN I3)
90C>
91C> REMARKS:
92C> IMPORTANT: THIS ROUTINE SHOULD ONLY BE CALLED BY THE VERIFICATION
93C> APPLICATION PROGRAM "GRIDTOBS", WHERE IT WAS PREVIOUSLY
94C> AN IN-LINE SUBROUTINE. IN GENERAL, UFBIN3 DOES NOT
95C> WORK PROPERLY IN OTHER APPLICATION PROGRAMS (I.E, THOSE
96C> THAT ARE READING PREPBUFR FILES) AT THIS TIME. ALWAYS
97C> USE UFBEVN INSTEAD!!
98C>
99C> THIS ROUTINE CALLS: BORT CONWIN ERRWRT GETWIN
100C> NEVN NXTWIN STATUS STRING
101C> THIS ROUTINE IS CALLED BY: None
102C> SHOULD NOT BE CALLED BY ANY APPLICATION
103C> PROGRAMS EXCEPT GRIDTOBS!!
104C>
105 SUBROUTINE ufbin3(LUNIT,USR,I1,I2,I3,IRET,JRET,STR)
106
107 USE modv_bmiss
108 USE moda_usrint
109 USE moda_msgcwd
110
111 COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
112 COMMON /quiet / iprt
113
114 CHARACTER*(*) STR
115 CHARACTER*128 ERRSTR
116 real*8 usr(i1,i2,i3)
117
118C----------------------------------------------------------------------
119C----------------------------------------------------------------------
120
121 iret = 0
122 jret = 0
123
124C CHECK THE FILE STATUS AND I-NODE
125C --------------------------------
126
127 CALL status(lunit,lun,il,im)
128 IF(il.EQ.0) GOTO 900
129 IF(il.GT.0) GOTO 901
130 IF(im.EQ.0) GOTO 902
131 IF(inode(lun).NE.inv(1,lun)) GOTO 903
132
133 IF(i1.LE.0) THEN
134 IF(iprt.GE.0) THEN
135 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
136 errstr = .LE.'BUFRLIB: UFBIN3 - 3rd ARG. (INPUT) IS 0, ' //
137 . 'SO RETURN WITH 6th AND 7th ARGS. (IRET, JRET) = 0; ' //
138 . '8th ARG. (STR) ='
139 CALL errwrt(errstr)
140 CALL errwrt(str)
141 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
142 CALL errwrt(' ')
143 ENDIF
144 GOTO 100
145 ELSEIF(i2.LE.0) THEN
146 IF(iprt.GE.0) THEN
147 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
148 errstr = .LE.'BUFRLIB: UFBIN3 - 4th ARG. (INPUT) IS 0, ' //
149 . 'SO RETURN WITH 6th AND 7th ARGS. (IRET, JRET) = 0; ' //
150 . '8th ARG. (STR) ='
151 CALL errwrt(errstr)
152 CALL errwrt(str)
153 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
154 CALL errwrt(' ')
155 ENDIF
156 GOTO 100
157 ELSEIF(i3.LE.0) THEN
158 IF(iprt.GE.0) THEN
159 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
160 errstr = .LE.'BUFRLIB: UFBIN3 - 5th ARG. (INPUT) IS 0, ' //
161 . 'SO RETURN WITH 6th AND 7th ARGS. (IRET, JRET) = 0; ' //
162 . '8th ARG. (STR) ='
163 CALL errwrt(errstr)
164 CALL errwrt(str)
165 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
166 CALL errwrt(' ')
167 ENDIF
168 GOTO 100
169 ENDIF
170
171C PARSE OR RECALL THE INPUT STRING
172C --------------------------------
173
174 CALL string(str,lun,i1,0)
175
176C INITIALIZE USR ARRAY
177C --------------------
178
179 DO k=1,i3
180 DO j=1,i2
181 DO i=1,i1
182 usr(i,j,k) = bmiss
183 ENDDO
184 ENDDO
185 ENDDO
186
187C LOOP OVER COND WINDOWS
188C ----------------------
189
190 inc1 = 1
191 inc2 = 1
192
1931 CALL conwin(lun,inc1,inc2)
194 IF(nnod.EQ.0) THEN
195 iret = i2
196 GOTO 100
197 ELSEIF(inc1.EQ.0) THEN
198 GOTO 100
199 ELSE
200 DO i=1,nnod
201 IF(nods(i).GT.0) THEN
202 ins2 = inc1
203 CALL getwin(nods(i),lun,ins1,ins2)
204 IF(ins1.EQ.0) GOTO 100
205 GOTO 2
206 ENDIF
207 ENDDO
208 ins1 = inc1
209 ins2 = inc2
210 ENDIF
211
212C READ PUSH DOWN STACK DATA INTO 3D ARRAYS
213C ----------------------------------------
214
2152 iret = iret+1
216 IF(iret.LE.i2) THEN
217 DO i=1,nnod
218 nnvn = nevn(nods(i),lun,ins1,ins2,i1,i2,i3,usr(i,iret,1))
219 jret = max(jret,nnvn)
220 ENDDO
221 ENDIF
222
223C DECIDE WHAT TO DO NEXT
224C ----------------------
225
226 CALL nxtwin(lun,ins1,ins2)
227 IF(ins1.GT.0 .AND. ins1.LT.inc2) GOTO 2
228 IF(ncon.GT.0) GOTO 1
229
230 IF(iret.EQ.0 .OR. jret.EQ.0) THEN
231 IF(iprt.GE.1) THEN
232 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
233 errstr = 'BUFRLIB: UFBIN3 - NO SPECIFIED VALUES READ IN, ' //
234 . 'SO RETURN WITH 6th AND/OR 7th ARGS. (IRET, JRET) = 0; ' //
235 . '8th ARG. (STR) ='
236 CALL errwrt(errstr)
237 CALL errwrt(str)
238 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
239 CALL errwrt(' ')
240 ENDIF
241 ENDIF
242
243C EXITS
244C -----
245
246100 RETURN
247900 CALL bort('BUFRLIB: UFBIN3 - INPUT BUFR FILE IS CLOSED, IT MUST'//
248 . ' BE OPEN FOR INPUT')
249901 CALL bort('BUFRLIB: UFBIN3 - INPUT BUFR FILE IS OPEN FOR OUTPUT'//
250 . ', IT MUST BE OPEN FOR INPUT')
251902 CALL bort('BUFRLIB: UFBIN3 - A MESSAGE MUST BE OPEN IN INPUT '//
252 . 'BUFR FILE, NONE ARE')
253903 CALL bort('BUFRLIB: UFBIN3 - LOCATION OF INTERNAL TABLE FOR '//
254 . 'INPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN '//
255 . 'INTERNAL SUBSET ARRAY')
256 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine conwin(LUN, INC1, INC2)
THIS SUBROUTINE SEARCHES CONSECUTIVE SUBSET BUFFER SEGMENTS FOR AN ELEMENT IDENTIFIED IN THE USER STR...
Definition: conwin.f:65
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
subroutine getwin(NODE, LUN, IWIN, JWIN)
GIVEN A NODE INDEX WITHIN THE INTERNAL JUMP/LINK TABLE, THIS SUBROUTINE LOOKS WITHIN THE CURRENT SUBS...
Definition: getwin.f:82
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
real *8, public bmiss
Current placeholder value to represent "missing" data when reading from or writing to BUFR files; thi...
Definition: modv_BMISS.f90:15
function nevn(NODE, LUN, INV1, INV2, I1, I2, I3, USR)
THIS FUNCTION LOOKS FOR ALL STACKED DATA EVENTS FOR A SPECIFIED DATA VALUE AND LEVEL WITHIN THE PORTI...
Definition: nevn.f:55
subroutine nxtwin(LUN, IWIN, JWIN)
GIVEN INDICES WITHIN THE INTERNAL JUMP/LINK TABLE WHICH POINT TO THE START AND END OF AN "RPC" WINDOW...
Definition: nxtwin.f:53
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:56
subroutine string(STR, LUN, I1, IO)
THIS SUBROUTINE CHECKS TO SEE IF A USER-SPECIFIED CHARACTER STRING IS IN THE STRING CACHE (ARRAYS IN ...
Definition: string.f:59
subroutine ufbin3(LUNIT, USR, I1, I2, I3, IRET, JRET, STR)
THIS SUBROUTINE READS SPECIFIED VALUES FROM THE CURRENT BUFR DATA SUBSET WITHIN INTERNAL ARRAYS.
Definition: ufbin3.f:106