NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
nemtbd.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Get information about a Table D descriptor
3 
4 C> This subroutine returns information about a Table D descriptor
5 C> from the internal DX BUFR tables.
6 C>
7 C> @author J. Woollen
8 C> @date 1994-01-06
9 C>
10 C> @param[in] LUN -- integer: Internal I/O stream index associated
11 C> with DX BUFR tables
12 C> @param[in] ITAB -- integer: Positional index of descriptor within
13 C> internal Table D
14 C> @param[out] NSEQ -- integer: Number of child mnemonics for descriptor
15 C> @param[out] NEMS -- character*8(*): Child mnemonics
16 C> @param[out] IRPS -- integer(*): Array of values corresponding to NEMS
17 C> - 5, if corresponding NEMS value is a Table D
18 C> mnemonic using 1-bit delayed replication
19 C> - 4, if corresponding NEMS value is a Table D
20 C> mnemonic using 8-bit delayed (stack) replication
21 C> - 3, if corresponding NEMS value is a Table D
22 C> mnemonic using 8-bit delayed replication
23 C> - 2, if corresponding NEMS value is a Table D
24 C> mnemonic using 16-bit delayed replication
25 C> - 1, if corresponding NEMS value is a Table D
26 C> mnemonic using regular (non-delayed) replication
27 C> - 0, otherwise
28 C> @param[out] KNTS -- integer(*): Array of values corresponding to NEMS
29 C> - Number of replications, if corresponding NEMS
30 C> value is a Table D mnemonic using regular
31 C> (non-delayed) replication
32 C> - 0, otherwise
33 C>
34 C> @remarks
35 C> - This subroutine does not recursively resolve any child mnemonics
36 C> which may themselves be Table D mnemonics. Instead, this subroutine
37 C> only returns the list of mnemonics which are direct children of the
38 C> descriptor referenced by ITAB. This information should have already
39 C> been stored into internal arrays via previous calls to subroutine
40 C> pktdd().
41 C>
42 C> <b>Program history log:</b>
43 C> | Date | Programmer | Comments |
44 C> | -----|------------|----------|
45 C> | 1994-01-06 | J. Woollen | Original author |
46 C> | 1995-06-28 | J. Woollen | Increased the size of internal BUFR table arrays in order to handle bigger files |
47 C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine "ABORT" with call to new internal routine bort() |
48 C> | 1999-11-18 | J. Woollen | The number of BUFR files which can be opened at one time increased from 10 to 32 |
49 C> | 2000-09-19 | J. Woollen | Handle child mnemonics which are Table C operators |
50 C> | 2003-11-04 | S. Bender | Added remarks/bufrlib routine interdependencies |
51 C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added documentation; outputs more complete diagnostic info when routine terminates abnormally |
52 C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
53 C>
54  SUBROUTINE nemtbd(LUN,ITAB,NSEQ,NEMS,IRPS,KNTS)
55 
56  USE modv_maxcd
57  USE moda_tababd
58 
59  CHARACTER*128 bort_str
60  CHARACTER*8 nemo,nems,nemt,nemf
61  CHARACTER*6 adn30,clemon
62  CHARACTER*1 tab
63  dimension nems(*),irps(*),knts(*)
64  LOGICAL rep
65 
66 C-----------------------------------------------------------------------
67 C-----------------------------------------------------------------------
68 
69  IF(itab.LE.0 .OR. itab.GT.ntbd(lun)) goto 900
70 
71  rep = .false.
72 
73 C CLEAR THE RETURN VALUES
74 C -----------------------
75 
76  nseq = 0
77 
78  DO i=1,maxcd
79  nems(i) = ' '
80  irps(i) = 0
81  knts(i) = 0
82  ENDDO
83 
84 C PARSE THE TABLE D ENTRY
85 C -----------------------
86 
87  nemo = tabd(itab,lun)(7:14)
88  idsc = idnd(itab,lun)
89  CALL uptdd(itab,lun,0,ndsc)
90 
91  IF(idsc.LT.ifxy('300000')) goto 901
92  IF(idsc.GT.ifxy('363255')) goto 901
93 cccc IF(NDSC.LE.0 ) GOTO 902
94 
95 C Loop through each child mnemonic.
96 
97 c .... DK: What happens here if NDSC=0 ?
98  DO j=1,ndsc
99  IF(nseq+1.GT.maxcd) goto 903
100  CALL uptdd(itab,lun,j,idsc)
101 c .... get NEMT from IDSC
102  CALL numtab(lun,idsc,nemt,tab,iret)
103  IF(tab.EQ.'R') THEN
104  IF(rep) goto 904
105  rep = .true.
106  IF(iret.LT.0) THEN
107 
108 C F=1 regular (i.e. non-delayed) replication.
109 
110  irps(nseq+1) = 1
111  knts(nseq+1) = abs(iret)
112  ELSEIF(iret.GT.0) THEN
113 
114 C Delayed replication.
115 
116  irps(nseq+1) = iret
117  ENDIF
118  ELSEIF(tab.EQ.'F') THEN
119 
120 C Replication factor.
121 
122  IF(.NOT.rep) goto 904
123  irps(nseq+1) = iret
124  rep = .false.
125  ELSEIF(tab.EQ.'D'.OR.tab.EQ.'C') THEN
126  rep = .false.
127  nseq = nseq+1
128  nems(nseq) = nemt
129  ELSEIF(tab.EQ.'B') THEN
130  rep = .false.
131  nseq = nseq+1
132  IF((nemt(1:1).EQ.'.').AND.(j.LT.ndsc)) THEN
133 
134 C This is a "following value" mnemonic.
135 
136  CALL uptdd(itab,lun,j+1,idsc)
137 c .... get NEMF from IDSC
138  CALL numtab(lun,idsc,nemf,tab,iret)
139  CALL rsvfvm(nemt,nemf)
140  IF(tab.NE.'B') goto 906
141  ENDIF
142  nems(nseq) = nemt
143  ELSE
144  goto 905
145  ENDIF
146  ENDDO
147 
148 C EXITS
149 C -----
150 
151  RETURN
152 900 WRITE(bort_str,'("BUFRLIB: NEMTBD - ITAB (",I7,") NOT FOUND IN '//
153  . 'TABLE D")') itab
154  CALL bort(bort_str)
155 901 WRITE(bort_str,'("BUFRLIB: NEMTBD - INTEGER REPRESENTATION OF '//
156  . 'DESCRIPTOR FOR TABLE D MNEMONIC ",A," (",I7,") IS OUTSIDE '//
157  . 'RANGE 0-65535 (65535 -> 3-63-255)")') nemo,idsc
158  CALL bort(bort_str)
159 902 WRITE(bort_str,'("BUFRLIB: NEMTBD - TABLE D MNEMONIC ",A," IS A'//
160  . ' ZERO LENGTH SEQUENCE")') nemo
161  CALL bort(bort_str)
162 903 WRITE(bort_str,'("BUFRLIB: NEMTBD - THERE ARE MORE THAN '//
163  . '(",I4,") DESCRIPTORS (THE LIMIT) IN TABLE D SEQUENCE '//
164  . 'MNEMONIC ",A)') maxcd, nemo
165  CALL bort(bort_str)
166 904 WRITE(bort_str,'("BUFRLIB: NEMTBD - REPLICATOR IS OUT OF ORDER '//
167  . 'IN TABLE D SEQUENCE MNEMONIC ",A)') nemo
168  CALL bort(bort_str)
169 905 clemon = adn30(idsc,6)
170  WRITE(bort_str,'("BUFRLIB: NEMTBD - UNRECOGNIZED DESCRIPTOR '//
171  . '",A," IN TABLE D SEQUENCE MNEMONIC ",A)') clemon,nemo
172  CALL bort(bort_str)
173 906 WRITE(bort_str,'("BUFRLIB: NEMTBD - A ''FOLLOWING VALUE'' '//
174  . 'MNEMONIC (",A,") IS FROM TABLE ",A,", IT MUST BE FROM TABLE B'//
175  . '")') nemf,tab
176  CALL bort(bort_str)
177  END
subroutine numtab(LUN, IDN, NEMO, TAB, IRET)
This subroutine returns information about a descriptor from the internal DX BUFR tables, based on the bit-wise representation of the FXY value associated with that descriptor.
Definition: numtab.f:58
subroutine rsvfvm(NEM1, NEM2)
THIS SUBROUTINE STEPS THROUGH THE &quot;FOLLOWING VALUE&quot; MNEMONIC NEM1 AND, FOR EACH &quot;.&quot; CHARACTER ENCOUNTERED (EXCEPT FOR THE INITIAL ONE), OVERWRITES IT WITH THE NEXT CORRESPONDING CHARACTER FROM NEM2 (SEE REMARKS).
Definition: rsvfvm.f:40
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
Definition: moda_tababd.F:10
character *(*) function adn30(IDN, L30)
This function converts an FXY value from its bit-wise (integer) representation to its 5 or 6 characte...
Definition: adn30.f:28
function ifxy(ADSC)
This function converts an FXY value from its 6 character representation to its bit-wise (integer) rep...
Definition: ifxy.f:42
This module declares and initializes the MAXCD variable.
Definition: modv_MAXCD.f90:13
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
subroutine uptdd(ID, LUN, IENT, IRET)
THIS SUBROUTINE RETURNS THE BIT-WISE REPRESENTATION OF THE FXY VALUE CORRESPONDING TO...
Definition: uptdd.f:60
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:54