NCEPLIBS-bufr  12.0.0
tabsub.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Store an entry for a Table A mnemonic within the internal jump/link table.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> This subroutine builds the entire jump/link tree
7 C> (including recursively resolving all "child" mnemonics) for a Table A
8 C> mnemonic within the internal jump/link table.
9 C>
10 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
11 C> @param[in] NEMO - character*8: Table A mnemonic.
12 C>
13 C> @author Woollen @date 1994-01-06
14  SUBROUTINE tabsub(LUN,NEMO)
15 
16  USE modv_mxtamc
17  USE modv_mxtco
18 
19  USE moda_tables
20  USE moda_nmikrp
21  USE moda_nrv203
22  USE moda_bitmaps
23 
24  COMMON /tabccc/ icdw,icsc,icrv,incw
25 
26  CHARACTER*128 BORT_STR
27  CHARACTER*8 NEMO,NEMS
28  CHARACTER*1 TAB
29  dimension drop(10),jmp0(10),nodl(10),ntag(10,2)
30  LOGICAL DROP,LTAMC
31 
32  DATA maxlim /10/
33 
34 C-----------------------------------------------------------------------
35 C-----------------------------------------------------------------------
36 
37 C CHECK THE MNEMONIC
38 C ------------------
39 
40 C Note that Table A mnemonics, in addition to being stored within
41 C internal BUFR Table A array TABA(*,LUN), are also stored as
42 C Table D mnemonics within internal BUFR Table D array TABD(*,LUN).
43 C Thus, the following test is valid.
44 
45  CALL nemtab(lun,nemo,idn,tab,itab)
46  IF(tab.NE.'D') GOTO 900
47 
48 C STORE A SUBSET NODE AND JUMP/LINK THE TREE
49 C ------------------------------------------
50 
51  CALL inctab(nemo,'SUB',node)
52  jump(node) = node+1
53  jmpb(node) = 0
54  link(node) = 0
55  ibt(node) = 0
56  irf(node) = 0
57  isc(node) = 0
58 
59  CALL nemtbd(lun,itab,nseq,nem(1,1),irp(1,1),krp(1,1))
60  ntag(1,1) = 1
61  ntag(1,2) = nseq
62  jmp0(1) = node
63  nodl(1) = node
64  limb = 1
65 
66  icdw = 0
67  icsc = 0
68  icrv = 1
69  incw = 0
70 
71  ibtnrv = 0
72  ipfnrv = 0
73 
74  IF(ntamc+1.GT.mxtamc) GOTO 913
75  inodtamc(ntamc+1) = node
76  ntco(ntamc+1) = 0
77  ltamc = .false.
78 
79 C THIS LOOP RESOLVES ENTITIES IN A SUBSET BY EMULATING RECURSION
80 C --------------------------------------------------------------
81 
82 1 DO n=ntag(limb,1),ntag(limb,2)
83 
84  ntag(limb,1) = n+1
85  drop(limb) = n.EQ.ntag(limb,2)
86 
87  CALL nemtab(lun,nem(n,limb),idn,tab,itab)
88  nems = nem(n,limb)
89 
90 C SPECIAL TREATMENT FOR CERTAIN OPERATOR DESCRIPTORS (TAB=C)
91 C ----------------------------------------------------------
92 
93  IF(tab.EQ.'C') THEN
94  READ(nems,'(3X,I3)') iyyy
95  IF(itab.EQ.1) THEN
96  IF(iyyy.NE.0) THEN
97  IF(icdw.NE.0) GOTO 907
98  icdw = iyyy-128
99  ELSE
100  icdw = 0
101  ENDIF
102  ELSEIF(itab.EQ.2) THEN
103  IF(iyyy.NE.0) THEN
104  IF(icsc.NE.0) GOTO 908
105  icsc = iyyy-128
106  ELSE
107  icsc = 0
108  ENDIF
109  ELSEIF(itab.EQ.3) THEN
110  IF(iyyy.EQ.0) THEN
111 
112 C Stop applying new reference values to subset nodes.
113 C Instead, revert to the use of standard Table B values.
114 
115  IF(ipfnrv.EQ.0) GOTO 911
116  DO jj=ipfnrv,nnrv
117  ienrv(jj) = ntab
118  ENDDO
119  ipfnrv = 0
120  ELSEIF(iyyy.EQ.255) THEN
121 
122 C End the definition of new reference values.
123 
124  ibtnrv = 0
125  ELSE
126 
127 C Begin the definition of new reference values.
128 
129  IF(ibtnrv.NE.0) GOTO 909
130  ibtnrv = iyyy
131  ENDIF
132  ELSEIF(itab.EQ.7) THEN
133  IF(iyyy.GT.0) THEN
134  IF(icdw.NE.0) GOTO 907
135  IF(icsc.NE.0) GOTO 908
136  icdw = ((10*iyyy)+2)/3
137  icsc = iyyy
138  icrv = 10**iyyy
139  ELSE
140  icsc = 0
141  icdw = 0
142  icrv = 1
143  ENDIF
144  ELSEIF(itab.EQ.8) THEN
145  incw = iyyy
146  ELSEIF((itab.GE.21).AND.(iokoper(nems).EQ.1)) THEN
147 
148 C Save the location of this operator within the
149 C jump/link table, for possible later use.
150 
151  IF(.NOT.ltamc) THEN
152  ltamc = .true.
153  ntamc = ntamc+1
154  END IF
155  IF(ntco(ntamc)+1.GT.mxtco) GOTO 912
156  ntco(ntamc) = ntco(ntamc)+1
157  ctco(ntamc,ntco(ntamc)) = nems(1:6)
159  ENDIF
160  ELSE
161  nodl(limb) = ntab+1
162  irep = irp(n,limb)
163  iknt = krp(n,limb)
164  jum0 = jmp0(limb)
165  CALL tabent(lun,nems,tab,itab,irep,iknt,jum0)
166  ENDIF
167 
168  IF(tab.EQ.'D') THEN
169 
170 C Note here how a new tree "LIMB" is created (and is then
171 C immediately recursively resolved) whenever a Table D mnemonic
172 C contains another Table D mnemonic as one of its children.
173 
174  limb = limb+1
175  IF(limb.GT.maxlim) GOTO 901
176  CALL nemtbd(lun,itab,nseq,nem(1,limb),irp(1,limb),krp(1,limb))
177  ntag(limb,1) = 1
178  ntag(limb,2) = nseq
179  jmp0(limb) = ntab
180  GOTO 1
181  ELSEIF(drop(limb)) THEN
182 2 link(nodl(limb)) = 0
183  limb = limb-1
184  IF(limb.EQ.0 ) THEN
185  IF(icrv.NE.1) GOTO 904
186  IF(icdw.NE.0) GOTO 902
187  IF(icsc.NE.0) GOTO 903
188  IF(incw.NE.0) GOTO 905
189  IF(ibtnrv.NE.0) GOTO 910
190  IF(ipfnrv.NE.0) THEN
191 
192 C One or more new reference values were defined for this
193 C subset, but there was no subsequent 2-03-000 operator,
194 C so set all IENRV(*) values for this subset to point to
195 C the last element of the subset within the jump/link table.
196 C Note that, if there had been a subsequent 2-03-000
197 C operator, then these IENRV(*) values would have already
198 C been properly set above.
199 
200  DO jj=ipfnrv,nnrv
201  ienrv(jj) = ntab
202  ENDDO
203  ENDIF
204  GOTO 100
205  ENDIF
206  IF(drop(limb)) GOTO 2
207  link(nodl(limb)) = ntab+1
208  GOTO 1
209  ELSEIF(tab.NE.'C') THEN
210  link(nodl(limb)) = ntab+1
211  ENDIF
212 
213  ENDDO
214 
215  GOTO 906
216 
217 C EXITS
218 C -----
219 
220 100 RETURN
221 900 WRITE(bort_str,'("BUFRLIB: TABSUB - SUBSET NODE NOT IN TABLE D '//
222  . '(TAB=",A,") FOR INPUT MNEMONIC ",A)') tab,nemo
223  CALL bort(bort_str)
224 901 WRITE(bort_str,'("BUFRLIB: TABSUB - THERE ARE TOO MANY NESTED '//
225  . 'TABLE D SEQUENCES (TREES) WITHIN INPUT MNEMONIC ",A," - THE '//
226  . 'LIMIT IS",I4)') nemo,maxlim
227  CALL bort(bort_str)
228 902 WRITE(bort_str,'("BUFRLIB: TABSUB - A 2-01-YYY OPERATOR WAS '//
229  . 'NOT CANCELLED IN THE TREE BUILT FROM INPUT MNEMONIC ",A)') nemo
230  CALL bort(bort_str)
231 903 WRITE(bort_str,'("BUFRLIB: TABSUB - A 2-02-YYY OPERATOR WAS '//
232  . 'NOT CANCELLED IN THE TREE BUILT FROM INPUT MNEMONIC ",A)') nemo
233  CALL bort(bort_str)
234 904 WRITE(bort_str,'("BUFRLIB: TABSUB - A 2-07-YYY OPERATOR WAS '//
235  . 'NOT CANCELLED IN THE TREE BUILT FROM INPUT MNEMONIC ",A)') nemo
236  CALL bort(bort_str)
237 905 WRITE(bort_str,'("BUFRLIB: TABSUB - A 2-08-YYY OPERATOR WAS '//
238  . 'NOT CANCELLED IN THE TREE BUILT FROM INPUT MNEMONIC ",A)') nemo
239  CALL bort(bort_str)
240 906 WRITE(bort_str,'("BUFRLIB: TABSUB - ENTITIES WERE NOT '//
241  . 'SUCCESSFULLY RESOLVED (BY EMULATING RESURSION) FOR SUBSET '//
242  . 'DEFINED BY TBL A MNEM. ",A)') nemo
243  CALL bort(bort_str)
244 907 WRITE(bort_str,'("BUFRLIB: TABSUB - THERE ARE TWO SIMULTANEOUS '//
245  . 'CHANGE DATA WIDTH OPERATIONS IN THE TREE BUILT FROM INPUT ' //
246  . 'MNEMONIC ",A)') nemo
247  CALL bort(bort_str)
248 908 WRITE(bort_str,'("BUFRLIB: TABSUB - THERE ARE TWO SIMULTANEOUS '//
249  . 'CHANGE DATA SCALE OPERATIONS IN THE TREE BUILT FROM INPUT ' //
250  . 'MNEMONIC ",A)') nemo
251  CALL bort(bort_str)
252 909 WRITE(bort_str,'("BUFRLIB: TABSUB - THERE ARE TWO SIMULTANEOUS '//
253  . 'CHANGE REF VALUE OPERATIONS IN THE TREE BUILT FROM INPUT ' //
254  . 'MNEMONIC ",A)') nemo
255  CALL bort(bort_str)
256 910 WRITE(bort_str,'("BUFRLIB: TABSUB - A 2-03-YYY OPERATOR WAS '//
257  . 'APPLIED WITHOUT ANY SUBSEQUENT 2-03-255 OPERATOR FOR '//
258  . 'INPUT MNEMONIC ",A)') nemo
259  CALL bort(bort_str)
260 911 WRITE(bort_str,'("BUFRLIB: TABSUB - A 2-03-000 OPERATOR WAS '//
261  . 'ENCOUNTERED WITHOUT ANY PRIOR 2-03-YYY OPERATOR FOR '//
262  . 'INPUT MNEMONIC ",A)') nemo
263  CALL bort(bort_str)
264 912 CALL bort('BUFRLIB: TABSUB - MXTCO OVERFLOW')
265 913 CALL bort('BUFRLIB: TABSUB - MXTAMC OVERFLOW')
266  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine inctab(ATAG, ATYP, NODE)
This subroutine returns the next available positional index for writing into the internal jump/link t...
Definition: inctab.f:21
integer function iokoper(NEMO)
This function determines whether a specified mnemonic is a Table C operator supported by the BUFRLIB ...
Definition: iokoper.f:18
This module contains array and variable declarations used to store bitmaps internally within a data s...
integer, dimension(:,:), allocatable inodtco
Entries within jump/link table which contain Table C operators.
integer ntamc
Number of Table A mnemonics in jump/link table (up to a maximum of MXTAMC) which contain at least one...
integer, dimension(:), allocatable inodtamc
Entries within jump/link table which contain Table A mnemonics.
character *6, dimension(:,:), allocatable ctco
Table C operators corresponding to inodtco.
integer, dimension(:), allocatable ntco
Number of Table C operators (with an XX value of 21 or greater) within the data subset definition of ...
This module contains declarations for arrays used by various subroutines to hold information about Ta...
integer, dimension(:,:), allocatable krp
Replication counts corresponding to nem:
integer, dimension(:,:), allocatable irp
Replication indicators corresponding to nem:
character *8, dimension(:,:), allocatable nem
Child mnemonics within Table D sequences.
This module contains array and variable declarations for use with any 2-03-YYY (change reference valu...
integer, dimension(:), allocatable ienrv
End of entry range in jump/link table, within which the corresponding new reference value in nrv will...
integer nnrv
Number of entries in the jump/link table which contain new reference values (up to a maximum of MXNRV...
integer ipfnrv
A number between 1 and nnrv, denoting the first entry within the module arrays which applies to the c...
integer ibtnrv
Number of bits in Section 4 occupied by each new reference value for the current 2-03-YYY operator in...
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
integer, dimension(:), allocatable jmpb
Jump backward indices corresponding to tag and typ:
integer ntab
Number of entries in the jump/link table.
integer, dimension(:), allocatable jump
Jump forward indices corresponding to tag and typ:
integer, dimension(:), allocatable link
Link indices corresponding to tag, typ and jmpb:
This module declares and initializes the MXTAMC variable.
integer mxtamc
Maximum number of Table A mnemonics in the internal jump/link table which contain at least one Table ...
This module declares and initializes the MXTCO variable.
integer mxtco
Maximum number of Table C operators with an XX value of 21 or greater that can appear within the data...
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
Get information about a descriptor, based on the mnemonic.
Definition: nemtab.f:29
subroutine nemtbd(LUN, ITAB, NSEQ, NEMS, IRPS, KNTS)
This subroutine returns information about a Table D descriptor from the internal DX BUFR tables.
Definition: nemtbd.f:44
subroutine tabent(LUN, NEMO, TAB, ITAB, IREP, IKNT, JUM0)
This subroutine builds and stores an entry for a Table B or Table D mnemonic within the internal jump...
Definition: tabent.f:23
subroutine tabsub(LUN, NEMO)
This subroutine builds the entire jump/link tree (including recursively resolving all "child" mnemoni...
Definition: tabsub.f:15