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