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