NCEPLIBS-bufr  12.0.1
rcstpl.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Store the subset template into internal arrays.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> This subroutine initializes space in internal subset array space (inv
7 C> and val) in modules @ref moda_usrint and @ref moda_usrbit, according
8 C> to the subset definition from subroutine maksetab(). This is in
9 C> preparation for the actual unpacking of the subset in rdtree().
10 C>
11 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
12 C> @param[out] IRET - integer: return code:.
13 C> - 0 Normal return.
14 C> - -1 An error occurred, possibly due to a corrupt subset in the input message.
15 C>
16 C> @author Woollen @date 1994-01-06
17  SUBROUTINE rcstpl(LUN,IRET)
18 
19  USE modv_bmiss
20  USE modv_maxjl
21  USE modv_maxss
22 
23  USE moda_usrint
24  USE moda_usrbit
25  USE moda_msgcwd
26  USE moda_bitbuf
27  USE moda_tables
28  USE moda_usrtmp
29 
30  COMMON /quiet / iprt
31 
32  CHARACTER*128 BORT_STR
33  dimension nbmp(2,maxrcr),newn(2,maxrcr)
34  dimension knx(maxrcr)
35 
36 C-----------------------------------------------------------------------
37 C-----------------------------------------------------------------------
38 
39  iret = 0
40 
41 C SET THE INITIAL VALUES FOR THE TEMPLATE
42 C ---------------------------------------
43 
44 c .... Positional index of Table A mnem.
45  inv(1,lun) = inode(lun)
46  val(1,lun) = 0
47  nbmp(1,1) = 1
48  nbmp(2,1) = 1
49  nodi = inode(lun)
50  node = inode(lun)
51  mbmp = 1
52  knvn = 1
53  nr = 0
54 
55  DO i=1,maxrcr
56  knx(i) = 0
57  ENDDO
58 
59 C SET UP THE PARAMETERS FOR A LEVEL OF RECURSION
60 C ----------------------------------------------
61 
62 10 CONTINUE
63 
64  nr = nr+1
65  IF(nr.GT.maxrcr) GOTO 900
66  nbmp(1,nr) = 1
67  nbmp(2,nr) = mbmp
68 
69  n1 = iseq(node,1)
70  n2 = iseq(node,2)
71  IF(n1.EQ.0 ) GOTO 901
72  IF(n2-n1+1.GT.maxjl) THEN
73  IF(iprt.GE.0) THEN
74  CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
75  CALL errwrt('BUFRLIB: RCSTPL - MAXJL OVERFLOW; SUBSET SKIPPED')
76  CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
77  ENDIF
78  iret = -1
79  RETURN
80  ENDIF
81  newn(1,nr) = 1
82  newn(2,nr) = n2-n1+1
83 
84  DO n=1,newn(2,nr)
85  nn = jseq(n+n1-1)
86  iutmp(n,nr) = nn
87  vutmp(n,nr) = vali(nn)
88  ENDDO
89 
90 C STORE NODES AT SOME RECURSION LEVEL
91 C -----------------------------------
92 
93 20 DO i=nbmp(1,nr),nbmp(2,nr)
94  IF(knx(nr).EQ.0000) knx(nr) = knvn
95  IF(i.GT.nbmp(1,nr)) newn(1,nr) = 1
96  DO j=newn(1,nr),newn(2,nr)
97  IF(knvn+1.GT.maxss) THEN
98  IF(iprt.GE.0) THEN
99  CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
100  CALL errwrt('BUFRLIB: RCSTPL - MAXSS OVERFLOW; SUBSET SKIPPED')
101  CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
102  ENDIF
103  iret = -1
104  RETURN
105  ENDIF
106  knvn = knvn+1
107  node = iutmp(j,nr)
108 c .... INV is positional index in internal jump/link table for packed
109 c subset element KNVN in MBAY
110  inv(knvn,lun) = node
111 c .... MBIT is the bit in MBAY pointing to where the packed subset
112 c element KNVN begins
113  mbit(knvn) = mbit(knvn-1)+nbit(knvn-1)
114 c .... NBIT is the number of bits in MBAY occupied by packed subset
115 c element KNVN
116  nrfelm(knvn,lun) = igetrfel(knvn,lun)
117  nbit(knvn) = ibt(node)
118  IF(tag(node)(1:5).EQ.'DPRI ') THEN
119 c .... This is a bitmap entry, so get and store the corresponding value
120  CALL upbb(idpri,nbit(knvn),mbit(knvn),mbay(1,lun))
121  IF(idpri.EQ.0) THEN
122  val(knvn,lun) = 0.0
123  ELSE
124  val(knvn,lun) = bmiss
125  ENDIF
126  CALL strbtm(knvn,lun)
127  ENDIF
128 c .... Actual unpacked subset values (VAL) are initialized here
129 c (numbers as BMISS)
130  val(knvn,lun) = vutmp(j,nr)
131  IF(itp(node).EQ.1) THEN
132  CALL upbb(mbmp,nbit(knvn),mbit(knvn),mbay(1,lun))
133  newn(1,nr) = j+1
134  nbmp(1,nr) = i
135  GOTO 10
136  ENDIF
137  ENDDO
138  new = knvn-knx(nr)
139  val(knx(nr)+1,lun) = val(knx(nr)+1,lun) + new
140  knx(nr) = 0
141  ENDDO
142 
143 C CONTINUE AT ONE RECURSION LEVEL BACK
144 C ------------------------------------
145 
146  IF(nr-1.NE.0) THEN
147  nr = nr-1
148  GOTO 20
149  ENDIF
150 
151 C FINALLY STORE THE LENGTH OF (NUMBER OF ELEMENTS IN) SUBSET TEMPLATE
152 C -------------------------------------------------------------------
153 
154  nval(lun) = knvn
155 
156 C EXITS
157 C -----
158 
159  RETURN
160 900 WRITE(bort_str,'("BUFRLIB: RCSTPL - THE NUMBER OF RECURSION '//
161  . 'LEVELS EXCEEDS THE LIMIT (",I3,")")') maxrcr
162  CALL bort(bort_str)
163 901 WRITE(bort_str,'("BUFRLIB: RCSTPL - UNSET EXPANSION SEGMENT ",A)')
164  . tag(nodi)
165  CALL bort(bort_str)
166  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
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:23
This module contains array and variable declarations used to store BUFR messages internally for multi...
integer, dimension(:,:), allocatable mbay
Current BUFR message for each internal I/O stream.
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable jseq
Temporary storage used in expanding sequences.
integer, dimension(:,:), allocatable iseq
Temporary storage used in expanding sequences.
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
real *8, dimension(:), allocatable vali
Initialized data values corresponding to typ:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
integer, dimension(:), allocatable itp
Integer type values corresponding to typ:
This module contains array declarations for internal storage of pointers to BUFR data subset values.
integer, dimension(:), allocatable nbit
Length (in bits) of each packed data value in data subset.
integer, dimension(:), allocatable mbit
Pointer in data subset to first bit of each packed data value.
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:), allocatable nval
Number of data values in BUFR data subset.
real *8, dimension(:,:), allocatable, target val
Data values.
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
integer, dimension(:,:), allocatable nrfelm
Referenced data value, for data values which refer to a previous data value in the BUFR data subset v...
This module contains arrays used in subroutine rcstpl() to store subset segments that are being copie...
integer, dimension(:,:), allocatable iutmp
inv array elements for new sections of a growing subset buffer.
real *8, dimension(:,:), allocatable vutmp
val array elements for new sections of a growing subset buffer.
This module declares and initializes the BMISS variable.
Definition: modules_vars.F90:9
real *8, public bmiss
Current placeholder value to represent "missing" data when reading from or writing to BUFR files; thi...
This module declares and initializes the MAXJL variable.
integer maxjl
Maximum number of entries in the internal jump/link table.
This module declares and initializes the MAXSS variable.
integer maxss
Maximum number of data values that can be read from or written into a data subset by the BUFRLIB soft...
subroutine rcstpl(LUN, IRET)
This subroutine initializes space in internal subset array space (inv and val) in modules moda_usrint...
Definition: rcstpl.f:18
subroutine strbtm(N, LUN)
This subroutine stores internal information in module bitmaps if the input element is part of a bitma...
Definition: strbtm.f:14
subroutine upbb(NVAL, NBITS, IBIT, IBAY)
This subroutine decodes an integer value from within a specified number of bits of an integer array,...
Definition: upbb.f:22