NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
ufbtam.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE READS SPECIFIED VALUES INTO INTERNAL ARRAYS
5 C> FROM ALL DATA SUBSETS IN BUFR MESSAGES STORED IN INTERNAL MEMORY.
6 C> THE DATA VALUES CORRESPOND TO MNEMONICS, NORMALLY WHERE THERE IS NO
7 C> REPLICATION (THERE CAN BE REGULAR OR DELAYED REPLICATION, BUT THIS
8 C> SUBROUTINE WILL ONLY READ THE FIRST OCCURRENCE OF THE MNEMONIC IN
9 C> EACH SUBSET). UFBTAM PROVIDES A MECHANISM WHEREBY A USER CAN DO A
10 C> QUICK SCAN OF THE RANGE OF VALUES CORRESPONDING TO ONE OR MORE
11 C> MNEMNONICS AMONGST ALL DATA SUBSETS FOR A GROUP OF BUFR MESSAGES
12 C> STORED IN INTERNAL MEMORY, NO OTHER BUFR ARCHIVE LIBRARY ROUTINES
13 C> HAVE TO BE CALLED. THIS SUBROUTINE IS SIMILAR TO BUFR ARCHIVE
14 C> LIBRARY SUBROUTINE UFBTAB EXCEPT UFBTAB READS SUBSETS FROM MESSAGES
15 C> IN A PHYSICAL BUFR FILE. UFBTAM CURRENTLY CANNOT READ DATA FROM
16 C> COMPRESSED BUFR MESSAGES.
17 C>
18 C> PROGRAM HISTORY LOG:
19 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
20 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
21 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
22 C> ROUTINE "BORT"
23 C> 1998-10-27 J. WOOLLEN -- MODIFIED TO CORRECT PROBLEMS CAUSED BY IN-
24 C> LINING CODE WITH FPP DIRECTIVES
25 C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
26 C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
27 C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
28 C> BUFR FILES UNDER THE MPI)
29 C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
30 C> 10,000 TO 20,000 BYTES
31 C> 2001-08-15 D. KEYSER -- PARAMETER MAXMEM (THE MAXIMUM NUMBER OF
32 C> BYTES REQUIRED TO STORE ALL MESSAGES
33 C> INTERNALLY) WAS INCREASED FROM 8 MBYTES TO
34 C> 16 MBYTES; MODIFIED TO NOT ABORT WHEN THERE
35 C> ARE TOO MANY SUBSETS COMING IN (I.E., .GT.
36 C> I2), BUT RATHER JUST PROCESS I2 REPORTS AND
37 C> PRINT A DIAGNOSTIC
38 C> 2002-05-14 J. WOOLLEN -- REMOVED OLD CRAY COMPILER DIRECTIVES
39 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
40 C> INTERDEPENDENCIES
41 C> 2003-11-04 D. KEYSER -- PARAMETER MAXMSG (THE MAXIMUM NUMBER OF
42 C> BUFR MESSAGES WHICH CAN BE STORED
43 C> INTERNALLY) INCREASED FROM 50000 TO 200000;
44 C> MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
45 C> INCREASED FROM 15000 TO 16000 (WAS IN
46 C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
47 C> WRF; ADDED DOCUMENTATION (INCLUDING
48 C> HISTORY); OUTPUTS MORE COMPLETE DIAGNOSTIC
49 C> INFO WHEN ROUTINE TERMINATES ABNORMALLY
50 C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
51 C> 20,000 TO 50,000 BYTES
52 C> 2004-11-15 D. KEYSER -- PARAMETER MAXMEM (THE MAXIMUM NUMBER OF
53 C> BYTES REQUIRED TO STORE ALL MESSAGES
54 C> INTERNALLY) WAS INCREASED FROM 16 MBYTES TO
55 C> 50 MBYTES
56 C> 2007-01-19 J. ATOR -- REPLACED CALL TO PARSEQ WITH CALL TO PARSTR
57 C> 2009-04-21 J. ATOR -- USE ERRWRT
58 C> 2009-10-21 D. KEYSER -- ADDED OPTION TO INPUT NEW MNEMONIC "ITBL"
59 C> IN ARGUMENT STR, RETURNS THE BUFR
60 C> DICTIONARY TABLE NUMBER ASSOCIATED WITH
61 C> EACH SUBSET IN INTERNAL MEMORY
62 C> 2012-03-02 J. ATOR -- USE FUNCTION UPS
63 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
64 C>
65 C> USAGE: CALL UFBTAM (TAB, I1, I2, IRET, STR)
66 C> INPUT ARGUMENT LIST:
67 C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF TAB (MUST BE AT
68 C> LEAST AS LARGE AS THE NUMBER OF BLANK-SEPARATED
69 C> MNEMONICS IN STR)
70 C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF TAB
71 C> STR - CHARACTER*(*): STRING OF BLANK-SEPARATED TABLE B
72 C> MNEMONICS IN ONE-TO-ONE CORRESPONDENCE WITH FIRST
73 C> DIMENSION OF TAB
74 C> - THERE ARE THREE "GENERIC" MNEMONICS NOT RELATED
75 C> TO TABLE B, THESE RETURN THE FOLLOWING
76 C> INFORMATION IN CORRESPONDING TAB LOCATION:
77 C> 'NUL' WHICH ALWAYS RETURNS BMISS ("MISSING")
78 C> 'IREC' WHICH ALWAYS RETURNS THE BUFR MESSAGE
79 C> (RECORD) NUMBER IN WHICH EACH SUBSET IN
80 C> INTERNAL MEMORY RESIDES
81 C> 'ISUB' WHICH ALWAYS RETURNS THE LOCATION WITHIN
82 C> MESSAGE "IREC" (I.E., THE SUBSET NUMBER)
83 C> FOR EACH SUBSET IN INTERNAL MEMORY
84 C> 'ITBL' WHICH ALWAYS RETURNS THE BUFR DICTIONARY
85 C> TABLE NUMBER ASSOCIATED WITH EACH SUBSET
86 C> IN INTERNAL MEMORY
87 C>
88 C> OUTPUT ARGUMENT LIST:
89 C> TAB - REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES READ
90 C> FROM INTERNAL MEMORY
91 C> IRET - INTEGER: NUMBER OF DATA SUBSETS IN INTERNAL MEMORY
92 C> (MUST BE NO LARGER THAN I2)
93 C>
94 C> REMARKS:
95 C> NOTE THAT UFBMEM IS CALLED PRIOR TO THIS TO STORE THE BUFR
96 C> MESSAGES INTO INTERNAL MEMORY.
97 C>
98 C> THIS ROUTINE CALLS: BORT ERRWRT NMSUB PARSTR
99 C> RDMEMM STATUS STRING UPB
100 C> UPBB UPC UPS USRTPL
101 C> THIS ROUTINE IS CALLED BY: None
102 C> Normally called only by application
103 C> programs.
104 C>
105  SUBROUTINE ufbtam(TAB,I1,I2,IRET,STR)
106 
107  USE modv_bmiss
108  USE moda_usrint
109  USE moda_msgcwd
110  USE moda_bitbuf
111  USE moda_msgmem
112  USE moda_tables
113 
114  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),vals(10),kons(10)
115  COMMON /quiet / iprt
116 
117  CHARACTER*(*) str
118  CHARACTER*128 bort_str,errstr
119  CHARACTER*10 tgs(100)
120  CHARACTER*8 subset,cval
121  equivalence(cval,rval)
122  REAL*8 tab(i1,i2),rval,ups
123 
124  DATA maxtg /100/
125 
126 C-----------------------------------------------------------------------
127  mps(node) = 2**(ibt(node))-1
128 C-----------------------------------------------------------------------
129 
130  iret = 0
131 
132  IF(msgp(0).EQ.0) goto 100
133 
134  DO j=1,i2
135  DO i=1,i1
136  tab(i,j) = bmiss
137  ENDDO
138  ENDDO
139 
140 C CHECK FOR SPECIAL TAGS IN STRING
141 C --------------------------------
142 
143  CALL parstr(str,tgs,maxtg,ntg,' ',.true.)
144  irec = 0
145  isub = 0
146  itbl = 0
147  DO i=1,ntg
148  IF(tgs(i).EQ.'IREC') irec = i
149  IF(tgs(i).EQ.'ISUB') isub = i
150  IF(tgs(i).EQ.'ITBL') itbl = i
151  ENDDO
152 
153 C READ A MESSAGE AND PARSE A STRING
154 C ---------------------------------
155 
156  CALL status(munit,lun,il,im)
157 
158  DO imsg=1,msgp(0)
159  CALL rdmemm(imsg,subset,jdate,mret)
160  IF(mret.LT.0) goto 900
161 
162  CALL string(str,lun,i1,0)
163  IF(irec.GT.0) nods(irec) = 0
164  IF(isub.GT.0) nods(isub) = 0
165  IF(itbl.GT.0) nods(itbl) = 0
166 
167 C PROCESS ALL THE SUBSETS IN THE MEMORY MESSAGE
168 C ---------------------------------------------
169 
170  DO WHILE (nsub(lun).LT.msub(lun))
171  IF(iret+1.GT.i2) goto 99
172  iret = iret+1
173 
174  DO i=1,nnod
175  nods(i) = abs(nods(i))
176  ENDDO
177 
178  CALL usrtpl(lun,1,1)
179  mbit = mbyt(lun)*8+16
180  nbit = 0
181  n = 1
182 
183 20 IF(n+1.LE.nval(lun)) THEN
184  n = n+1
185  node = inv(n,lun)
186  mbit = mbit+nbit
187  nbit = ibt(node)
188  IF(itp(node).EQ.1) THEN
189  CALL upbb(ival,nbit,mbit,mbay(1,lun))
190  CALL usrtpl(lun,n,ival)
191  ENDIF
192  DO i=1,nnod
193  IF(nods(i).EQ.node) THEN
194  IF(itp(node).EQ.1) THEN
195  CALL upbb(ival,nbit,mbit,mbay(1,lun))
196  tab(i,iret) = ival
197  ELSEIF(itp(node).EQ.2) THEN
198  CALL upbb(ival,nbit,mbit,mbay(1,lun))
199  IF(ival.LT.mps(node)) tab(i,iret) = ups(ival,node)
200  ELSEIF(itp(node).EQ.3) THEN
201  cval = ' '
202  kbit = mbit
203  CALL upc(cval,nbit/8,mbay(1,lun),kbit,.true.)
204  tab(i,iret) = rval
205  ENDIF
206  nods(i) = -nods(i)
207  goto 20
208  ENDIF
209  ENDDO
210  DO i=1,nnod
211  IF(nods(i).GT.0) goto 20
212  ENDDO
213  ENDIF
214 
215 C UPDATE THE SUBSET POINTERS BEFORE NEXT READ
216 C -------------------------------------------
217 
218  ibit = mbyt(lun)*8
219  CALL upb(nbyt,16,mbay(1,lun),ibit)
220  mbyt(lun) = mbyt(lun) + nbyt
221  nsub(lun) = nsub(lun) + 1
222  IF(irec.GT.0) tab(irec,iret) = nmsg(lun)
223  IF(isub.GT.0) tab(isub,iret) = nsub(lun)
224  IF(itbl.GT.0) tab(itbl,iret) = ldxts
225  ENDDO
226 
227  ENDDO
228 
229  goto 200
230 
231 C EMERGENCY ROOM TREATMENT FOR ARRAY OVERFLOW
232 C -------------------------------------------
233 
234 99 CALL rdmemm(0,subset,jdate,mret)
235  nrep = 0
236  DO imsg=1,msgp(0)
237  CALL rdmemm(imsg,subset,jdate,mret)
238  IF(mret.LT.0) goto 900
239  nrep = nrep+nmsub(munit)
240  ENDDO
241  IF(iprt.GE.0) THEN
242  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
243  WRITE ( unit=errstr, fmt='(A,A,I8,A,A)' )
244  . 'BUFRLIB: UFBTAM - THE NO. OF DATA SUBSETS IN MEMORY ',
245  . .GT.'IS LIMIT OF ', i2, ' IN THE 3RD ARG. (INPUT) - ',
246  . 'INCOMPLETE READ'
247  CALL errwrt(errstr)
248  WRITE ( unit=errstr, fmt='(A,I8,A,I8,A)' )
249  . '>>>UFBTAM STORED ', iret, ' REPORTS OUT OF ', nrep, '<<<'
250  CALL errwrt(errstr)
251  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
252  CALL errwrt(' ')
253  ENDIF
254 
255 C RESET THE MEMORY FILE
256 C ---------------------
257 
258 200 CALL rdmemm(0,subset,jdate,mret)
259 
260 C EXITS
261 C -----
262 
263 100 RETURN
264 900 WRITE(bort_str,'("BUFRLIB: UFBTAM - HIT END-OF-FILE READING '//
265  . 'MESSAGE NUMBER",I5," IN INTERNAL MEMORY")') imsg
266  CALL bort(bort_str)
267  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
subroutine upb(NVAL, NBITS, IBAY, IBIT)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY...
Definition: upb.f:49
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
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
This module contains array and variable declarations used to store the contents of one or more BUFR f...
Definition: moda_msgmem.F:14
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 rdmemm(IMSG, SUBSET, JDATE, IRET)
This subroutine reads a specified BUFR message from internal arrays in memory, so that it is now in s...
Definition: rdmemm.f:49
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 ufbtam(TAB, I1, I2, IRET, STR)
THIS SUBROUTINE READS SPECIFIED VALUES INTO INTERNAL ARRAYS FROM ALL DATA SUBSETS IN BUFR MESSAGES ST...
Definition: ufbtam.f:105
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:55
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:41
function nmsub(LUNIT)
This function returns the total number of data subsets available within the BUFR message that was mos...
Definition: nmsub.f:29
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
This module contains array and variable declarations used to store BUFR messages internally for multi...
Definition: moda_bitbuf.F:10
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