NCEPLIBS-bufr 11.7.1
ufbget.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE UNPACKS AND RETURNS THE VALUES FOR ONE-
5C> DIMENSIONAL DESCRIPTORS IN THE INPUT STRING WITHOUT ADVANCING THE
6C> SUBSET POINTER.
7C>
8C> PROGRAM HISTORY LOG:
9C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
10C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
11C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
12C> ROUTINE "BORT"; IMPROVED MACHINE
13C> PORTABILITY
14C> 1998-10-27 J. WOOLLEN -- MODIFIED TO CORRECT PROBLEMS CAUSED BY IN-
15C> LINING CODE WITH FPP DIRECTIVES
16C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
17C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
18C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
19C> BUFR FILES UNDER THE MPI)
20C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
21C> 10,000 TO 20,000 BYTES
22C> 2002-05-14 J. WOOLLEN -- REMOVED OLD CRAY COMPILER DIRECTIVES
23C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
24C> INTERDEPENDENCIES
25C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
26C> INCREASED FROM 15000 TO 16000 (WAS IN
27C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
28C> WRF; ADDED DOCUMENTATION (INCLUDING
29C> HISTORY); OUTPUTS MORE COMPLETE DIAGNOSTIC
30C> INFO WHEN ROUTINE TERMINATES ABNORMALLY
31C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
32C> 20,000 TO 50,000 BYTES
33C> 2012-03-02 J. ATOR -- USE FUNCTION UPS
34C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
35C> 2022-05-06 J. WOOLLEN -- REPLACE UPBB WITH UPB8 FOR 8BYTE INTEGERS
36C>
37C> USAGE: CALL UFBGET (LUNIT, TAB, I1, IRET, STR)
38C> INPUT ARGUMENT LIST:
39C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
40C> I1 - INTEGER: LENGTH OF TAB
41C> STR - CHARACTER*(*): STRING OF BLANK-SEPARATED TABLE B
42C> MNEMONICS IN ONE-TO-ONE CORRESPONDENCE WITH THE WORDS
43C> IN THE ARRAY TAB
44C> - THERE ARE THREE "GENERIC" MNEMONICS NOT RELATED
45C> TO TABLE B, THESE RETURN THE FOLLOWING
46C> INFORMATION IN CORRESPONDING TAB LOCATION:
47C> 'NUL' WHICH ALWAYS RETURNS BMISS ("MISSING")
48C> 'IREC' WHICH ALWAYS RETURNS THE CURRENT BUFR
49C> MESSAGE (RECORD) NUMBER IN WHICH THIS
50C> SUBSET RESIDES
51C> 'ISUB' WHICH ALWAYS RETURNS THE CURRENT SUBSET
52C> NUMBER OF THIS SUBSET WITHIN THE BUFR
53C> MESSAGE (RECORD) NUMBER 'IREC'
54C>
55C> OUTPUT ARGUMENT LIST:
56C> TAB - REAL*8: (I1) STARTING ADDRESS OF DATA VALUES READ FROM
57C> DATA SUBSET
58C> IRET - INTEGER: RETURN CODE:
59C> 0 = normal return
60C> -1 = there are no more subsets in the BUFR
61C> message
62C>
63C> REMARKS:
64C> THIS ROUTINE CALLS: BORT INVWIN STATUS STRING
65C> UPB8 UPC UPS USRTPL
66C> THIS ROUTINE IS CALLED BY: None
67C> Normally called only by application
68C> programs.
69C>
70 SUBROUTINE ufbget(LUNIT,TAB,I1,IRET,STR)
71
72 USE modv_bmiss
73 USE moda_usrint
74 USE moda_usrbit
75 USE moda_msgcwd
76 USE moda_bitbuf
77 USE moda_tables
78
79 COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
80
81 CHARACTER*(*) STR
82 CHARACTER*8 CVAL
83 equivalence(cval,rval)
84 integer*8 ival
85 real*8 rval,tab(i1),ups
86
87C-----------------------------------------------------------------------
88C-----------------------------------------------------------------------
89
90 iret = 0
91
92 DO i=1,i1
93 tab(i) = bmiss
94 ENDDO
95
96C MAKE SURE A FILE/MESSAGE IS OPEN FOR INPUT
97C ------------------------------------------
98
99 CALL status(lunit,lun,il,im)
100 IF(il.EQ.0) GOTO 900
101 IF(il.GT.0) GOTO 901
102 IF(im.EQ.0) GOTO 902
103
104C SEE IF THERE IS ANOTHER SUBSET IN THE MESSAGE
105C ---------------------------------------------
106
107 IF(nsub(lun).EQ.msub(lun)) THEN
108 iret = -1
109 GOTO 100
110 ENDIF
111
112C PARSE THE STRING
113C ----------------
114
115 CALL string(str,lun,i1,0)
116
117C EXPAND THE TEMPLATE FOR THIS SUBSET AS LITTLE AS POSSIBLE
118C ---------------------------------------------------------
119
120 n = 1
121 nbit(n) = 0
122 mbit(n) = mbyt(lun)*8 + 16
123 CALL usrtpl(lun,n,n)
124
12510 DO n=n+1,nval(lun)
126 node = inv(n,lun)
127 nbit(n) = ibt(node)
128 mbit(n) = mbit(n-1)+nbit(n-1)
129 IF(node.EQ.nods(nnod)) THEN
130 nval(lun) = n
131 GOTO 20
132 ELSEIF(itp(node).EQ.1) THEN
133 CALL upb8(ival,nbit(n),mbit(n),mbay(1,lun))
134 nbmp=ival; CALL usrtpl(lun,n,nbmp)
135 GOTO 10
136 ENDIF
137 ENDDO
13820 CONTINUE
139
140C UNPACK ONLY THE NODES FOUND IN THE STRING
141C -----------------------------------------
142
143 DO i=1,nnod
144 node = nods(i)
145 invn = invwin(node,lun,1,nval(lun))
146 IF(invn.GT.0) THEN
147 CALL upb8(ival,nbit(invn),mbit(invn),mbay(1,lun))
148 IF(itp(node).EQ.1) THEN
149 tab(i) = ival
150 ELSEIF(itp(node).EQ.2) THEN
151 IF(ival.LT.2_8**(ibt(node))-1) tab(i) = ups(ival,node)
152 ELSEIF(itp(node).EQ.3) THEN
153 cval = ' '
154 kbit = mbit(invn)
155 CALL upc(cval,nbit(invn)/8,mbay(1,lun),kbit,.true.)
156 tab(i) = rval
157 ENDIF
158 ELSE
159 tab(i) = bmiss
160 ENDIF
161 ENDDO
162
163C EXITS
164C -----
165
166100 RETURN
167900 CALL bort('BUFRLIB: UFBGET - INPUT BUFR FILE IS CLOSED, IT MUST'//
168 . ' BE OPEN FOR INPUT')
169901 CALL bort('BUFRLIB: UFBGET - INPUT BUFR FILE IS OPEN FOR OUTPUT'//
170 . ', IT MUST BE OPEN FOR INPUT')
171902 CALL bort('BUFRLIB: UFBGET - A MESSAGE MUST BE OPEN IN INPUT '//
172 . 'BUFR FILE, NONE ARE')
173 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
function invwin(NODE, LUN, INV1, INV2)
THIS FUNCTION LOOKS FOR A SPECIFIED NODE WITHIN THE PORTION OF THE CURRENT SUBSET BUFFER BOUNDED BY T...
Definition: invwin.f:49
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 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
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 ufbget(LUNIT, TAB, I1, IRET, STR)
THIS SUBROUTINE UNPACKS AND RETURNS THE VALUES FOR ONE- DIMENSIONAL DESCRIPTORS IN THE INPUT STRING W...
Definition: ufbget.f:71
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 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