NCEPLIBS-bufr 11.7.1
ufbevn.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
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). OTHER THAN THE ADDITION OF A THIRD
17C> DIMENSION AND THE READ ONLY RESTRICTION, THE CONTEXT AND USAGE OF
18C> UFBEVN IS EXACTLY THE SAME AS FOR BUFR ARCHIVE LIBRARY SUBROUTINES
19C> UFBINT, UFBREP AND UFBSEQ. THIS SUBROUTINE IS DESIGNED TO READ
20C> EVENT INFORMATION FROM "PREPBUFR" TYPE BUFR FILES. PREPBUFR FILES
21C> HAVE THE FOLLOWING BUFR TABLE EVENT STRUCTURE (NOTE SIXTEEN
22C> CHARACTERS HAVE BEEN REMOVED FROM THE LAST COLUMN TO ALLOW THE
23C> TABLE TO FIT IN THIS DOCBLOCK):
24C>
25C> | ADPUPA | HEADR {PLEVL}
26C> |----------|---------------
27C> | HEADR | SID XOB YOB DHR ELV TYP T29 TSB ITP SQN
28C> | PLEVL | CAT <PINFO> <QINFO> <TINFO> <ZINFO> <WINFO>
29C> | PINFO | [PEVN] <PBACKG> <PPOSTP>
30C> | QINFO | [QEVN] TDO <QBACKG> <QPOSTP>
31C> | TINFO | [TEVN] TVO <TBACKG> <TPOSTP>
32C> | ZINFO | [ZEVN] <ZBACKG> <ZPOSTP>
33C> | WINFO | [WEVN] <WBACKG> <WPOSTP>
34C> | PEVN | POB PQM PPC PRC
35C> | QEVN | QOB QQM QPC QRC
36C> | TEVN | TOB TQM TPC TRC
37C> | ZEVN | ZOB ZQM ZPC ZRC
38C> | WEVN | UOB WQM WPC WRC VOB
39C> | PBACKG | POE PFC
40C> | QBACKG | QOE QFC
41C> | TBACKG | TOE TFC
42C> | ZBACKG | ZOE ZFC
43C> | WBACKG | WOE UFC VFC
44C> | PPOSTP | PAN
45C> | QPOSTP | QAN
46C> | TPOSTP | TAN
47C> | ZPOSTP | ZAN
48C> | WPOSTP | UAN VAN
49C>
50C> NOTE THAT THE EIGHT-BIT DELAYED REPLIATION EVENT SEQUENCES "[xxxx]"
51C> ARE NESTED INSIDE ONE-BIT DELAYED REPLICATED SEQUENCES "<yyyy>".
52C> THE ANALOGOUS BUFR ARCHIVE LIBRARY SUBROUTINE UFBIN3 DOES NOT WORK
53C> PROPERLY ON THIS TYPE OF EVENT STRUCTURE. IT WORKS ONLY ON THE
54C> EVENT STRUCTURE FOUND IN "PREPFITS" TYPE BUFR FILES (SEE UFBIN3 FOR
55C> MORE DETAILS). IN TURN, UFBEVN DOES NOT WORK PROPERLY ON THE EVENT
56C> STRUCTURE FOUND IN PREPFITS FILES (ALWAYS USE UFBIN3 IN THIS CASE).
57C> ONE OTHER DIFFERENCE BETWEEN UFBEVN AND UFBIN3 IS THAT UFBEVN
58C> STORES THE MAXIMUM NUMBER OF EVENTS FOUND FOR ALL DATA VALUES
59C> SPECIFIED AMONGST ALL LEVELS RETURNED INTERNALLY IN COMMON BLOCK
60C> /UFBN3C/. UFBIN3 RETURNS THIS VALUE AS AN ADDITIONAL OUTPUT
61C> ARGUMENT.
62C>
63C> PROGRAM HISTORY LOG:
64C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
65C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
66C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
67C> ROUTINE "BORT"; IMPROVED MACHINE
68C> PORTABILITY
69C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
70C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
71C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
72C> BUFR FILES UNDER THE MPI)
73C> 2003-11-04 J. WOOLLEN -- SAVES THE MAXIMUM NUMBER OF EVENTS FOUND
74C> FOR ALL DATA VALUES SPECIFIED AMONGST ALL
75C> LEVELS RETURNED AS VARIABLE MAXEVN IN NEW
76C> COMMON BLOCK /UFBN3C/
77C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
78C> INTERDEPENDENCIES
79C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
80C> INCREASED FROM 15000 TO 16000 (WAS IN
81C> VERIFICATION VERSION); ADDED CALL TO BORT
82C> IF BUFR FILE IS OPEN FOR OUTPUT; UNIFIED/
83C> PORTABLE FOR WRF; ADDED DOCUMENTATION
84C> (INCLUDING HISTORY); OUTPUTS MORE COMPLETE
85C> DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
86C> ABNORMALLY OR UNUSUAL THINGS HAPPEN
87C> 2009-04-21 J. ATOR -- USE ERRWRT
88C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
89C>
90C> USAGE: CALL UFBEVN (LUNIT, USR, I1, I2, I3, IRET, STR)
91C> INPUT ARGUMENT LIST:
92C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
93C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR (MUST BE AT
94C> LEAST AS LARGE AS THE NUMBER OF BLANK-SEPARATED
95C> MNEMONICS IN STR)
96C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
97C> I3 - INTEGER: LENGTH OF THIRD DIMENSION OF USR (MAXIMUM
98C> VALUE IS 255)
99C> STR - CHARACTER*(*): STRING OF BLANK-SEPARATED TABLE B
100C> MNEMONICS IN ONE-TO-ONE CORRESPONDENCE WITH FIRST
101C> DIMENSION OF USR
102C> - THERE ARE THREE "GENERIC" MNEMONICS NOT RELATED
103C> TO TABLE B, THESE RETURN THE FOLLOWING
104C> INFORMATION IN CORRESPONDING USR LOCATION:
105C> 'NUL' WHICH ALWAYS RETURNS BMISS ("MISSING")
106C> 'IREC' WHICH ALWAYS RETURNS THE CURRENT BUFR
107C> MESSAGE (RECORD) NUMBER IN WHICH THIS
108C> SUBSET RESIDES
109C> 'ISUB' WHICH ALWAYS RETURNS THE CURRENT SUBSET
110C> NUMBER OF THIS SUBSET WITHIN THE BUFR
111C> MESSAGE (RECORD) NUMBER 'IREC'
112C>
113C> OUTPUT ARGUMENT LIST:
114C> USR - REAL*8: (I1,I2,I3) STARTING ADDRESS OF DATA VALUES
115C> READ FROM DATA SUBSET
116C> IRET - INTEGER: NUMBER OF "LEVELS" OF DATA VALUES READ FROM
117C> DATA SUBSET (MUST BE NO LARGER THAN I2)
118C>
119C> REMARKS:
120C> APPLICATION PROGRAMS READING PREPFITS FILES SHOULD NOT CALL THIS
121C> ROUTINE.
122C>
123C> THIS ROUTINE CALLS: BORT CONWIN ERRWRT GETWIN
124C> NVNWIN NXTWIN STATUS STRING
125C> THIS ROUTINE IS CALLED BY: None
126C> Normally called only by application
127C> programs.
128C>
129 SUBROUTINE ufbevn(LUNIT,USR,I1,I2,I3,IRET,STR)
130
131 USE modv_bmiss
132 USE moda_usrint
133 USE moda_msgcwd
134
135 COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
136 COMMON /ufbn3c/ maxevn
137 COMMON /quiet / iprt
138
139 CHARACTER*(*) STR
140 CHARACTER*128 ERRSTR
141 dimension invn(255)
142 real*8 usr(i1,i2,i3)
143
144C----------------------------------------------------------------------
145C----------------------------------------------------------------------
146
147 maxevn = 0
148 iret = 0
149
150C CHECK THE FILE STATUS AND I-NODE
151C --------------------------------
152
153 CALL status(lunit,lun,il,im)
154 IF(il.EQ.0) GOTO 900
155 IF(il.GT.0) GOTO 901
156 IF(im.EQ.0) GOTO 902
157 IF(inode(lun).NE.inv(1,lun)) GOTO 903
158
159 IF(i1.LE.0) THEN
160 IF(iprt.GE.0) THEN
161 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
162 errstr = .LE.'BUFRLIB: UFBEVN - 3rd ARG. (INPUT) IS 0, ' //
163 . 'SO RETURN WITH 6th ARG. (IRET) = 0; 7th ARG. (STR) ='
164 CALL errwrt(errstr)
165 CALL errwrt(str)
166 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
167 CALL errwrt(' ')
168 ENDIF
169 GOTO 100
170 ELSEIF(i2.LE.0) THEN
171 IF(iprt.GE.0) THEN
172 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
173 errstr = .LE.'BUFRLIB: UFBEVN - 4th ARG. (INPUT) IS 0, ' //
174 . 'SO RETURN WITH 6th ARG. (IRET) = 0; 7th ARG. (STR) ='
175 CALL errwrt(errstr)
176 CALL errwrt(str)
177 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
178 CALL errwrt(' ')
179 ENDIF
180 GOTO 100
181 ELSEIF(i3.LE.0) THEN
182 IF(iprt.GE.0) THEN
183 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
184 errstr = .LE.'BUFRLIB: UFBEVN - 5th ARG. (INPUT) IS 0, ' //
185 . 'SO RETURN WITH 6th ARG. (IRET) = 0; 7th ARG. (STR) ='
186 CALL errwrt(errstr)
187 CALL errwrt(str)
188 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
189 CALL errwrt(' ')
190 ENDIF
191 GOTO 100
192 ENDIF
193
194C PARSE OR RECALL THE INPUT STRING
195C --------------------------------
196
197 CALL string(str,lun,i1,0)
198
199C INITIALIZE USR ARRAY
200C --------------------
201
202 DO k=1,i3
203 DO j=1,i2
204 DO i=1,i1
205 usr(i,j,k) = bmiss
206 ENDDO
207 ENDDO
208 ENDDO
209
210C LOOP OVER COND WINDOWS
211C ----------------------
212
213 inc1 = 1
214 inc2 = 1
215
2161 CALL conwin(lun,inc1,inc2)
217 IF(nnod.EQ.0) THEN
218 iret = i2
219 GOTO 100
220 ELSEIF(inc1.EQ.0) THEN
221 GOTO 100
222 ELSE
223 DO i=1,nnod
224 IF(nods(i).GT.0) THEN
225 ins2 = inc1
226 CALL getwin(nods(i),lun,ins1,ins2)
227 IF(ins1.EQ.0) GOTO 100
228 GOTO 2
229 ENDIF
230 ENDDO
231 ins1 = inc1
232 ins2 = inc2
233 ENDIF
234
235C READ PUSH DOWN STACK DATA INTO 3D ARRAYS
236C ----------------------------------------
237
2382 iret = iret+1
239 IF(iret.LE.i2) THEN
240 DO i=1,nnod
241 IF(nods(i).GT.0) THEN
242 nnvn = nvnwin(nods(i),lun,ins1,ins2,invn,i3)
243 maxevn = max(nnvn,maxevn)
244 DO n=1,nnvn
245 usr(i,iret,n) = val(invn(n),lun)
246 ENDDO
247 ENDIF
248 ENDDO
249 ENDIF
250
251C DECIDE WHAT TO DO NEXT
252C ----------------------
253
254 CALL nxtwin(lun,ins1,ins2)
255 IF(ins1.GT.0 .AND. ins1.LT.inc2) GOTO 2
256 IF(ncon.GT.0) GOTO 1
257
258 IF(iret.EQ.0) THEN
259 IF(iprt.GE.1) THEN
260 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
261 errstr = 'BUFRLIB: UFBEVN - NO SPECIFIED VALUES READ IN, ' //
262 . 'SO RETURN WITH 6th ARG. (IRET) = 0; 7th ARG. (STR) ='
263 CALL errwrt(errstr)
264 CALL errwrt(str)
265 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
266 CALL errwrt(' ')
267 ENDIF
268 ENDIF
269
270C EXITS
271C -----
272
273100 RETURN
274900 CALL bort('BUFRLIB: UFBEVN - INPUT BUFR FILE IS CLOSED, IT MUST'//
275 . ' BE OPEN FOR INPUT')
276901 CALL bort('BUFRLIB: UFBEVN - INPUT BUFR FILE IS OPEN FOR OUTPUT'//
277 . ', IT MUST BE OPEN FOR INPUT')
278902 CALL bort('BUFRLIB: UFBEVN - A MESSAGE MUST BE OPEN IN INPUT '//
279 . 'BUFR FILE, NONE ARE')
280903 CALL bort('BUFRLIB: UFBEVN - LOCATION OF INTERNAL TABLE FOR '//
281 . 'INPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN '//
282 . 'INTERNAL SUBSET ARRAY')
283 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 nvnwin(NODE, LUN, INV1, INV2, INVN, NMAX)
THIS FUNCTION LOOKS FOR AND RETURNS ALL OCCURRENCES OF A SPECIFIED NODE WITHIN THE PORTION OF THE CUR...
Definition: nvnwin.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 ufbevn(LUNIT, USR, I1, I2, I3, IRET, STR)
THIS SUBROUTINE READS SPECIFIED VALUES FROM THE CURRENT BUFR DATA SUBSET WITHIN INTERNAL ARRAYS.
Definition: ufbevn.f:130