NCEPLIBS-bufr 11.7.1
rcstpl.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE STORES THE SUBSET TEMPLATE INTO INTERNAL
5C> SUBSET ARRAYS IN MODULES USRINT AND USRBIT. THIS IS IN
6C> PREPARATION FOR THE ACTUAL UNPACKING OF THE SUBSET IN BUFR ARCHIVE
7C> LIBRARY SUBROUTINE RDTREE.
8C>
9C> PROGRAM HISTORY LOG:
10C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
11C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
12C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
13C> ROUTINE "BORT"
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); MAXRCR (MAXIMUM
28C> NUMBER OF RECURSION LEVELS) INCREASED FROM
29C> 50 TO 100 (WAS IN VERIFICATION VERSION);
30C> UNIFIED/PORTABLE FOR WRF; ADDED
31C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
32C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
33C> TERMINATES ABNORMALLY; COMMENTED OUT
34C> HARDWIRE OF VTMP TO "BMISS" (10E10) WHEN IT
35C> IS > 10E9 (CAUSED PROBLEMS ON SOME FOREIGN
36C> MACHINES)
37C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
38C> 20,000 TO 50,000 BYTES
39C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
40C> 2016-11-09 J. ATOR -- ADDED IRET ARGUMENT AND CHECK FOR POSSIBLY
41C> CORRUPT SUBSETS
42C>
43C> USAGE: CALL RCSTPL (LUN,IRET)
44C> INPUT ARGUMENT LIST:
45C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
46C>
47C> OUTPUT ARGUMENT LIST:
48C> IRET - INTEGER: RETURN CODE:
49C> 0 = NORMAL RETURN
50C> -1 = AN ERROR OCCURRED, POSSIBLY DUE TO A
51C> CORRUPT SUBSET IN THE INPUT MESSAGE
52C>
53C> REMARKS:
54C> THIS ROUTINE CALLS: BORT IGETRFEL STRBTM UPBB
55C> THIS ROUTINE IS CALLED BY: RDTREE
56C> Normally not called by any application
57C> programs.
58C>
59 SUBROUTINE rcstpl(LUN,IRET)
60
61 USE modv_bmiss
62 USE modv_maxjl
63 USE modv_maxss
64
65 USE moda_usrint
66 USE moda_usrbit
67 USE moda_msgcwd
68 USE moda_bitbuf
69 USE moda_tables
70 USE moda_usrtmp
71
72 COMMON /quiet / iprt
73
74 CHARACTER*128 BORT_STR
75 dimension nbmp(2,maxrcr),newn(2,maxrcr)
76 dimension knx(maxrcr)
77
78C-----------------------------------------------------------------------
79C-----------------------------------------------------------------------
80
81 iret = 0
82
83C SET THE INITIAL VALUES FOR THE TEMPLATE
84C ---------------------------------------
85
86c .... Positional index of Table A mnem.
87 inv(1,lun) = inode(lun)
88 val(1,lun) = 0
89 nbmp(1,1) = 1
90 nbmp(2,1) = 1
91 nodi = inode(lun)
92 node = inode(lun)
93 mbmp = 1
94 knvn = 1
95 nr = 0
96
97 DO i=1,maxrcr
98 knx(i) = 0
99 ENDDO
100
101C SET UP THE PARAMETERS FOR A LEVEL OF RECURSION
102C ----------------------------------------------
103
10410 CONTINUE
105
106 nr = nr+1
107 IF(nr.GT.maxrcr) GOTO 900
108 nbmp(1,nr) = 1
109 nbmp(2,nr) = mbmp
110
111 n1 = iseq(node,1)
112 n2 = iseq(node,2)
113 IF(n1.EQ.0 ) GOTO 901
114 IF(n2-n1+1.GT.maxjl) THEN
115 IF(iprt.GE.0) THEN
116 CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
117 CALL errwrt('BUFRLIB: RCSTPL - MAXJL OVERFLOW; SUBSET SKIPPED')
118 CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
119 ENDIF
120 iret = -1
121 RETURN
122 ENDIF
123 newn(1,nr) = 1
124 newn(2,nr) = n2-n1+1
125
126 DO n=1,newn(2,nr)
127 nn = jseq(n+n1-1)
128 iutmp(n,nr) = nn
129 vutmp(n,nr) = vali(nn)
130 ENDDO
131
132C STORE NODES AT SOME RECURSION LEVEL
133C -----------------------------------
134
13520 DO i=nbmp(1,nr),nbmp(2,nr)
136 IF(knx(nr).EQ.0000) knx(nr) = knvn
137 IF(i.GT.nbmp(1,nr)) newn(1,nr) = 1
138 DO j=newn(1,nr),newn(2,nr)
139 IF(knvn+1.GT.maxss) THEN
140 IF(iprt.GE.0) THEN
141 CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
142 CALL errwrt('BUFRLIB: RCSTPL - MAXSS OVERFLOW; SUBSET SKIPPED')
143 CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
144 ENDIF
145 iret = -1
146 RETURN
147 ENDIF
148 knvn = knvn+1
149 node = iutmp(j,nr)
150c .... INV is positional index in internal jump/link table for packed
151c subset element KNVN in MBAY
152 inv(knvn,lun) = node
153c .... MBIT is the bit in MBAY pointing to where the packed subset
154c element KNVN begins
155 mbit(knvn) = mbit(knvn-1)+nbit(knvn-1)
156c .... NBIT is the number of bits in MBAY occupied by packed subset
157c element KNVN
158 nrfelm(knvn,lun) = igetrfel(knvn,lun)
159 nbit(knvn) = ibt(node)
160 IF(tag(node)(1:5).EQ.'DPRI ') THEN
161c .... This is a bitmap entry, so get and store the corresponding value
162 CALL upbb(idpri,nbit(knvn),mbit(knvn),mbay(1,lun))
163 IF(idpri.EQ.0) THEN
164 val(knvn,lun) = 0.0
165 ELSE
166 val(knvn,lun) = bmiss
167 ENDIF
168 CALL strbtm(knvn,lun)
169 ENDIF
170c .... Actual unpacked subset values (VAL) are initialized here
171c (numbers as BMISS)
172 val(knvn,lun) = vutmp(j,nr)
173 IF(itp(node).EQ.1) THEN
174 CALL upbb(mbmp,nbit(knvn),mbit(knvn),mbay(1,lun))
175 newn(1,nr) = j+1
176 nbmp(1,nr) = i
177 GOTO 10
178 ENDIF
179 ENDDO
180 new = knvn-knx(nr)
181 val(knx(nr)+1,lun) = val(knx(nr)+1,lun) + new
182 knx(nr) = 0
183 ENDDO
184
185C CONTINUE AT ONE RECURSION LEVEL BACK
186C ------------------------------------
187
188 IF(nr-1.NE.0) THEN
189 nr = nr-1
190 GOTO 20
191 ENDIF
192
193C FINALLY STORE THE LENGTH OF (NUMBER OF ELEMENTS IN) SUBSET TEMPLATE
194C -------------------------------------------------------------------
195
196 nval(lun) = knvn
197
198C EXITS
199C -----
200
201 RETURN
202900 WRITE(bort_str,'("BUFRLIB: RCSTPL - THE NUMBER OF RECURSION '//
203 . 'LEVELS EXCEEDS THE LIMIT (",I3,")")') maxrcr
204 CALL bort(bort_str)
205901 WRITE(bort_str,'("BUFRLIB: RCSTPL - UNSET EXPANSION SEGMENT ",A)')
206 . tag(nodi)
207 CALL bort(bort_str)
208 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
integer function igetrfel(N, LUN)
THIS FUNCTION CHECKS WHETHER THE INPUT ELEMENT REFERS TO A PREVIOUS ELEMENT WITHIN THE SAME SUBSET VI...
Definition: igetrfel.f:36
This module contains array and variable declarations used to store BUFR messages internally for multi...
Definition: moda_bitbuf.F:10
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
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
Definition: moda_tables.F:132
real *8, dimension(:), allocatable vali
Initialized data values corresponding to typ:
Definition: moda_tables.F:142
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
This module declares and initializes the MAXJL variable.
Definition: modv_MAXJL.f:13
integer maxjl
Maximum number of entries in the internal jump/link table.
Definition: modv_MAXJL.f:18
This module declares and initializes the MAXSS variable.
Definition: modv_MAXSS.f:13
integer maxss
Maximum number of data values that can be read from or written into a data subset by the BUFRLIB soft...
Definition: modv_MAXSS.f:19
subroutine rcstpl(LUN, IRET)
THIS SUBROUTINE STORES THE SUBSET TEMPLATE INTO INTERNAL SUBSET ARRAYS IN MODULES USRINT AND USRBIT.
Definition: rcstpl.f:60
subroutine strbtm(N, LUN)
THIS SUBROUTINE STORES INTERNAL INFORMATION IN MODULE BITMAPS IF THE INPUT ELEMENT IS PART OF A BITMA...
Definition: strbtm.f:22
subroutine upbb(NVAL, NBITS, IBIT, IBAY)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY,...
Definition: upbb.f:43