NCEPLIBS-bufr 11.7.1
nemtbd.f
Go to the documentation of this file.
1C> @file
2C> @brief Get information about a Table D descriptor
3
4C> This subroutine returns information about a Table D descriptor
5C> from the internal DX BUFR tables.
6C>
7C> @author J. Woollen
8C> @date 1994-01-06
9C>
10C> @param[in] LUN -- integer: Internal I/O stream index associated
11C> with DX BUFR tables
12C> @param[in] ITAB -- integer: Positional index of descriptor within
13C> internal Table D
14C> @param[out] NSEQ -- integer: Number of child mnemonics for descriptor
15C> @param[out] NEMS -- character*8(*): Child mnemonics
16C> @param[out] IRPS -- integer(*): Array of values corresponding to NEMS
17C> - 5, if corresponding NEMS value is a Table D
18C> mnemonic using 1-bit delayed replication
19C> - 4, if corresponding NEMS value is a Table D
20C> mnemonic using 8-bit delayed (stack) replication
21C> - 3, if corresponding NEMS value is a Table D
22C> mnemonic using 8-bit delayed replication
23C> - 2, if corresponding NEMS value is a Table D
24C> mnemonic using 16-bit delayed replication
25C> - 1, if corresponding NEMS value is a Table D
26C> mnemonic using regular (non-delayed) replication
27C> - 0, otherwise
28C> @param[out] KNTS -- integer(*): Array of values corresponding to NEMS
29C> - Number of replications, if corresponding NEMS
30C> value is a Table D mnemonic using regular
31C> (non-delayed) replication
32C> - 0, otherwise
33C>
34C> @remarks
35C> - This subroutine does not recursively resolve any child mnemonics
36C> which may themselves be Table D mnemonics. Instead, this subroutine
37C> only returns the list of mnemonics which are direct children of the
38C> descriptor referenced by ITAB. This information should have already
39C> been stored into internal arrays via previous calls to subroutine
40C> pktdd().
41C>
42C> <b>Program history log:</b>
43C> | Date | Programmer | Comments |
44C> | -----|------------|----------|
45C> | 1994-01-06 | J. Woollen | Original author |
46C> | 1995-06-28 | J. Woollen | Increased the size of internal BUFR table arrays in order to handle bigger files |
47C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine "ABORT" with call to new internal routine bort() |
48C> | 1999-11-18 | J. Woollen | The number of BUFR files which can be opened at one time increased from 10 to 32 |
49C> | 2000-09-19 | J. Woollen | Handle child mnemonics which are Table C operators |
50C> | 2003-11-04 | S. Bender | Added remarks/bufrlib routine interdependencies |
51C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added documentation; outputs more complete diagnostic info when routine terminates abnormally |
52C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
53C>
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
66C-----------------------------------------------------------------------
67C-----------------------------------------------------------------------
68
69 IF(itab.LE.0 .OR. itab.GT.ntbd(lun)) GOTO 900
70
71 rep = .false.
72
73C CLEAR THE RETURN VALUES
74C -----------------------
75
76 nseq = 0
77
78 DO i=1,maxcd
79 nems(i) = ' '
80 irps(i) = 0
81 knts(i) = 0
82 ENDDO
83
84C PARSE THE TABLE D ENTRY
85C -----------------------
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
93cccc IF(NDSC.LE.0 ) GOTO 902
94
95C Loop through each child mnemonic.
96
97c .... 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)
101c .... 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
108C 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
114C Delayed replication.
115
116 irps(nseq+1) = iret
117 ENDIF
118 ELSEIF(tab.EQ.'F') THEN
119
120C 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
134C This is a "following value" mnemonic.
135
136 CALL uptdd(itab,lun,j+1,idsc)
137c .... 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
148C EXITS
149C -----
150
151 RETURN
152900 WRITE(bort_str,'("BUFRLIB: NEMTBD - ITAB (",I7,") NOT FOUND IN '//
153 . 'TABLE D")') itab
154 CALL bort(bort_str)
155901 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)
159902 WRITE(bort_str,'("BUFRLIB: NEMTBD - TABLE D MNEMONIC ",A," IS A'//
160 . ' ZERO LENGTH SEQUENCE")') nemo
161 CALL bort(bort_str)
162903 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)
166904 WRITE(bort_str,'("BUFRLIB: NEMTBD - REPLICATOR IS OUT OF ORDER '//
167 . 'IN TABLE D SEQUENCE MNEMONIC ",A)') nemo
168 CALL bort(bort_str)
169905 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)
173906 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 bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
function ifxy(ADSC)
This function converts an FXY value from its 6 character representation to its bit-wise (integer) rep...
Definition: ifxy.f:43
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
Definition: moda_tababd.F:10
integer, dimension(:), allocatable ntbd
Number of Table D entries for each internal I/O stream (up to a maximum of MAXTBD,...
Definition: moda_tababd.F:53
integer, dimension(:,:), allocatable idnd
Bit-wise representations of the FXY values corresponding to tabd.
Definition: moda_tababd.F:57
character *600, dimension(:,:), allocatable tabd
Table D entries for each internal I/O stream.
Definition: moda_tababd.F:60
This module declares and initializes the MAXCD variable.
Definition: modv_MAXCD.f90:12
integer, public maxcd
Maximum number of child descriptors that can be included within the sequence definition of a Table D ...
Definition: modv_MAXCD.f90:18
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:55
subroutine numtab(LUN, IDN, NEMO, TAB, IRET)
This subroutine returns information about a descriptor from the internal DX BUFR tables,...
Definition: numtab.f:59
subroutine rsvfvm(NEM1, NEM2)
THIS SUBROUTINE STEPS THROUGH THE "FOLLOWING VALUE" MNEMONIC NEM1 AND, FOR EACH "....
Definition: rsvfvm.f:41
subroutine uptdd(ID, LUN, IENT, IRET)
THIS SUBROUTINE RETURNS THE BIT-WISE REPRESENTATION OF THE FXY VALUE CORRESPONDING TO,...
Definition: uptdd.f:61