NCEPLIBS-bufr 11.7.1
dxdump.f
Go to the documentation of this file.
1C> @file
2C> @brief Print the contents of a DX BUFR table.
3
4C> This subroutine prints a copy of the DX BUFR table associated
5C> with a specified Fortran logical unit.
6C>
7C> This subroutine is especially useful for learning the structure
8C> of existing BUFR files which contain DX BUFR table information
9C> embedded as BUFR messages within those files.
10C> The DX BUFR table is printed using the same ASCII format
11C> described in the documentation for
12C> [DX BUFR Tables](@ref dfbftab), so the output file is suitable
13C> for use as Fortran logical unit LUNDX in subsequent calls to
14C> subroutine openbf() for reading or writing additional BUFR
15C> files with the same structure.
16C>
17C> @author J. Ator
18C> @date 2004-08-18
19C>
20C> @param[in] LUNIT -- integer: Fortran logical unit number for
21C> BUFR file
22C> @param[in] LDXOT -- integer: Fortran logical unit number for
23C> print output
24C>
25C> <p>Logical unit LUNIT must be open for either input or output
26C> operations via a previous call to subroutine openbf().
27C> Logical unit LDXOT must already be associated with a filename
28C> on the local system, typically via a Fortran "OPEN" statement.
29C>
30C> @remarks
31C> - This subroutine only prints the DX BUFR table that is currently
32C> in scope for logical unit LUNIT. Therefore, if logical unit LUNIT
33C> contains multiple embedded DX BUFR tables, then multiple calls to
34C> this subroutine must be made to print out all of the tables,
35C> once while each table is in scope for a data subset defined
36C> within that particular table.
37C>
38C> <b>Program history log:</b>
39C> | Date | Programmer | Comments |
40C> | -----|------------|----------|
41C> | 2004-08-18 | J. Ator | Original author |
42C> | 2007-01-19 | J. Ator | Corrected output for reference values longer than 8 digits |
43C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
44C>
45 SUBROUTINE dxdump(LUNIT,LDXOT)
46
47 USE moda_tababd
48 USE moda_nmikrp
49
50 COMMON /reptab/ idnr(5,2),typs(5,2),reps(5,2),lens(5)
51
52 CHARACTER*80 CARD,CARDI1,CARDI2,CARDI3,CARDI4
53 CHARACTER*20 CMSTR
54 CHARACTER*10 WRK3
55 CHARACTER*8 WRK1,WRK2
56 CHARACTER*6 ADN
57 CHARACTER*3 TYPS
58 CHARACTER*1 REPS
59
60 LOGICAL TBSKIP, TDSKIP, XTRCI1
61
62 DATA cardi1( 1:40)
63 . /'| | | '/
64 DATA cardi1(41:80)
65 . /' |'/
66 DATA cardi2( 1:40)
67 . /'| | '/
68 DATA cardi2(41:80)
69 . /' |'/
70 DATA cardi3( 1:40)
71 . /'| | | | | '/
72 DATA cardi3(41:80)
73 . /' |-------------|'/
74 DATA cardi4( 1:40)
75 . /'|---------------------------------------'/
76 DATA cardi4(41:80)
77 . /'---------------------------------------|'/
78
79C-----------------------------------------------------------------------
80 tbskip(adn) = ((adn.EQ.'063000').OR.(adn.EQ.'063255').OR.
81 . (adn.EQ.'031000').OR.(adn.EQ.'031001').OR.
82 . (adn.EQ.'031002'))
83 tdskip(adn) = ((adn.EQ.'360001').OR.(adn.EQ.'360002').OR.
84 . (adn.EQ.'360003').OR.(adn.EQ.'360004'))
85C-----------------------------------------------------------------------
86
87C DETERMINE LUN FROM LUNIT.
88
89 CALL status(lunit,lun,il,im)
90 IF(il.EQ.0) GOTO 900
91
92C CREATE AND WRITE OUT (TO LDXOT) THE HEADER CARDS FOR THE
93C DESCRIPTOR DEFINITION SECTION.
94
95 card=cardi4
96 card( 1: 1)='.'
97 card(80:80)='.'
98 WRITE (ldxot,'(A)') card
99
100 card=cardi4
101 card( 2: 2)=' '
102 card(79:79)=' '
103 card(15:64)=' USER DEFINITIONS FOR TABLE-A TABLE-B TABLE D '
104 WRITE (ldxot,'(A)') card
105
106 WRITE (ldxot,'(A)') cardi4
107
108 card=cardi1
109 card( 3:10)='MNEMONIC'
110 card(14:19)='NUMBER'
111 card(23:33)='DESCRIPTION'
112 WRITE (ldxot,'(A)') card
113
114 card=cardi4
115 card(12:12)='|'
116 card(21:21)='|'
117 WRITE (ldxot,'(A)') card
118
119C CREATE AND WRITE OUT (TO LDXOT) THE TABLE D DESCRIPTOR
120C DEFINITION CARDS.
121
122 WRITE (ldxot,'(A)') cardi1
123
124 xtrci1=.false.
125 DO n=1,ntbd(lun)
126 IF(.NOT.tdskip(tabd(n,lun)(1:6))) THEN
127 card=cardi1
128 card( 3:10)=tabd(n,lun)( 7:14)
129 card(14:19)=tabd(n,lun)( 1: 6)
130 card(23:77)=tabd(n,lun)(16:70)
131
132C CHECK IF THIS TABLE D MNEMONIC IS ALSO A TABLE A MNEMONIC.
133C IF SO, THEN LABEL IT AS SUCH AND ALSO CHECK IF IT IS THE
134C LAST OF THE TABLE A MNEMONICS, IN WHICH CASE AN EXTRA
135C CARDI1 LINE WILL BE WRITTEN TO LDXOT IN ORDER TO SEPARATE
136C THE TABLE A MNEMONICS FROM THE OTHER TABLE D MNEMONICS.
137
138 DO na=1,ntba(lun)
139 IF(taba(na,lun)(4:11).EQ.tabd(n,lun)(7:14)) THEN
140 card(14:14)='A'
141 IF(na.EQ.ntba(lun)) xtrci1=.true.
142 GOTO 10
143 END IF
144 END DO
145 10 WRITE (ldxot,'(A)') card
146 IF(xtrci1) THEN
147 WRITE (ldxot,'(A)') cardi1
148 xtrci1=.false.
149 END IF
150 END IF
151 END DO
152
153C CREATE AND WRITE OUT (TO LDXOT) THE TABLE B DESCRIPTOR
154C DEFINITION CARDS.
155
156 WRITE (ldxot,'(A)') cardi1
157
158 DO n=1,ntbb(lun)
159 IF(.NOT.tbskip(tabb(n,lun)(1:6))) THEN
160 card=cardi1
161 card( 3:10)=tabb(n,lun)( 7:14)
162 card(14:19)=tabb(n,lun)( 1: 6)
163 card(23:77)=tabb(n,lun)(16:70)
164 WRITE (ldxot,'(A)') card
165 END IF
166 END DO
167
168 WRITE (ldxot,'(A)') cardi1
169
170C CREATE AND WRITE OUT (TO LDXOT) THE HEADER CARDS FOR THE
171C SEQUENCE DEFINITION SECTION.
172
173 WRITE (ldxot,'(A)') cardi4
174
175 card=cardi2
176 card( 3:10)='MNEMONIC'
177 card(14:21)='SEQUENCE'
178 WRITE (ldxot,'(A)') card
179
180 card=cardi4
181 card(12:12)='|'
182 WRITE (ldxot,'(A)') card
183
184C CREATE AND WRITE OUT (TO LDXOT) THE TABLE D SEQUENCE
185C DEFINITION CARDS.
186
187 WRITE (ldxot,'(A)') cardi2
188
189 DO n=1,ntbd(lun)
190 IF(.NOT.tdskip(tabd(n,lun)(1:6))) THEN
191 card=cardi2
192 card( 3:10)=tabd(n,lun)( 7:14)
193 ic = 14
194
195C GET THE LIST OF CHILD MNEMONICS FOR THIS TABLE D DESCRIPTOR,
196C AND THEN ADD EACH ONE (INCLUDING ANY REPLICATION TAGS) TO
197C THE SEQUENCE DEFINITION CARD FOR THIS TABLE D DESCRIPTOR.
198
199 CALL nemtbd(lun,n,nseq,nem(1,1),irp(1,1),krp(1,1))
200 IF(nseq.GT.0) THEN
201 DO nc=1,nseq
202 cmstr=' '
203 icms=0
204 CALL strsuc(nem(nc,1),wrk2,nch)
205 IF(irp(nc,1).NE.0) THEN
206
207C ADD THE OPENING REPLICATION TAG.
208
209 icms=icms+1
210 cmstr(icms:icms)=reps(irp(nc,1),1)
211 END IF
212 cmstr(icms+1:icms+nch)=wrk2(1:nch)
213 icms=icms+nch
214 IF(irp(nc,1).NE.0) THEN
215
216C ADD THE CLOSING REPLICATION TAG.
217
218 icms=icms+1
219 cmstr(icms:icms)=reps(irp(nc,1),2)
220 END IF
221 IF(krp(nc,1).NE.0) THEN
222
223C ADD THE FIXED REPLICATION COUNT.
224
225 wrk1=' '
226 WRITE (wrk1,'(I3)') krp(nc,1)
227 CALL strsuc(wrk1,wrk2,nch)
228 cmstr(icms+1:icms+nch)=wrk2(1:nch)
229 icms=icms+nch
230 END IF
231
232C WILL THIS CHILD (AND ITS REPLICATION TAGS, IF ANY) FIT
233C INTO THE CURRENT SEQUENCE DEFINITION CARD? IF NOT, THEN
234C WRITE OUT (TO LDXOT) THE CURRENT CARD AND INITIALIZE A
235C NEW ONE TO HOLD THIS CHILD.
236
237 IF(ic.GT.(79-icms)) THEN
238 WRITE (ldxot,'(A)') card
239 card=cardi2
240 card( 3:10)=tabd(n,lun)( 7:14)
241 ic = 14
242 END IF
243 card(ic:ic+icms-1)=cmstr(1:icms)
244
245C NOTE THAT WE WANT TO LEAVE 2 BLANK SPACES BETWEEN EACH
246C CHILD WITHIN THE SEQUENCE DEFINITION CARD (TO IMPROVE
247C READABILITY).
248
249 ic=ic+icms+2
250 END DO
251 WRITE (ldxot,'(A)') card
252 WRITE (ldxot,'(A)') cardi2
253 END IF
254 END IF
255 END DO
256
257C CREATE AND WRITE OUT (TO LDXOT) THE HEADER CARDS FOR THE
258C ELEMENT DEFINITION SECTION.
259
260 WRITE (ldxot,'(A)') cardi4
261
262 card=cardi3
263 card( 3:10)='MNEMONIC'
264 card(14:17)='SCAL'
265 card(21:29)='REFERENCE'
266 card(35:37)='BIT'
267 card(41:45)='UNITS'
268 WRITE (ldxot,'(A)') card
269
270 card=cardi4
271 card(12:12)='|'
272 card(19:19)='|'
273 card(33:33)='|'
274 card(39:39)='|'
275 card(66:66)='|'
276 WRITE (ldxot,'(A)') card
277
278C CREATE AND WRITE OUT (TO LDXOT) THE TABLE B ELEMENT
279C DEFINITION CARDS.
280
281 WRITE (ldxot,'(A)') cardi3
282
283 DO n=1,ntbb(lun)
284 IF(.NOT.tbskip(tabb(n,lun)(1:6))) THEN
285 card=cardi3
286 card( 3:10)=tabb(n,lun)( 7:14)
287 card(41:64)=tabb(n,lun)(71:94)
288
289C ADD THE SCALE FACTOR.
290
291 CALL strsuc(tabb(n,lun)(96:98),wrk2,nch)
292 card(17-nch+1:17)=wrk2
293 IF(tabb(n,lun)(95:95).EQ.'-') card(17-nch:17-nch)='-'
294
295C ADD THE REFERENCE VALUE.
296
297 CALL strsuc(tabb(n,lun)(100:109),wrk3,nch)
298 card(31-nch+1:31)=wrk3
299 IF(tabb(n,lun)(99:99).EQ.'-') card(31-nch:31-nch)='-'
300
301C ADD THE BIT WIDTH.
302
303 CALL strsuc(tabb(n,lun)(110:112),wrk2,nch)
304 card(37-nch+1:37)=wrk2
305 WRITE (ldxot,'(A)') card
306 END IF
307 END DO
308
309 WRITE (ldxot,'(A)') cardi3
310
311C CREATE AND WRITE OUT (TO LDXOT) THE CLOSING CARD.
312
313 card=cardi4
314 card( 1: 1)='`'
315 card(80:80)=''''
316 WRITE (ldxot,'(A)') card
317
318 RETURN
319900 CALL bort('BUFRLIB: DXDUMP - BUFR FILE IS CLOSED, IT MUST BE'//
320 . ' OPEN')
321
322 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine dxdump(LUNIT, LDXOT)
This subroutine prints a copy of the DX BUFR table associated with a specified Fortran logical unit.
Definition: dxdump.f:46
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
Definition: moda_tababd.F:10
character *128, dimension(:,:), allocatable tabb
Table B entries for each internal I/O stream.
Definition: moda_tababd.F:59
character *128, dimension(:,:), allocatable taba
Table A entries for each internal I/O stream.
Definition: moda_tababd.F:58
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 ntbb
Number of Table B entries for each internal I/O stream (up to a maximum of MAXTBB,...
Definition: moda_tababd.F:52
integer, dimension(:), allocatable ntba
Number of Table A entries for each internal I/O stream (up to a maximum of MAXTBA,...
Definition: moda_tababd.F:51
character *600, dimension(:,:), allocatable tabd
Table D entries for each internal I/O stream.
Definition: moda_tababd.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:55
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:56
subroutine strsuc(STR1, STR2, LENS)
This subroutine removes leading and trailing blanks from a character string.
Definition: strsuc.f:24