NCEPLIBS-bufr  12.2.0
All Data Structures Namespaces Files Functions Variables Macros Pages
dumpdata.F90
Go to the documentation of this file.
1 
5 
41 recursive subroutine ufbdmp(lunin,luprt)
42 
43  use modv_vars, only: im8b
44 
45  use moda_usrint
46  use moda_msgcwd
47  use moda_tababd
48  use moda_tables
49 
50  implicit none
51 
52  integer, intent(in) :: lunin, luprt
53  integer, parameter :: mxfv = 31
54  integer ifv(mxfv), my_lunin, my_luprt, luout, lunit, lun, il, im, nv, nd, it, ib, is, ir, jp, lk, jb, &
55  idn, nifv, nchr, n, ii, ipt, isz, isize, ibfms, icbfms
56 
57  character lchr2*120, lchr*20, pmiss*20, bits*14, tg*10, tg_rj*10, vc*8, fmtf*7, tp*3, tab, you
58 
59  real*8 vl
60 
61  equivalence(vl,vc)
62 
63  data pmiss /' MISSING'/
64  data you /'Y'/
65 
66  ! Check for I8 integers
67 
68  if(im8b) then
69  im8b=.false.
70 
71  call x84(lunin,my_lunin,1)
72  call x84(luprt,my_luprt,1)
73  call ufbdmp(my_lunin,my_luprt)
74 
75  im8b=.true.
76  return
77  endif
78 
79  if(luprt==0) then
80  luout = 6
81  else
82  luout = luprt
83  endif
84 
85  ! Check the file status and inode
86 
87  lunit = abs(lunin)
88  call status(lunit,lun,il,im)
89  if(il==0) call bort('BUFRLIB: UFBDMP - INPUT BUFR FILE IS CLOSED, IT MUST BE OPEN FOR INPUT')
90  if(il>0) call bort('BUFRLIB: UFBDMP - INPUT BUFR FILE IS OPEN FOR OUTPUT, IT MUST BE OPEN FOR INPUT')
91  if(im==0) call bort('BUFRLIB: UFBDMP - A MESSAGE MUST BE OPEN IN INPUT BUFR FILE, NONE ARE')
92  if(inode(lun)/=inv(1,lun)) call bort('BUFRLIB: UFBDMP - LOCATION OF INTERNAL TABLE FOR '// &
93  'INPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN INTERNAL SUBSET ARRAY')
94 
95  ! Dump the contents of @ref moda_usrint for unit abs(lunin)
96 
97  do nv=1,nval(lun)
98  if(luprt==0 .and. mod(nv,20)==0) then
99 
100  ! When luprt=0, the output will be scrolled, 20 elements at a time
101 
102  print*,'(<enter> for MORE, q <enter> to QUIT)'
103  read(5,'(A1)') you
104 
105  ! If the terminal enters "q" followed by "<enter>", then scrolling will end and the subroutine will return to the
106  ! calling program
107 
108  if(you=='q') then
109  print*
110  print*,'==> You have chosen to stop the dumping of this subset'
111  print*
112  return
113  endif
114  endif
115  nd = inv(nv,lun)
116  vl = val(nv,lun)
117  tg = tag(nd)
118  tp = typ(nd)
119  it = itp(nd)
120  ib = ibt(nd)
121  is = isc(nd)
122  ir = irf(nd)
123  jp = jump(nd)
124  lk = link(nd)
125  jb = jmpb(nd)
126  tg_rj = adjustr(tg)
127  if(tp/='CHR') then
128  bits = ' '
129  if(it==2) then
130  call nemtab(lun,tg,idn,tab,n)
131  if(tabb(n,lun)(71:75)=='FLAG') then
132 
133  ! Print a listing of the bits corresponding to this value.
134 
135  call upftbv(lunit,tg,vl,mxfv,ifv,nifv)
136  if(nifv>0) then
137  bits(1:1) = '('
138  ipt = 2
139  do ii=1,nifv
140  isz = isize(ifv(ii))
141  write(fmtf,'(A2,I1,A4)') '(I', isz, ',A1)'
142  if((ipt+isz)<=14) then
143  write(bits(ipt:ipt+isz),fmtf) ifv(ii), ','
144  ipt = ipt + isz + 1
145  else
146  bits(2:13) = 'MANY BITS ON'
147  ipt = 15
148  endif
149  enddo
150  bits(ipt-1:ipt-1) = ')'
151  endif
152  endif
153  endif
154  if(ibfms(vl)/=0) then
155  write(luout,'(I5,1X,A3,A1,I1,1X,A10,1X, A20, 14X,7(1X,I5))') nv,tp,'-',it,tg_rj,pmiss,ib,is,ir,nd,jp,lk,jb
156  else
157  if(lunit==lunin) then
158  write(luout,'(I5,1X,A3,A1,I1,1X,A10,5X,G15.6,1X,A14,7(1X,I5))') nv,tp,'-',it,tg_rj,vl,bits,ib,is,ir,nd,jp,lk,jb
159  else
160  write(luout,'(I5,1X,A3,A1,I1,1X,A10,5X,F15.6,1X,A14,7(1X,I5))') nv,tp,'-',it,tg_rj,vl,bits,ib,is,ir,nd,jp,lk,jb
161  endif
162  endif
163  else
164  nchr=ib/8
165  if(nchr>8) then
166  call readlc(lunit,lchr2,tg_rj)
167  if (icbfms(lchr2,nchr)/=0) then
168  lchr = pmiss
169  else
170  lchr = lchr2(1:20)
171  endif
172  else
173  if(ibfms(vl)/=0) then
174  lchr = pmiss
175  else
176  lchr = vc
177  endif
178  endif
179  if ( nchr<=20 .or. lchr==pmiss ) then
180  lchr = adjustr(lchr)
181  write(luout,'(I5,1X,A3,A1,I1,1X,A10,1X, A20, 14X,7(1X,I5))') nv,tp,'-',it,tg_rj,lchr,ib,is,ir,nd,jp,lk,jb
182  else
183  write(luout,'(I5,1X,A3,A1,I1,1X,A10,1X, A, 7(1X,I5))') nv,tp,'-',it,tg_rj,lchr2(1:nchr),ib,is,ir,nd,jp,lk,jb
184  endif
185  endif
186  enddo
187 
188  write(luout,'(/A/)') ' >>> END OF SUBSET <<< '
189 
190  return
191 end subroutine ufbdmp
192 
227 recursive subroutine ufdump(lunit,luprt)
228 
229  use bufrlib
230 
231  use modv_vars, only: im8b
232 
233  use moda_usrint
234  use moda_msgcwd
235  use moda_tababd
236  use moda_tables
237  use moda_tablef
238  use moda_nrv203
239 
240  implicit none
241 
242  integer, intent(in) :: lunit, luprt
243  integer, parameter :: mxfv = 31 , mxcfdp = 5, mxseq = 10, mxls = 10
244  integer ifv(mxfv), icfdp(mxcfdp), idxrep(mxseq), numrep(mxseq), lsqnam(mxseq), lsct(mxls), my_lunit, my_luprt, &
245  nseq, nls, lcfmeang, luout, lun, il, im, node, lnm2, lnm3, itmp, ityp, ii, jj, nifv, nv, n, nchr, idn, ipt, &
246  nrfe, nout, lcfmg, ifvd, iersf, ierbd, ierft, isz, isize, iscl, ireadmt, ibfms, icbfms, imrkopr
247  integer*8 ival
248 
249  real*8 rval
250 
251  character cfmeang*120, lchr2*120, fmt*80, desc*64, unit*24, lchr*20, pmiss*20, nemo3*15, nemo*10, nemo2*10, tagrfe*10, &
252  seqnam(mxseq)*10, lsnemo(mxls)*10, nemod*8, cval*8, fmtf*7, numb*6, type*3, tab, you
253 
254  logical track, found, rdrv
255 
256  equivalence(rval,cval)
257 
258  data pmiss /' MISSING'/
259  data you /'Y'/
260 
261  ! Check for I8 integers
262 
263  if(im8b) then
264  im8b=.false.
265 
266  call x84(lunit,my_lunit,1)
267  call x84(luprt,my_luprt,1)
268  call ufdump(my_lunit,my_luprt)
269 
270  im8b=.true.
271  return
272  endif
273 
274  nseq = 0
275  nls = 0
276  lcfmeang = len(cfmeang)
277 
278  if(luprt==0) then
279  luout = 6
280  else
281  luout = luprt
282  endif
283 
284  ! Check the file status and inode
285 
286  call status(lunit,lun,il,im)
287  if(il==0) call bort('BUFRLIB: UFDUMP - INPUT BUFR FILE IS CLOSED, IT MUST BE OPEN FOR INPUT')
288  if(il>0) call bort('BUFRLIB: UFDUMP - INPUT BUFR FILE IS OPEN FOR OUTPUT, IT MUST BE OPEN FOR INPUT')
289  if(im==0) call bort('BUFRLIB: UFDUMP - A MESSAGE MUST BE OPEN IN INPUT BUFR FILE, NONE ARE')
290  if(inode(lun)/=inv(1,lun)) call bort('BUFRLIB: UFDUMP - LOCATION OF INTERNAL TABLE FOR '// &
291  'INPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN INTERNAL SUBSET ARRAY')
292 
293  write(luout,'(/,2A,/)') 'MESSAGE TYPE ',tag(inode(lun))
294 
295  ! If code/flag table details are being printed, and if this is the first subset of a new message, then
296  ! make sure the appropriate master tables have been read in to memory for this message.
297 
298  if(cdmf=='Y' .and. nsub(lun)==1) itmp = ireadmt(lun)
299 
300  ! Dump the contents of @ref moda_usrint for unit lunit
301 
302  do nv=1,nval(lun)
303  if(luprt==0 .and. mod(nv,20)==0) then
304 
305  ! When luprt=0, the output will be scrolled, 20 elements at a time
306 
307  print*,'(<enter> for MORE, q <enter> to QUIT)'
308  read(5,'(A1)') you
309 
310  ! If the terminal enters "q" followed by "<enter>", then scrolling will end and the subroutine will return to the
311  ! calling program
312 
313  if(you=='q') then
314  print*
315  print*,'==> You have chosen to stop the dumping of this subset'
316  print*
317  return
318  endif
319  endif
320 
321  node = inv(nv,lun)
322  nemo = tag(node)
323  ityp = itp(node)
324  type = typ(node)
325 
326  if(ityp>=1.and.ityp<=3) then
327  call nemtab(lun,nemo,idn,tab,n)
328  if(n>0) then
329  numb = tabb(n,lun)(1:6)
330  desc = tabb(n,lun)(16:70)
331  unit = tabb(n,lun)(71:94)
332  endif
333  rval = val(nv,lun)
334  endif
335 
336  if((ityp==0).or.(ityp==1)) then
337 
338  ! Sequence descriptor or delayed descriptor replication factor
339 
340  if((type=='REP').or.(type=='DRP').or.(type=='DRB').or.(type=='DRS')) then
341 
342  ! Print the number of replications
343  nseq = nseq+1
344  if(nseq>mxseq) call bort('BUFRLIB: UFDUMP - MXSEQ OVERFLOW')
345  if(type=='REP') then
346  numrep(nseq) = irf(node)
347  else
348  numrep(nseq) = nint(rval)
349  endif
350  call strsuc(nemo,nemo2,lnm2)
351  fmt = '(11X,A,I6,1X,A)'
352  write(luout,fmt) nemo2(1:lnm2), numrep(nseq), 'REPLICATIONS'
353 
354  ! How many times is this sequence replicated?
355  if(numrep(nseq)>1) then
356  ! Track the sequence
357  seqnam(nseq) = nemo2
358  lsqnam(nseq) = lnm2
359  idxrep(nseq) = 1
360  else
361  ! Don't bother
362  nseq = nseq-1
363  endif
364  elseif( ((type=='SEQ').or.(type=='RPC').or.(type=='RPS')) .and. (nseq>0) ) then
365 
366  ! Is this one of the sequences being tracked?
367  ii = nseq
368  track = .false.
369  call strsuc(nemo,nemo2,lnm2)
370  do while ((ii>=1).and.(.not.track))
371  if(nemo2(1:lnm2)==seqnam(ii)(2:lsqnam(ii)-1)) then
372  track = .true.
373  ! Mark this level in the output
374  fmt = '(4X,A,2X,A,2X,A,I6,2X,A)'
375  write(luout,fmt) '++++++', nemo2(1:lnm2), 'REPLICATION #', idxrep(ii), '++++++'
376  if(idxrep(ii)<numrep(ii)) then
377  ! There are more levels to come
378  idxrep(ii) = idxrep(ii)+1
379  else
380  ! This was the last level for this sequence, so stop tracking it
381  nseq = nseq-1
382  endif
383  else
384  ii = ii-1
385  endif
386  enddo
387  endif
388  elseif(ityp==2) then
389 
390  ! Numeric value.
391 
392  ! First check if this node contains a redefined reference value. If so, modify the desc field to label it as such.
393  jj = 1
394  rdrv = .false.
395  do while ((jj<=nnrv).and.(.not.rdrv))
396  if (node==inodnrv(jj)) then
397  rdrv = .true.
398  desc = 'New reference value for ' // nemo
399  unit = ' '
400  else
401  jj = jj + 1
402  endif
403  enddo
404 
405  ! Next check if this element refers to another element via a bitmap. If so, modify the desc field to identify the
406  ! referred element.
407  nrfe = nrfelm(nv,lun)
408  if(nrfe>0) then
409  tagrfe = tag(inv(nrfe,lun))
410  jj = 48
411  do while((jj>=1).and.(desc(jj:jj)==' '))
412  jj = jj - 1
413  enddo
414  if(jj<=33) desc(jj+1:jj+15) = ' for ' // tagrfe
415  endif
416 
417  ! Now print the value
418  if(ibfms(rval)/=0) then
419  ! The value is "missing".
420  fmt = '(A6,2X,A10,2X,A20,2X,A24,6X,A48)'
421  write(luout,fmt) numb,nemo,pmiss,unit,desc
422  else
423  fmt = '(A6,2X,A10,2X, ,2X,A24,6X,A48)'
424  ! Based upon the corresponding scale factor, select an appropriate format for the printing of this value.
425  if(imrkopr(nemo)==1) then
426  iscl = isc(inv(nrfe,lun))
427  else
428  iscl = isc(node)
429  endif
430  if(iscl>0) then
431  write(fmt(15:20),'(A,I2)') 'F20.', iscl
432  else
433  write(fmt(18:20),'(A)') 'I20'
434  endif
435  if(unit(1:4)=='FLAG') then
436  ! Print a listing of the bits corresponding to this value.
437  call upftbv(lunit,nemo,rval,mxfv,ifv,nifv)
438  if(nifv>0) then
439  unit(11:11) = '('
440  ipt = 12
441  do ii=1,nifv
442  isz = isize(ifv(ii))
443  write(fmtf,'(A2,I1,A4)') '(I', isz, ',A1)'
444  if((ipt+isz)<=24) then
445  write(unit(ipt:ipt+isz),fmtf) ifv(ii), ','
446  ipt = ipt + isz + 1
447  else
448  unit(12:23) = 'MANY BITS ON'
449  ipt = 25
450  endif
451  enddo
452  unit(ipt-1:ipt-1) = ')'
453  endif
454  endif
455  if(iscl>0) then
456  write(luout,fmt) numb,nemo,rval,unit,desc
457  else
458  ival = nint(rval,8)
459  write(luout,fmt) numb,nemo,ival,unit,desc
460  endif
461  if( (unit(1:4)=='FLAG' .or. unit(1:4)=='CODE') .and. (cdmf=='Y') ) then
462  ! Print the meanings of the code and flag values.
463  fmt = '(31X,I8,A,A)'
464  if(unit(1:4)=='CODE') then
465  nifv = 1
466  ifv(nifv) = nint(rval)
467  endif
468  do ii=1,nifv
469  icfdp(1) = (-1)
470  call srchtbf_c(idn,ifv(ii),icfdp(1),mxcfdp,-1,cfmeang,lcfmeang,lcfmg,iersf)
471  if(iersf==0) then
472  write(luout,fmt) ifv(ii),' = ',cfmeang(1:lcfmg)
473  elseif(iersf<0) then
474  write(luout,fmt) ifv(ii),' = ','***THIS IS AN ILLEGAL/UNDEFINED VALUE***'
475  else
476  ! The meaning of this value is dependent on the value of another mnemonic in the report. Look for
477  ! that other mnemonic within the report and then use it and its associated value to retrieve and print
478  ! the proper meaning from the code/flag tables.
479  ierft = (-1)
480  jj = 0
481  do while((jj<iersf).and.(ierft<0))
482  jj = jj + 1
483  call numtbd(lun,icfdp(jj),nemod,tab,ierbd)
484  if((ierbd>0).and.(tab=='B')) call fstag(lun,nemod,-1,nv,nout,ierft)
485  enddo
486  if(ierft==0) then
487  ifvd = nint(val(nout,lun))
488  if(jj>1) icfdp(1) = icfdp(jj)
489  call srchtbf_c(idn,ifv(ii),icfdp(1),mxcfdp,ifvd,cfmeang,lcfmeang,lcfmg,iersf)
490  if(iersf==0) write(luout,fmt) ifv(ii),' = ', cfmeang(1:lcfmg)
491  endif
492  endif
493  enddo
494  endif
495  endif
496  elseif(ityp==3) then
497 
498  ! Character (CCITT IA5) value
499 
500  nchr = ibt(node)/8
501 
502  if(ibfms(rval)/=0) then
503  lchr = pmiss
504  else if(nchr<=8) then
505  lchr = cval
506  else
507  ! Track the number of occurrences of this long character string, so that we can properly output each one.
508  ii = 1
509  found = .false.
510  do while((ii<=nls).and.(.not.found))
511  if(nemo==lsnemo(ii)) then
512  found = .true.
513  else
514  ii = ii + 1
515  endif
516  enddo
517  if(.not.found) then
518  nls = nls+1
519  if(nls>mxls) call bort('BUFRLIB: UFDUMP - MXLS OVERFLOW')
520  lsnemo(nls) = nemo
521  lsct(nls) = 1
522  nemo3 = nemo
523  else
524  call strsuc(nemo,nemo3,lnm3)
525  lsct(ii) = lsct(ii) + 1
526  write(fmtf,'(A,I1,A)') '(2A,I', isize(lsct(ii)), ')'
527  write(nemo3,fmtf) nemo(1:lnm3), '#', lsct(ii)
528  endif
529 
530  call readlc(lunit,lchr2,nemo3)
531  if (icbfms(lchr2,nchr)/=0) then
532  lchr = pmiss
533  else
534  lchr = lchr2(1:20)
535  endif
536  endif
537 
538  if ( nchr<=20 .or. lchr==pmiss ) then
539  lchr = adjustr(lchr)
540  fmt = '(A6,2X,A10,2X,A20,2X,"(",I2,")",A24,2X,A48)'
541  write(luout,fmt) numb,nemo,lchr,nchr,unit,desc
542  else
543  fmt = '(A6,2X,A10,2X,A,2X,"(",I3,")",A23,2X,A48)'
544  write(luout,fmt) numb,nemo,lchr2(1:nchr),nchr,unit,desc
545  endif
546  endif
547 
548  enddo
549 
550  write(luout,'(/A/)') ' >>> END OF SUBSET <<< '
551 
552  return
553 end subroutine ufdump
554 
584 recursive subroutine dxdump(lunit,ldxot)
585 
586  use modv_vars, only: im8b, reps, fxy_fbit, fxy_sbyct, fxy_drp16, fxy_drp8, fxy_drp8s, fxy_drp1, &
587  fxy_drf16, fxy_drf8, fxy_drf1
588 
589  use moda_tababd
590  use moda_nmikrp
591 
592  implicit none
593 
594  integer, intent(in) :: lunit, ldxot
595  integer my_lunit, my_ldxot, lun, il, im, n, na, nc, nch, ic, icms, nseq
596 
597  character card*80, cardi1*80, cardi2*80, cardi3*80, cardi4*80, cmstr*20, wrk3*10, wrk1*8, wrk2*8, adn*6
598 
599  logical tbskip, tdskip, xtrci1
600 
601  data cardi1 /'| | | |'/
602  data cardi2 /'| | |'/
603  data cardi3 /'| | | | | |-------------|'/
604  data cardi4 /'|------------------------------------------------------------------------------|'/
605 
606  ! Statement functions
607  tbskip(adn) = ((adn==fxy_sbyct).or.(adn==fxy_fbit).or.(adn==fxy_drf16).or.(adn==fxy_drf8).or.(adn==fxy_drf1))
608  tdskip(adn) = ((adn==fxy_drp16).or.(adn==fxy_drp8).or.(adn==fxy_drp8s).or.(adn==fxy_drp1))
609 
610  ! Check for I8 integers.
611 
612  if(im8b) then
613  im8b=.false.
614 
615  call x84(lunit,my_lunit,1)
616  call x84(ldxot,my_ldxot,1)
617  call dxdump(my_lunit,my_ldxot)
618 
619  im8b=.true.
620  return
621  endif
622 
623  ! Determine lun from lunit.
624 
625  call status(lunit,lun,il,im)
626  if(il==0) call bort('BUFRLIB: DXDUMP - BUFR FILE IS CLOSED, IT MUST BE OPEN')
627 
628  ! Create and write out (to ldxot) the header cards for the descriptor definition section.
629 
630  card=cardi4
631  card( 1: 1)='.'
632  card(80:80)='.'
633  write (ldxot,'(A)') card
634 
635  card=cardi4
636  card( 2: 2)=' '
637  card(79:79)=' '
638  card(15:64)=' USER DEFINITIONS FOR TABLE-A TABLE-B TABLE D '
639  write (ldxot,'(A)') card
640 
641  write (ldxot,'(A)') cardi4
642 
643  card=cardi1
644  card( 3:10)='MNEMONIC'
645  card(14:19)='NUMBER'
646  card(23:33)='DESCRIPTION'
647  write (ldxot,'(A)') card
648 
649  card=cardi4
650  card(12:12)='|'
651  card(21:21)='|'
652  write (ldxot,'(A)') card
653 
654  ! Create and write out (to ldxot) the Table D descriptor definition cards.
655 
656  write (ldxot,'(A)') cardi1
657 
658  xtrci1=.false.
659  do n=1,ntbd(lun)
660  if(.not.tdskip(tabd(n,lun)(1:6))) then
661  card=cardi1
662  card( 3:10)=tabd(n,lun)( 7:14)
663  card(14:19)=tabd(n,lun)( 1: 6)
664  card(23:77)=tabd(n,lun)(16:70)
665  ! Check if this Table D mnemonic is also a Table A mnemonic. If so, then label it as such and also check if it is the
666  ! last of the Table A mnemonics, in which case an extra cardi1 line will be written to ldxot in order to separate
667  ! the Table A mnemonics from the other Table D mnemonics.
668  do na=1,ntba(lun)
669  if(taba(na,lun)(4:11)==tabd(n,lun)(7:14)) then
670  card(14:14)='A'
671  if(na==ntba(lun)) xtrci1=.true.
672  exit
673  end if
674  end do
675  write (ldxot,'(A)') card
676  if(xtrci1) then
677  write (ldxot,'(A)') cardi1
678  xtrci1=.false.
679  end if
680  end if
681  end do
682 
683  ! Create and write out (to ldxot) the Table B descriptor definition cards.
684 
685  write (ldxot,'(A)') cardi1
686 
687  do n=1,ntbb(lun)
688  if(.not.tbskip(tabb(n,lun)(1:6))) then
689  card=cardi1
690  card( 3:10)=tabb(n,lun)( 7:14)
691  card(14:19)=tabb(n,lun)( 1: 6)
692  card(23:77)=tabb(n,lun)(16:70)
693  write (ldxot,'(A)') card
694  end if
695  end do
696 
697  write (ldxot,'(A)') cardi1
698 
699  ! Create and write out (to ldxot) the header cards for the sequence definition section.
700 
701  write (ldxot,'(A)') cardi4
702 
703  card=cardi2
704  card( 3:10)='MNEMONIC'
705  card(14:21)='SEQUENCE'
706  write (ldxot,'(A)') card
707 
708  card=cardi4
709  card(12:12)='|'
710  write (ldxot,'(A)') card
711 
712  ! Create and write out (to ldxot) the Table D sequence definition cards.
713 
714  write (ldxot,'(A)') cardi2
715 
716  do n=1,ntbd(lun)
717  if(.not.tdskip(tabd(n,lun)(1:6))) then
718  card=cardi2
719  card( 3:10)=tabd(n,lun)( 7:14)
720  ic = 14
721  ! Get the list of child mnemonics for this Table D descriptor, and then add each one (including any replication tags)
722  ! to the sequence definition card for this Table D descriptor.
723  call nemtbd(lun,n,nseq,nem(1,1),irp(1,1),krp(1,1))
724  if(nseq>0) then
725  do nc=1,nseq
726  cmstr=' '
727  icms=0
728  call strsuc(nem(nc,1),wrk2,nch)
729  if(irp(nc,1)/=0) then
730  ! Add the opening replication tag.
731  icms=icms+1
732  cmstr(icms:icms)=reps(irp(nc,1))
733  end if
734  cmstr(icms+1:icms+nch)=wrk2(1:nch)
735  icms=icms+nch
736  if(irp(nc,1)/=0) then
737  ! Add the closing replication tag.
738  icms=icms+1
739  cmstr(icms:icms)=reps(irp(nc,1)+5)
740  end if
741  if(krp(nc,1)/=0) then
742  ! Add the fixed replication count.
743  wrk1=' '
744  write (wrk1,'(I3)') krp(nc,1)
745  call strsuc(wrk1,wrk2,nch)
746  cmstr(icms+1:icms+nch)=wrk2(1:nch)
747  icms=icms+nch
748  end if
749  ! Will this child (and its replication tags, if any) fit into the current sequence definition card? If not, then
750  ! write out (to ldxot) the current card and initialize a new one to hold this child.
751  if(ic>(79-icms)) then
752  write (ldxot,'(A)') card
753  card=cardi2
754  card( 3:10)=tabd(n,lun)( 7:14)
755  ic = 14
756  end if
757  card(ic:ic+icms-1)=cmstr(1:icms)
758  ! Note that we want to leave 2 blank spaces between each child within the sequence definition card, to improve
759  ! readability.
760  ic=ic+icms+2
761  end do
762  write (ldxot,'(A)') card
763  write (ldxot,'(A)') cardi2
764  end if
765  end if
766  end do
767 
768  ! Create and write out (to ldxot) the header cards for the element definition section.
769 
770  write (ldxot,'(A)') cardi4
771 
772  card=cardi3
773  card( 3:10)='MNEMONIC'
774  card(14:17)='SCAL'
775  card(21:29)='REFERENCE'
776  card(35:37)='BIT'
777  card(41:45)='UNITS'
778  write (ldxot,'(A)') card
779 
780  card=cardi4
781  card(12:12)='|'
782  card(19:19)='|'
783  card(33:33)='|'
784  card(39:39)='|'
785  card(66:66)='|'
786  write (ldxot,'(A)') card
787 
788  ! Create and write out (to ldxot) the Table B element definition cards.
789 
790  write (ldxot,'(A)') cardi3
791 
792  do n=1,ntbb(lun)
793  if(.not.tbskip(tabb(n,lun)(1:6))) then
794  card=cardi3
795  card( 3:10)=tabb(n,lun)( 7:14)
796  card(41:64)=tabb(n,lun)(71:94)
797  ! Add the scale factor.
798  call strsuc(tabb(n,lun)(96:98),wrk2,nch)
799  card(17-nch+1:17)=wrk2
800  if(tabb(n,lun)(95:95)=='-') card(17-nch:17-nch)='-'
801  ! Add the reference value.
802  call strsuc(tabb(n,lun)(100:109),wrk3,nch)
803  card(31-nch+1:31)=wrk3
804  if(tabb(n,lun)(99:99)=='-') card(31-nch:31-nch)='-'
805  ! Add the bit width.
806  call strsuc(tabb(n,lun)(110:112),wrk2,nch)
807  card(37-nch+1:37)=wrk2
808  write (ldxot,'(a)') card
809  end if
810  end do
811 
812  write (ldxot,'(A)') cardi3
813 
814  ! Create and write out (to ldxot) the closing card.
815 
816  card=cardi4
817  card( 1: 1)='`'
818  card(80:80)=''''
819  write (ldxot,'(A)') card
820 
821  return
822 end subroutine dxdump
823 
834 recursive subroutine getabdb(lunit,tabdb,itab,jtab)
835 
836  use modv_vars, only: im8b
837 
838  use moda_tababd
839  use moda_nmikrp
840 
841  implicit none
842 
843  integer, intent(in) :: lunit, itab
844  integer, intent(out) :: jtab
845  integer my_lunit, my_itab, lun, il, im, i, j, k, nseq
846 
847  character*128, intent(out) :: tabdb(*)
848  character*8 nemo
849 
850  ! Check for I8 integers
851 
852  if(im8b) then
853  im8b=.false.
854  call x84(lunit,my_lunit,1)
855  call x84(itab,my_itab,1)
856  call getabdb(my_lunit,tabdb,my_itab,jtab)
857  call x48(jtab,jtab,1)
858  im8b=.true.
859  return
860  endif
861 
862  jtab = 0
863 
864  ! Make sure the file is open
865 
866  call status(lunit,lun,il,im)
867  if(il==0) return
868 
869  ! Write out the Table D entries for this file
870 
871  do i=1,ntbd(lun)
872  nemo = tabd(i,lun)(7:14)
873  call nemtbd(lun,i,nseq,nem(1,1),irp(1,1),krp(1,1))
874  do j=1,nseq,10
875  jtab = jtab+1
876  if(jtab<=itab) then
877  write(tabdb(jtab),fmt='(A,A8,10(1X,A10))') 'D ', nemo, (nem(k,1),k=j,min(j+9,nseq))
878  endif
879  enddo
880  enddo
881 
882  ! Add the Table B entries
883 
884  do i=1,ntbb(lun)
885  jtab = jtab+1
886  if(jtab<=itab) then
887  write(tabdb(jtab),fmt='(A,A8,1X,A42)') 'B ', tabb(i,lun)(7:14), tabb(i,lun)(71:112)
888  endif
889  enddo
890 
891  return
892 end subroutine getabdb
integer function imrkopr(nemo)
Check whether a specified mnemonic is a Table C marker operator.
Definition: bitmaps.F90:361
subroutine bort(str)
Log an error message, then abort the application program.
Definition: borts.F90:15
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: cftbvs.F90:70
recursive subroutine ufdump(lunit, luprt)
Print a verbose listing of the contents of a data subset, including all data values and replicated se...
Definition: dumpdata.F90:228
recursive subroutine getabdb(lunit, tabdb, itab, jtab)
Get Table B and Table D information from the internal DX BUFR tables.
Definition: dumpdata.F90:835
recursive subroutine dxdump(lunit, ldxot)
Print a copy of the DX BUFR table associated with a specified Fortran logical unit.
Definition: dumpdata.F90:585
recursive subroutine ufbdmp(lunin, luprt)
Print a verbose listing of the contents of a data subset, including all data values and replicated se...
Definition: dumpdata.F90:42
subroutine nemtbd(lun, itab, nseq, nems, irps, knts)
Get information about a Table D descriptor from the internal DX BUFR tables.
Definition: dxtable.F90:1337
subroutine nemtab(lun, nemo, idn, tab, iret)
Get information about a descriptor, based on a mnemonic.
Definition: fxy.F90:434
subroutine numtbd(lun, idn, nemo, tab, iret)
Get information about a Table B or Table D descriptor, based on the WMO bit-wise representation of an...
Definition: fxy.F90:290
integer function ireadmt(lun)
Check the most recent BUFR message that was read via a call to one of the message-reading subroutines...
subroutine strsuc(str1, str2, lens)
Remove leading and trailing blanks from a character string.
Definition: misc.F90:199
integer function isize(num)
Compute the number of characters needed to encode an integer as a string.
Definition: misc.F90:385
recursive integer function icbfms(str, lstr)
Check whether a character string returned from a previous call to subroutine readlc() was encoded as ...
Definition: missing.F90:56
integer function ibfms(r8val)
Check whether a real*8 data value returned from a previous call to any of the NCEPLIBS-bufr values-re...
Definition: missing.F90:25
Wrap C NCEPLIBS-bufr functions so they can be called from within the Fortran part of the library.
Definition: bufrlib.F90:11
Declare arrays used to store information about the current BUFR message that is in the process of bei...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
integer, dimension(:), allocatable nsub
Current subset pointer within message.
Declare arrays used by various subroutines to hold information about Table D sequences.
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.
Declare arrays and variables for use with any 2-03-YYY (change reference value) operators present wit...
integer nnrv
Number of entries in the jump/link table which contain new reference values (up to a maximum of mxnrv...
integer, dimension(:), allocatable inodnrv
Entries within jump/link table which contain new reference values.
Declare arrays and variables used to store DX BUFR tables internally for multiple file IDs.
integer, dimension(:), allocatable ntba
Number of Table A entries for each file ID (up to a maximum of maxtba, whose value is stored in array...
character *600, dimension(:,:), allocatable tabd
Table D entries for each file ID.
character *128, dimension(:,:), allocatable taba
Table A entries for each file ID.
integer, dimension(:), allocatable ntbd
Number of Table D entries for each file ID (up to a maximum of maxtbd, whose value is stored in array...
integer, dimension(:), allocatable ntbb
Number of Table B entries for each file ID (up to a maximum of maxtbb, whose value is stored in array...
character *128, dimension(:,:), allocatable tabb
Table B entries for each file ID.
Declare a variable used to indicate whether master code and flag tables should be read.
character cdmf
Flag indicating whether to include code and flag table information during reads of master BUFR tables...
Declare arrays and variables 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:
Declare arrays used to store data values and associated metadata for the current BUFR data subset in ...
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...
integer, dimension(:,:), allocatable nrfelm
Referenced data value, for data values which refer to a previous data value in the BUFR data subset v...
recursive subroutine status(lunit, lun, il, im)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
recursive subroutine readlc(lunit, chr, str)
Read a long character string (greater than 8 bytes) from a data subset.
subroutine x48(iin4, iout8, nval)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x4884.F90:18
subroutine x84(iin8, iout4, nval)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x4884.F90:65