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