NCEPLIBS-bufr  12.0.1
ufbdmp.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Print the contents of a data subset.
3 C>
4 C> @authors J. Woollen, J. Ator, D. Keyser @date 1994-01-06
5 
6 C> Print the contents of a data subset.
7 C>
8 C> This subroutine prints a verbose listing of the contents of a data
9 C> subset, including all data values and replicated sequences, as well
10 C> as jump/link table information and other internal subset pointers.
11 C>
12 C> This subroutine is similar to subroutine ufdump(), but it prints
13 C> different characteristics of each data subset, and in a slightly
14 C> different format. However, both subroutines can be useful for
15 C> different diagnostic purposes, and both can also be run
16 C> interactively to scroll through the contents of a data subset.
17 C>
18 C> Logical unit ABS(LUNIN) should have already been opened for
19 C> input operations via a previous call to subroutine openbf(), and a
20 C> BUFR data subset should have already been read into internal arrays
21 C> via a previous call to one of the
22 C> [subset-reading subroutines](@ref hierarchy).
23 C>
24 C> Except when LUPRT = 0, logical unit LUPRT must already be
25 C> associated with a filename on the local system, typically via a
26 C> Fortran "OPEN" statement. When LUPRT = 0, the subroutine will run
27 C> interactively and print to standard output, scrolling 20 lines at
28 C> a time and prompting each time whether to quit and return to the
29 C> application program (by typing 'q' then '<Enter>') or continue
30 C> scrolling (by typing anything else).
31 C>
32 C> @param[in] LUNIN - integer: Absolute value is Fortran logical
33 C> unit number for BUFR file.
34 C> - If LUNIN > 0, data values are printed to
35 C> LUPRT using the format descriptor code
36 C> 'G15.6', meaning that all values will be
37 C> printed (since the format adapts to the
38 C> order of magnitude of each value), but
39 C> values won't necessarily be lined up
40 C> with the decimal point in the same column
41 C> - If LUNIN < 0, data values are printed to
42 C> LUPRT using the format descriptor code
43 C> 'F15.6', meaning that all values will be
44 C> lined up with the decimal point in the
45 C> same column, but values exceeding the
46 C> format width of 15 characters will print
47 C> as overflow (e.g. '***************')
48 C> @param[in] LUPRT - integer: Fortran logical unit number for
49 C> print output:
50 C> - 0 = Run interactively, printing to standard output
51 C>
52 C> @authors J. Woollen, J. Ator, D. Keyser @date 1994-01-06
53  RECURSIVE SUBROUTINE ufbdmp(LUNIN,LUPRT)
54 
55  USE modv_im8b
56 
57  USE moda_usrint
58  USE moda_msgcwd
59  USE moda_tababd
60  USE moda_tables
61 
62  CHARACTER*120 lchr2
63  CHARACTER*20 lchr,pmiss
64  CHARACTER*14 bits
65  CHARACTER*10 tg,tg_rj
66  CHARACTER*8 vc
67  CHARACTER*7 fmtf
68  CHARACTER*3 tp
69  CHARACTER*1 tab,you
70  equivalence(vl,vc)
71  real*8 vl
72 
73  parameter(mxfv=31)
74  INTEGER ifv(mxfv)
75 
76  DATA pmiss /' MISSING'/
77  DATA you /'Y'/
78 
79 C----------------------------------------------------------------------
80 C----------------------------------------------------------------------
81 
82 C CHECK FOR I8 INTEGERS
83 C ---------------------
84 
85  IF(im8b) THEN
86  im8b=.false.
87 
88  CALL x84(lunin,my_lunin,1)
89  CALL x84(luprt,my_luprt,1)
90  CALL ufbdmp(my_lunin,my_luprt)
91 
92  im8b=.true.
93  RETURN
94  ENDIF
95 
96  IF(luprt.EQ.0) THEN
97  luout = 6
98  ELSE
99  luout = luprt
100  ENDIF
101 
102 C CHECK THE FILE STATUS AND I-NODE
103 C --------------------------------
104 
105  lunit = abs(lunin)
106  CALL status(lunit,lun,il,im)
107  IF(il.EQ.0) GOTO 900
108  IF(il.GT.0) GOTO 901
109  IF(im.EQ.0) GOTO 902
110  IF(inode(lun).NE.inv(1,lun)) GOTO 903
111 
112 C DUMP THE CONTENTS OF MODULE USRINT FOR UNIT ABS(LUNIN)
113 C ------------------------------------------------------
114 
115  DO nv=1,nval(lun)
116  IF(luprt.EQ.0 .AND. mod(nv,20).EQ.0) THEN
117 
118 C When LUPRT=0, the output will be scrolled, 20 elements at a time
119 C ----------------------------------------------------------------
120 
121  print*,'(<enter> for MORE, q <enter> to QUIT)'
122  READ(5,'(A1)') you
123 
124 C If the terminal enters "q" followed by "<enter>" after the prompt
125 C "(<enter> for MORE, q <enter> to QUIT)", scrolling will end and the
126 C subroutine will return to the calling program
127 C -------------------------------------------------------------------
128 
129  IF(you.EQ.'q') THEN
130  print*
131  print*,'==> You have chosen to stop the dumping of this subset'
132  print*
133  GOTO 100
134  ENDIF
135  ENDIF
136  nd = inv(nv,lun)
137  vl = val(nv,lun)
138  tg = tag(nd)
139  tp = typ(nd)
140  it = itp(nd)
141  ib = ibt(nd)
142  is = isc(nd)
143  ir = irf(nd)
144  jp = jump(nd)
145  lk = link(nd)
146  jb = jmpb(nd)
147  tg_rj = adjustr(tg)
148  IF(tp.NE.'CHR') THEN
149  bits = ' '
150  IF(it.EQ.2) THEN
151  CALL nemtab(lun,tg,idn,tab,n)
152  IF(tabb(n,lun)(71:75).EQ.'FLAG') THEN
153 
154 C Print a listing of the bits corresponding to
155 C this value.
156 
157  CALL upftbv(lunit,tg,vl,mxfv,ifv,nifv)
158  IF(nifv.GT.0) THEN
159  bits(1:1) = '('
160  ipt = 2
161  DO ii=1,nifv
162  isz = isize(ifv(ii))
163  WRITE(fmtf,'(A2,I1,A4)') '(I', isz, ',A1)'
164  IF((ipt+isz).LE.14) THEN
165  WRITE(bits(ipt:ipt+isz),fmtf) ifv(ii), ','
166  ipt = ipt + isz + 1
167  ELSE
168  bits(2:13) = 'MANY BITS ON'
169  ipt = 15
170  ENDIF
171  ENDDO
172  bits(ipt-1:ipt-1) = ')'
173  ENDIF
174  ENDIF
175  ENDIF
176  IF(ibfms(vl).NE.0) THEN
177  WRITE(luout,2) nv,tp,it,tg_rj,pmiss,ib,is,ir,nd,jp,lk,jb
178  ELSE
179  IF(lunit.EQ.lunin) THEN
180  WRITE(luout,1) nv,tp,it,tg_rj,vl,bits,ib,is,ir,nd,jp,lk,
181  . jb
182  ELSE
183  WRITE(luout,10) nv,tp,it,tg_rj,vl,bits,ib,is,ir,nd,jp,lk,
184  . jb
185  ENDIF
186  ENDIF
187  ELSE
188  nchr=ib/8
189  IF(nchr.GT.8) THEN
190  CALL readlc(lunit,lchr2,tg_rj)
191  IF (icbfms(lchr2,nchr).NE.0) THEN
192  lchr = pmiss
193  ELSE
194  lchr = lchr2(1:20)
195  ENDIF
196  ELSE
197  IF(ibfms(vl).NE.0) THEN
198  lchr = pmiss
199  ELSE
200  lchr = vc
201  ENDIF
202  ENDIF
203  IF ( nchr.LE.20 .OR. lchr.EQ.pmiss ) THEN
204  lchr = adjustr(lchr)
205  WRITE(luout,2) nv,tp,it,tg_rj,lchr,ib,is,ir,nd,jp,lk,jb
206  ELSE
207  WRITE(luout,4) nv,tp,it,tg_rj,lchr2(1:nchr),ib,is,ir,nd,jp,
208  . lk,jb
209  ENDIF
210  ENDIF
211  ENDDO
212 
213  WRITE(luout,3)
214 
215 1 FORMAT(i5,1x,a3,'-',i1,1x,a10,5x,g15.6,1x,a14,7(1x,i5))
216 10 FORMAT(i5,1x,a3,'-',i1,1x,a10,5x,f15.6,1x,a14,7(1x,i5))
217 2 FORMAT(i5,1x,a3,'-',i1,1x,a10,1x, a20, 14x,7(1x,i5))
218 3 FORMAT(/' >>> END OF SUBSET <<< '/)
219 4 FORMAT(i5,1x,a3,'-',i1,1x,a10,1x, a, 7(1x,i5))
220 
221 C EXITS
222 C -----
223 
224 100 RETURN
225 900 CALL bort('BUFRLIB: UFBDMP - INPUT BUFR FILE IS CLOSED, IT '//
226  . 'MUST BE OPEN FOR INPUT')
227 901 CALL bort('BUFRLIB: UFBDMP - INPUT BUFR FILE IS OPEN FOR '//
228  . 'OUTPUT, IT MUST BE OPEN FOR INPUT')
229 902 CALL bort('BUFRLIB: UFBDMP - A MESSAGE MUST BE OPEN IN INPUT '//
230  . 'BUFR FILE, NONE ARE')
231 903 CALL bort('BUFRLIB: UFBDMP - LOCATION OF INTERNAL TABLE FOR '//
232  . 'INPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN '//
233  . 'INTERNAL SUBSET ARRAY')
234  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
integer function ibfms(R8VAL)
Test whether a real*8 data value is "missing".
Definition: ibfms.f:28
recursive function icbfms(STR, LSTR)
This function provides a handy way to check whether a character string returned from a previous call ...
Definition: icbfms.f:25
integer function isize(NUM)
This function computes and returns the number of characters needed to encode the input integer NUM as...
Definition: isize.f:19
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
character *128, dimension(:,:), allocatable tabb
Table B entries for each internal I/O stream.
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
character *3, dimension(:), allocatable typ
Type indicators corresponding to tag:
integer, dimension(:), allocatable jmpb
Jump backward indices corresponding to tag and typ:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
integer, dimension(:), allocatable jump
Jump forward indices corresponding to tag and typ:
integer, dimension(:), allocatable itp
Integer type values corresponding to typ:
integer, dimension(:), allocatable link
Link indices corresponding to tag, typ and jmpb:
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:), allocatable nval
Number of data values in BUFR data subset.
real *8, dimension(:,:), allocatable, target val
Data values.
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
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 nemtab(LUN, NEMO, IDN, TAB, IRET)
Get information about a descriptor, based on the mnemonic.
Definition: nemtab.f:29
recursive subroutine readlc(LUNIT, CHR, STR)
Read a long character string (greater than 8 bytes) from a data subset.
Definition: readlc.f:50
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
recursive subroutine ufbdmp(LUNIN, LUPRT)
Print the contents of a data subset.
Definition: ufbdmp.f:54
recursive subroutine upftbv(LUNIT, NEMO, VAL, MXIB, IBIT, NIB)
Given a Table B mnemonic with flag table units and a corresponding numerical data value,...
Definition: upftbv.f:28
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19