NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
ufbtab.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE EITHER OPENS A BUFR FILE CONNECTED TO
5 C> ABS(LUNIN) FOR INPUT OPERATIONS (IF IT IS NOT ALREADY OPENED AS
6 C> SUCH), OR SAVES ITS POSITION AND REWINDS IT TO THE FIRST DATA
7 C> MESSAGE (IF BUFR FILE ALREADY OPENED), THE EXTENT OF ITS PROCESSING
8 C> IS DETERMINED BY THE SIGN OF LUNIN. IF LUNIN IS GREATER THAN ZERO,
9 C> THIS SUBROUTINE READS SPECIFIED VALUES FROM ALL DATA SUBSETS IN THE
10 C> BUFR FILE INTO INTERNAL ARRAYS AND RETURNS THESE VALUES ALONG WITH
11 C> A COUNT OF THE SUBSETS. IF LUNIN IS LESS THAN ZERO, THIS
12 C> SUBROUTINE RETURNS THE BUFR ARCHIVE LIBRARY'S GLOBAL VALUE FOR
13 C> MISSING (REGARDLESS OF THE MNEMONICS SPECIFIED IN STR)
14 C> ALONG WITH A COUNT OF THE SUBSETS (SEE REMARKS 2). FINALLY, THIS
15 C> SUBROUTINE EITHER CLOSES THE BUFR FILE IN ABS(LUNIN) (IF IT WAS
16 C> OPENED HERE) OR RESTORES IT TO ITS PREVIOUS READ/WRITE STATUS AND
17 C> POSITION (IF IT WAS NOT OPENED HERE). WHEN LUNIN IS GREATER THAN
18 C> ZERO, THE DATA VALUES CORRESPOND TO MNEMONICS, NORMALLY WHERE THERE
19 C> IS NO REPLICATION (THERE CAN BE REGULAR OR DELAYED REPLICATION, BUT
20 C> THIS SUBROUTINE WILL ONLY READ THE FIRST OCCURRENCE OF THE MNEMONIC
21 C> IN EACH SUBSET). UFBTAB PROVIDES A MECHANISM WHEREBY A USER CAN
22 C> EITHER DO A QUICK SCAN OF THE RANGE OF VALUES CORRESPONDING TO ONE
23 C> OR MORE MNEMNONICS AMONGST ALL DATA SUBSETS FOR AN ENTIRE BUFR FILE
24 C> (WHEN LUNIN IS GREATER THAN ZERO), OR SIMPLY OBTAIN A COUNT OF
25 C> SUBSETS IN THE BUFR FILE (WHEN LUNIN IS LESS THAN ZERO); NO OTHER
26 C> BUFR ARCHIVE LIBRARY ROUTINES HAVE TO BE CALLED. THIS SUBROUTINE
27 C> IS SIMILAR TO BUFR ARCHIVE LIBRARY SUBROUTINE UFBTAM EXCEPT UFBTAM
28 C> READS SUBSETS FROM MESSAGES STORED IN INTERNAL MEMORY AND IT HAS NO
29 C> OPTION FOR RETURNING ONLY A COUNT OF THE SUBSETS. IN ADDITION,
30 C> UFBTAM CURRENTLY CANNOT READ DATA FROM COMPRESSED BUFR MESSAGES.
31 C> UFBTAB CAN READ DATA FROM BOTH UNCOMPRESSED AND COMPRESSED BUFR
32 C> MESSAGES.
33 C>
34 C> PROGRAM HISTORY LOG:
35 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
36 C> 1998-07-08 J. WOOLLEN -- IMPROVED MACHINE PORTABILITY
37 C> 1998-10-27 J. WOOLLEN -- MODIFIED TO CORRECT PROBLEMS CAUSED BY IN-
38 C> LINING CODE WITH FPP DIRECTIVES
39 C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
40 C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
41 C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
42 C> BUFR FILES UNDER THE MPI)
43 C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
44 C> 10,000 TO 20,000 BYTES
45 C> 2002-05-14 J. WOOLLEN -- REMOVED OLD CRAY COMPILER DIRECTIVES
46 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
47 C> INTERDEPENDENCIES
48 C> 2003-11-04 D. KEYSER -- MODIFIED TO NOT ABORT WHEN THERE ARE TOO
49 C> MANY SUBSETS COMING IN (I.E., .GT. "I2"),
50 C> BUT RATHER JUST PROCESS "I2" REPORTS AND
51 C> PRINT A DIAGNOSTIC; MAXJL (MAXIMUM NUMBER
52 C> OF JUMP/LINK ENTRIES) INCREASED FROM 15000
53 C> TO 16000 (WAS IN VERIFICATION VERSION);
54 C> MODIFIED TO CALL ROUTINE REWNBF WHEN THE
55 C> BUFR FILE IS ALREADY OPENED, ALLOWS
56 C> SPECIFIC SUBSET INFORMATION TO BE READ FROM
57 C> A FILE IN THE MIDST OF ITS BEING READ FROM
58 C> OR WRITTEN TO), BEFORE OPENBF WAS ALWAYS
59 C> CALLED AND THIS WOULD HAVE LED TO AN ABORT
60 C> OF THE APPLICATION PROGRAM (WAS IN
61 C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
62 C> WRF; ADDED DOCUMENTATION (INCLUDING
63 C> HISTORY)
64 C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
65 C> 20,000 TO 50,000 BYTES
66 C> 2005-09-16 J. WOOLLEN -- WORKS FOR COMPRESSED BUFR MESSAGES; ADDED
67 C> OPTION TO RETURN ONLY SUBSET COUNT (WHEN
68 C> INPUT UNIT NUMBER IS LESS THAN ZERO)
69 C> 2006-04-14 J. ATOR -- ADD DECLARATION FOR CREF
70 C> 2007-01-19 J. ATOR -- REPLACED CALL TO PARSEQ WITH CALL TO PARSTR
71 C> 2009-04-21 J. ATOR -- USE ERRWRT
72 C> 2009-12-01 J. ATOR -- FIX BUG FOR COMPRESSED CHARACTER STRINGS
73 C> WHICH ARE IDENTICAL ACROSS ALL SUBSETS IN
74 C> A SINGLE MESSAGE
75 C> 2010-05-07 J. ATOR -- WHEN CALLING IREADMG, TREAT READ ERROR AS
76 C> END-OF-FILE CONDITION
77 C> 2012-03-02 J. ATOR -- USE FUNCTION UPS
78 C> 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
79 C> USE NEW OPENBF TYPE 'INX' TO OPEN AND CLOSE
80 C> THE C FILE WITHOUT CLOSING THE FORTRAN FILE
81 C> 2014-11-20 J. ATOR -- ENSURE OPENBF HAS BEEN CALLED AT LEAST ONCE
82 C> BEFORE CALLING STATUS
83 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
84 C> 2016-12-19 J. WOOLLEN -- FIX BUG TO PREVENT INVENTORY OVERFLOW
85 C>
86 C> USAGE: CALL UFBTAB (LUNIN, TAB, I1, I2, IRET, STR)
87 C> INPUT ARGUMENT LIST:
88 C> LUNIN - INTEGER: ABSOLUTE VALUE IS FORTRAN LOGICAL UNIT NUMBER
89 C> FOR BUFR FILE
90 C> I1 - INTEGER:
91 C> - IF LUNIN IS GREATER THAN ZERO: LENGTH OF FIRST
92 C> DIMENSION OF TAB (MUST BE AT LEAST AS LARGE AS THE
93 C> NUMBER OF BLANK-SEPARATED MNEMONICS IN STR)
94 C> - IF LUNIN IS LESS THAN ZERO: LENGTH OF FIRST
95 C> DIMENSION OF TAB (RECOMMEND PASSING IN WITH VALUE
96 C> OF 1 - SEE REMARKS 2)
97 C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF TAB
98 C> - IF LUNIN IS GREATER THAN ZERO: MUST BE AT LEAST AS
99 C> LARGE AS VALUE RETURNED IN IRET, OTHERWISE ONLY
100 C> FIRST I2 SUBSETS ARE RETURNED IN TAB
101 C> - IF LUNIN IS LESS THAN ZERO: RECOMMEND PASSING IN
102 C> WITH VALUE OF 1 - SEE REMARKS 2
103 C> STR - CHARACTER*(*):
104 C> - IF LUNIN IS GREATER THAN ZERO: STRING OF BLANK-
105 C> SEPARATED TABLE B MNEMONICS IN ONE-TO-ONE
106 C> CORRESPONDENCE WITH FIRST DIMENSION OF TAB, I1
107 C> (THE NUMBER OF MNEMONICS IN THE STRING MUST BE NO
108 C> LARGER THAN I1)
109 C> - THERE ARE THREE "GENERIC" MNEMONICS NOT
110 C> RELATED TO TABLE B, THESE RETURN THE FOLLOWING
111 C> INFORMATION IN CORRESPONDING TAB LOCATION:
112 C> 'NUL' WHICH ALWAYS RETURNS BMISS ("MISSING")
113 C> 'IREC' WHICH ALWAYS RETURNS THE CURRENT BUFR
114 C> MESSAGE (RECORD) NUMBER IN WHICH THIS
115 C> SUBSET RESIDES
116 C> 'ISUB' WHICH ALWAYS RETURNS THE CURRENT
117 C> SUBSET NUMBER OF THIS SUBSET WITHIN
118 C> THE BUFR MESSAGE (RECORD) NUMBER
119 C> 'IREC'
120 C> - IF LUNIN IS LESS THAN ZERO: DUMMY {RECOMMEND
121 C> PASSING IN STRING AS A 1-CHARACTER BLANK (i.e.,
122 C> ' ') - SEE REMARKS 2}
123 C>
124 C> OUTPUT ARGUMENT LIST:
125 C> TAB - REAL*8: (I1,I2):
126 C> - IF LUNIN IS GREATER THAN ZERO: STARTING ADDRESS OF
127 C> DATA VALUES READ FROM BUFR FILE
128 C> - IF LUNIN IS LESS THAN ZERO: STARTING ADDRESS OF
129 C> ARRAY OF VALUES ALL RETURNED WITH THE BUFRLIB'S
130 C> GLOBAL VALUE FOR MISSING (BMISS)
131 C> IRET - INTEGER: NUMBER OF DATA SUBSETS IN BUFR FILE
132 C> - IF LUNIN IS GREATER THAN ZERO: MUST BE NO LARGER
133 C> THAN I2, OTHERWISE ONLY FIRST I2 SUBSETS ARE
134 C> RETURNED IN TAB
135 C>
136 C> REMARKS:
137 C> 1) NOTE THAT UFBMEM CAN BE CALLED PRIOR TO THIS TO STORE THE BUFR
138 C> MESSAGES INTO INTERNAL MEMORY.
139 C>
140 C> 2) BELOW ARE TWO EXAMPLES WHERE THE USER CALLS UFBTAB WITH LUNIN
141 C> LESS THAN ZERO SO AS TO ONLY OBTAIN A COUNT OF SUBSETS IN A
142 C> BUFR FILE (ALONG WITH THE BUFRLIB'S GLOBAL VALUE FOR
143 C> "MISSING").
144 C>
145 C> EXAMPLE 1) I1 AND I2 ARE SET TO 1 SUCH THAT TAB IS A SCALAR AND
146 C> STR IS SET TO A 1-CHARACTER BLANK. THESE ARE THE
147 C> RECOMMENDED VALUES FOR I1, I2 AND STR SINCE THEY USE THE
148 C> LEAST AMOUNT OF MEMORY):
149 C>
150 C> REAL(8) TAB
151 C> ....
152 C> ....
153 C> CALL UFBTAB(-LUNIN,TAB,1,1,IRET,' ')
154 C> ....
155 C> ....
156 C>
157 C> HERE IRET WILL RETURN THE COUNT OF SUBSETS IN THE BUFR FILE
158 C> AND TAB WILL RETURN THE BUFRLIB'S GLOBAL VALUE FOR "MISSING"
159 C> (BMISS).
160 C>
161 C> EXAMPLE 2) I1 IS SET TO 4 AND I2 IS SET TO 8 SUCH THAT TAB IS A
162 C> 32-WORD ARRAY, AND STR IS SET TO A NONSENSICAL STRING.
163 C> THESE VALUES FOR I1, I2 AND STR WASTE MEMORY BUT GIVE THE
164 C> SAME ANSWERS FOR TAB AND IRET AS IN EXAMPLE 1 (FOR THE SAME
165 C> INPUT BUFR FILE!):
166 C>
167 C> REAL(8) TAB(4,8)
168 C> ....
169 C> ....
170 C> CALL UFBTAB(-LUNIN,TAB,4,8,IRET,'BUFR IS A WONDERFUL FMT')
171 C> ....
172 C> ....
173 C>
174 C> HERE IRET WILL AGAIN RETURN THE COUNT OF SUBSETS IN THE BUFR
175 C> FILE AND ALL 32 VALUES OF ARRAY TAB WILL RETURN THE
176 C> BUFRLIB'S GLOBAL VALUE FOR "MISSING" (BMISS).
177 C>
178 C> THE SIXTH ARGUMENT STR IS A DUMMY VALUE AND CAN BE SET TO
179 C> ANY CHARACTER STRING (AGAIN, A 1-CHARACTER BLANK ' ' IS
180 C> RECOMMENDED). THE THIRD ARGUMENT I1 HAS NO RELATIONSHIP WITH
181 C> THE NUMBER OF BLANK-SEPARATED MNEMONICS IN STR AND CAN BE SET
182 C> TO ANY INTEGER VALUE (AGAIN, 1 IS RECOMMENDED). THE FOURTH
183 C> ARGUMENT I2 HAS NO RELATIONSHIP WITH THE NUMBER OF DATA SUBSETS
184 C> IN THE BUFR FILE RETURNED IN IRET (AGAIN, 1 IS RECOMMENDED).
185 C>
186 C>.....................................................................
187 C>
188 C> THIS ROUTINE CALLS: BORT CLOSBF ERRWRT IREADMG
189 C> IREADSB MESGBC NMSUB OPENBF
190 C> PARSTR REWNBF STATUS STRING
191 C> UPB UPBB UPC UPS
192 C> USRTPL
193 C> THIS ROUTINE IS CALLED BY: None
194 C> Normally called only by application
195 C> programs.
196 C>
197  SUBROUTINE ufbtab(LUNIN,TAB,I1,I2,IRET,STR)
198 
199  USE modv_bmiss
200  USE moda_usrint
201  USE moda_msgcwd
202  USE moda_bitbuf
203  USE moda_tables
204 
205  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
206  COMMON /acmode/ iac
207  COMMON /quiet / iprt
208 
209  CHARACTER*(*) str
210  CHARACTER*128 bort_str,errstr
211  CHARACTER*40 cref
212  CHARACTER*10 tgs(100)
213  CHARACTER*8 subset,cval
214  equivalence(cval,rval)
215  LOGICAL openit,just_count
216  REAL*8 tab(i1,i2),rval,ups
217 
218  DATA maxtg /100/
219 
220 C-----------------------------------------------------------------------
221  mps(node) = 2**(ibt(node))-1
222  lps(lbit) = max(2**(lbit)-1,1)
223 C-----------------------------------------------------------------------
224 
225 C SET COUNTERS TO ZERO
226 C --------------------
227 
228  iret = 0
229  irec = 0
230  isub = 0
231  iacc = iac
232 
233 C CHECK FOR COUNT SUBSET ONLY OPTION (RETURNING THE BUFRLIB'S GLOBAL
234 C VALUE FOR MISSING IN OUTPUT ARRAY) INDICATED BY NEGATIVE UNIT
235 C ------------------------------------------------------------------
236 
237  lunit = abs(lunin)
238  just_count = lunin.LT.lunit
239 
240 C Make sure OPENBF has been called at least once before trying to
241 C call STATUS; otherwise, STATUS might try to access array space
242 C that hasn't yet been dynamically allocated.
243  CALL openbf(0,'FIRST',0)
244 
245  CALL status(lunit,lun,il,im)
246  openit = il.EQ.0
247 
248  IF(openit) THEN
249 
250 C OPEN BUFR FILE CONNECTED TO UNIT LUNIT IF IT IS NOT ALREADY OPEN
251 C ----------------------------------------------------------------
252 
253  CALL openbf(lunit,'INX',lunit)
254  ELSE
255 
256 C IF BUFR FILE ALREADY OPENED, SAVE POSITION & REWIND TO FIRST DATA MSG
257 C ---------------------------------------------------------------------
258 
259  CALL rewnbf(lunit,0)
260  ENDIF
261 
262  iac = 1
263 
264 C SET THE OUTPUT ARRAY VALUES TO THE BUFRLIB'S GLOBAL VALUE FOR
265 C MISSING (BMISS)
266 C -------------------------------------------------------------
267 
268  DO j=1,i2
269  DO i=1,i1
270  tab(i,j) = bmiss
271  ENDDO
272  ENDDO
273 
274  IF(just_count) THEN
275 
276 C COME HERE FOR COUNT ONLY OPTION (OUTPUT ARRAY VALUES REMAIN MISSING)
277 C --------------------------------------------------------------------
278 
279  DO WHILE(ireadmg(-lunit,subset,idate).GE.0)
280  iret = iret+nmsub(lunit)
281  ENDDO
282  goto 25
283  ENDIF
284 
285 C OTHERWISE, CHECK FOR SPECIAL TAGS IN STRING
286 C -------------------------------------------
287 
288  CALL parstr(str,tgs,maxtg,ntg,' ',.true.)
289  DO i=1,ntg
290  IF(tgs(i).EQ.'IREC') irec = i
291  IF(tgs(i).EQ.'ISUB') isub = i
292  ENDDO
293 
294 C READ A MESSAGE AND PARSE A STRING
295 C ---------------------------------
296 
297 10 IF(ireadmg(-lunit,subset,jdate).LT.0) goto 25
298  CALL string(str,lun,i1,0)
299  IF(irec.GT.0) nods(irec) = 0
300  IF(isub.GT.0) nods(isub) = 0
301 
302 C PARSE THE MESSAGE DEPENDING ON WHETHER COMPRESSED OR NOT
303 C --------------------------------------------------------
304 
305  CALL mesgbc(-lunit,mtyp,icmp)
306  IF(icmp.EQ.0) THEN
307  goto 15
308  ELSEIF(icmp.EQ.1) then
309  goto 115
310  ELSE
311  goto 900
312  ENDIF
313 
314 C ---------------------------------------------
315 C THIS BRANCH IS FOR UNCOMPRESSED MESSAGES
316 C ---------------------------------------------
317 C SEE IF THERE IS ANOTHER SUBSET IN THE MESSAGE
318 C ---------------------------------------------
319 
320 15 IF(nsub(lun).EQ.msub(lun)) goto 10
321  IF(iret+1.GT.i2) goto 99
322  iret = iret+1
323 
324  DO i=1,nnod
325  nods(i) = abs(nods(i))
326  ENDDO
327 
328 C PARSE THE STRING NODES FROM A SUBSET
329 C ------------------------------------
330 
331  mbit = mbyt(lun)*8 + 16
332  nbit = 0
333  n = 1
334  CALL usrtpl(lun,n,n)
335 20 IF(n+1.LE.nval(lun)) THEN
336  n = n+1
337  node = inv(n,lun)
338  mbit = mbit+nbit
339  nbit = ibt(node)
340  IF(itp(node).EQ.1) THEN
341  CALL upbb(ival,nbit,mbit,mbay(1,lun))
342  CALL usrtpl(lun,n,ival)
343  ENDIF
344  DO i=1,nnod
345  IF(nods(i).EQ.node) THEN
346  IF(itp(node).EQ.1) THEN
347  CALL upbb(ival,nbit,mbit,mbay(1,lun))
348  tab(i,iret) = ival
349  ELSEIF(itp(node).EQ.2) THEN
350  CALL upbb(ival,nbit,mbit,mbay(1,lun))
351  IF(ival.LT.mps(node)) tab(i,iret) = ups(ival,node)
352  ELSEIF(itp(node).EQ.3) THEN
353  cval = ' '
354  kbit = mbit
355  CALL upc(cval,nbit/8,mbay(1,lun),kbit,.true.)
356  tab(i,iret) = rval
357  ENDIF
358  nods(i) = -nods(i)
359  goto 20
360  ENDIF
361  ENDDO
362  DO i=1,nnod
363  IF(nods(i).GT.0) goto 20
364  ENDDO
365  ENDIF
366 
367 C UPDATE THE SUBSET POINTERS BEFORE NEXT READ
368 C -------------------------------------------
369 
370  ibit = mbyt(lun)*8
371  CALL upb(nbyt,16,mbay(1,lun),ibit)
372  mbyt(lun) = mbyt(lun) + nbyt
373  nsub(lun) = nsub(lun) + 1
374  IF(irec.GT.0) tab(irec,iret) = nmsg(lun)
375  IF(isub.GT.0) tab(isub,iret) = nsub(lun)
376  goto 15
377 
378 C ---------------------------------------------
379 C THIS BRANCH IS FOR COMPRESSED MESSAGES
380 C ---------------------------------------------
381 C STORE ANY MESSAGE AND/OR SUBSET COUNTERS
382 C ---------------------------------------------
383 
384 C CHECK ARRAY BOUNDS
385 C ------------------
386 
387 115 IF(iret+msub(lun).GT.i2) goto 99
388 
389 C STORE MESG/SUBS TOKENS
390 C ----------------------
391 
392  IF(irec.GT.0.OR.isub.GT.0) THEN
393  DO nsb=1,msub(lun)
394  IF(irec.GT.0) tab(irec,iret+nsb) = nmsg(lun)
395  IF(isub.GT.0) tab(isub,iret+nsb) = nsb
396  ENDDO
397  ENDIF
398 
399 C SETUP A NEW SUBSET TEMPLATE, PREPARE TO SUB-SURF
400 C ------------------------------------------------
401 
402  CALL usrtpl(lun,1,1)
403  ibit = mbyt(lun)
404  n = 0
405 
406 C UNCOMPRESS CHOSEN NODES INTO THE TAB ARRAY (FIRST OCCURANCES ONLY)
407 C ------------------------------------------------------------------
408 
409 C READ ELEMENTS LOOP
410 C ------------------
411 
412 120 DO n=n+1,nval(lun)
413  node = inv(n,lun)
414  nbit = ibt(node)
415  ityp = itp(node)
416 
417 C FIRST TIME IN RESET NODE INDEXES, OR CHECK FOR NODE(S) STILL NEEDED
418 C -------------------------------------------------------------------
419 
420  IF(n.EQ.1) THEN
421  DO i=1,nnod
422  nods(i) = abs(nods(i))
423  ENDDO
424  ELSE
425  DO i=1,nnod
426  IF(nods(i).GT.0) goto 125
427  ENDDO
428  goto 135
429  ENDIF
430 
431 C FIND THE EXTENT OF THE NEXT SUB-GROUP
432 C -------------------------------------
433 
434 125 IF(ityp.EQ.1.OR.ityp.EQ.2) THEN
435  CALL upb(lref,nbit,mbay(1,lun),ibit)
436  CALL upb(linc, 6,mbay(1,lun),ibit)
437  nibit = ibit + linc*msub(lun)
438  ELSEIF(ityp.EQ.3) THEN
439  cref=' '
440  CALL upc(cref,nbit/8,mbay(1,lun),ibit,.true.)
441  CALL upb(linc, 6,mbay(1,lun),ibit)
442  nibit = ibit + 8*linc*msub(lun)
443  ELSE
444  goto 120
445  ENDIF
446 
447 C PROCESS A TYPE1 NODE INTO NVAL
448 C ------------------------------
449 
450  IF(ityp.EQ.1) THEN
451  jbit = ibit + linc
452  CALL upb(ninc,linc,mbay(1,lun),jbit)
453  ival = lref+ninc
454  CALL usrtpl(lun,n,ival)
455  goto 120
456  ENDIF
457 
458 C LOOP OVER STRING NODES
459 C ----------------------
460 
461  DO i=1,nnod
462 
463 C CHOSEN NODES LOOP - KEEP TRACK OF NODES NEEDED AND NODES FOUND
464 C --------------------------------------------------------------
465 
466  IF(node.NE.nods(i)) goto 130
467  nods(i) = -nods(i)
468  lret = iret
469 
470 C PROCESS A FOUND NODE INTO TAB
471 C -----------------------------
472 
473  IF(ityp.EQ.1.OR.ityp.EQ.2) THEN
474  DO nsb=1,msub(lun)
475  jbit = ibit + linc*(nsb-1)
476  CALL upb(ninc,linc,mbay(1,lun),jbit)
477  ival = lref+ninc
478  lret = lret+1
479  IF(ninc.LT.lps(linc)) tab(i,lret) = ups(ival,node)
480  ENDDO
481  ELSEIF(ityp.EQ.3) THEN
482  DO nsb=1,msub(lun)
483  IF(linc.EQ.0) THEN
484  cval = cref
485  ELSE
486  jbit = ibit + linc*(nsb-1)*8
487  cval = ' '
488  CALL upc(cval,linc,mbay(1,lun),jbit,.true.)
489  ENDIF
490  lret = lret+1
491  tab(i,lret) = rval
492  ENDDO
493  ELSE
494  CALL bort('UFBTAB - INVALID ELEMENT TYPE SPECIFIED')
495  ENDIF
496 
497 C END OF LOOPS FOR COMPRESSED MESSAGE PARSING
498 C -------------------------------------------
499 
500 130 CONTINUE
501  ENDDO
502  ibit = nibit
503 
504 C END OF READ ELEMENTS LOOP
505 C -------------------------
506 
507  ENDDO
508 135 iret = iret+msub(lun)
509 
510 C END OF MESSAGE PARSING - GO BACK FOR ANOTHER
511 C --------------------------------------------
512 
513  goto 10
514 
515 C -------------------------------------------
516 C ERROR PROCESSING AND EXIT ROUTES BELOW
517 C -------------------------------------------
518 C EMERGENCY ROOM TREATMENT FOR ARRAY OVERFLOW
519 C -------------------------------------------
520 
521 99 nrep = iret
522  DO WHILE(ireadsb(lunit).EQ.0)
523  nrep = nrep+1
524  ENDDO
525  DO WHILE(ireadmg(-lunit,subset,jdate).GE.0)
526  nrep = nrep+nmsub(lunit)
527  ENDDO
528  IF(iprt.GE.0) THEN
529  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
530  WRITE ( unit=errstr, fmt='(A,A,I8,A,A)' )
531  . 'BUFRLIB: UFBTAB - THE NO. OF DATA SUBSETS IN THE BUFR FILE ',
532  . .GT.'IS LIMIT OF ', i2, ' IN THE 4TH ARG. (INPUT) - ',
533  . 'INCOMPLETE READ'
534  CALL errwrt(errstr)
535  WRITE ( unit=errstr, fmt='(A,I8,A,I8,A)' )
536  . '>>>UFBTAB STORED ', iret, ' REPORTS OUT OF ', nrep, '<<<'
537  CALL errwrt(errstr)
538  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
539  CALL errwrt(' ')
540  ENDIF
541 
542 
543 25 IF(openit) THEN
544 
545 C CLOSE BUFR FILE IF IT WAS OPENED HERE
546 C -------------------------------------
547 
548  CALL closbf(lunit)
549  ELSE
550 
551 C RESTORE BUFR FILE TO PREV. STATUS & POSITION IF NOT ORIG. OPENED HERE
552 C ---------------------------------------------------------------------
553 
554  CALL rewnbf(lunit,1)
555  ENDIF
556 
557  iac = iacc
558 
559 C EXITS
560 C -----
561 
562  RETURN
563 900 WRITE(bort_str,'("BUFRLIB: UFBTAB - INVALID COMPRESSION '//
564  . 'INDICATOR (ICMP=",I3," RETURNED FROM BUFR ARCHIVE LIBRARY '//
565  . 'ROUTINE MESGBC")') icmp
566  CALL bort(bort_str)
567  END
subroutine upbb(NVAL, NBITS, IBIT, IBAY)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY...
Definition: upbb.f:42
function ireadmg(LUNIT, SUBSET, IDATE)
This function calls BUFRLIB subroutine readmg() and passes back its return code as the function value...
Definition: ireadmg.f:43
subroutine upb(NVAL, NBITS, IBAY, IBIT)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY...
Definition: upb.f:49
function ireadsb(LUNIT)
This function calls BUFRLIB subroutine readsb() and passes back its return code as the function value...
Definition: ireadsb.f:30
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS...
Definition: parstr.f:37
subroutine usrtpl(LUN, INVN, NBMP)
THIS SUBROUTINE STORES THE SUBSET TEMPLATE INTO INTERNAL SUBSET ARRAYS IN MODULE USRINT FOR CASES OF ...
Definition: usrtpl.f:51
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
Definition: closbf.F:36
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
Definition: openbf.F:157
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
subroutine upc(CHR, NCHR, IBAY, IBIT, CNVNULL)
THIS SUBROUTINE UNPACKS AND RETURNS A CHARACTER STRING OF LENGTH NCHR CONTAINED WITHIN NCHR BYTES OF ...
Definition: upc.f:49
subroutine mesgbc(LUNIN, MESGTYP, ICOMP)
THIS SUBROUTINE EXAMINES A BUFR MESSAGE AND RETURNS BOTH THE MESSAGE TYPE FROM SECTION 1 AND A MESSAG...
Definition: mesgbc.f:96
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:58
This module contains array and variable declarations used to store the internal jump/link table...
Definition: moda_tables.F:13
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:61
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39
function nmsub(LUNIT)
This function returns the total number of data subsets available within the BUFR message that was mos...
Definition: nmsub.f:31
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
This module contains array and variable declarations used to store BUFR messages internally for multi...
Definition: moda_bitbuf.F:10
subroutine ufbtab(LUNIN, TAB, I1, I2, IRET, STR)
THIS SUBROUTINE EITHER OPENS A BUFR FILE CONNECTED TO ABS(LUNIN) FOR INPUT OPERATIONS (IF IT IS NOT A...
Definition: ufbtab.f:197
REAL *8 function ups(IVAL, NODE)
THIS FUNCTION UNPACKS A REAL*8 USER VALUE FROM A PACKED BUFR INTEGER BY APPLYING THE PROPER SCALE AND...
Definition: ups.f:31
subroutine rewnbf(LUNIT, ISR)
THIS SUBROUTINE, DEPENDING ON THE VALUE OF ISR, WILL EITHER: 1) STORE THE CURRENT PARAMETERS ASSOCIAT...
Definition: rewnbf.f:64