NCEPLIBS-bufr  12.1.0
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, ireadmt, ibfms, icbfms
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(isc(node)>0) then
426  write(fmt(15:20),'(A,I2)') 'F20.', isc(node)
427  else
428  write(fmt(18:20),'(A)') 'I20'
429  endif
430  if(unit(1:4)=='FLAG') then
431  ! Print a listing of the bits corresponding to this value.
432  call upftbv(lunit,nemo,rval,mxfv,ifv,nifv)
433  if(nifv>0) then
434  unit(11:11) = '('
435  ipt = 12
436  do ii=1,nifv
437  isz = isize(ifv(ii))
438  write(fmtf,'(A2,I1,A4)') '(I', isz, ',A1)'
439  if((ipt+isz)<=24) then
440  write(unit(ipt:ipt+isz),fmtf) ifv(ii), ','
441  ipt = ipt + isz + 1
442  else
443  unit(12:23) = 'MANY BITS ON'
444  ipt = 25
445  endif
446  enddo
447  unit(ipt-1:ipt-1) = ')'
448  endif
449  endif
450  if(isc(node)>0) then
451  write(luout,fmt) numb,nemo,rval,unit,desc
452  else
453  ival = nint(rval,8)
454  write(luout,fmt) numb,nemo,ival,unit,desc
455  endif
456  if( (unit(1:4)=='FLAG' .or. unit(1:4)=='CODE') .and. (cdmf=='Y') ) then
457  ! Print the meanings of the code and flag values.
458  fmt = '(31X,I8,A,A)'
459  if(unit(1:4)=='CODE') then
460  nifv = 1
461  ifv(nifv) = nint(rval)
462  endif
463  do ii=1,nifv
464  icfdp(1) = (-1)
465  call srchtbf_c(idn,ifv(ii),icfdp(1),mxcfdp,-1,cfmeang,lcfmeang,lcfmg,iersf)
466  if(iersf==0) then
467  write(luout,fmt) ifv(ii),' = ',cfmeang(1:lcfmg)
468  elseif(iersf<0) then
469  write(luout,fmt) ifv(ii),' = ','***THIS IS AN ILLEGAL/UNDEFINED VALUE***'
470  else
471  ! The meaning of this value is dependent on the value of another mnemonic in the report. Look for
472  ! that other mnemonic within the report and then use it and its associated value to retrieve and print
473  ! the proper meaning from the code/flag tables.
474  ierft = (-1)
475  jj = 0
476  do while((jj<iersf).and.(ierft<0))
477  jj = jj + 1
478  call numtbd(lun,icfdp(jj),nemod,tab,ierbd)
479  if((ierbd>0).and.(tab=='B')) call fstag(lun,nemod,-1,nv,nout,ierft)
480  enddo
481  if(ierft==0) then
482  ifvd = nint(val(nout,lun))
483  if(jj>1) icfdp(1) = icfdp(jj)
484  call srchtbf_c(idn,ifv(ii),icfdp(1),mxcfdp,ifvd,cfmeang,lcfmeang,lcfmg,iersf)
485  if(iersf==0) write(luout,fmt) ifv(ii),' = ', cfmeang(1:lcfmg)
486  endif
487  endif
488  enddo
489  endif
490  endif
491  elseif(ityp==3) then
492 
493  ! Character (CCITT IA5) value
494 
495  nchr = ibt(node)/8
496 
497  if(ibfms(rval)/=0) then
498  lchr = pmiss
499  else if(nchr<=8) then
500  lchr = cval
501  else
502  ! Track the number of occurrences of this long character string, so that we can properly output each one.
503  ii = 1
504  found = .false.
505  do while((ii<=nls).and.(.not.found))
506  if(nemo==lsnemo(ii)) then
507  found = .true.
508  else
509  ii = ii + 1
510  endif
511  enddo
512  if(.not.found) then
513  nls = nls+1
514  if(nls>mxls) call bort('BUFRLIB: UFDUMP - MXLS OVERFLOW')
515  lsnemo(nls) = nemo
516  lsct(nls) = 1
517  nemo3 = nemo
518  else
519  call strsuc(nemo,nemo3,lnm3)
520  lsct(ii) = lsct(ii) + 1
521  write(fmtf,'(A,I1,A)') '(2A,I', isize(lsct(ii)), ')'
522  write(nemo3,fmtf) nemo(1:lnm3), '#', lsct(ii)
523  endif
524 
525  call readlc(lunit,lchr2,nemo3)
526  if (icbfms(lchr2,nchr)/=0) then
527  lchr = pmiss
528  else
529  lchr = lchr2(1:20)
530  endif
531  endif
532 
533  if ( nchr<=20 .or. lchr==pmiss ) then
534  lchr = adjustr(lchr)
535  fmt = '(A6,2X,A10,2X,A20,2X,"(",I2,")",A24,2X,A48)'
536  write(luout,fmt) numb,nemo,lchr,nchr,unit,desc
537  else
538  fmt = '(A6,2X,A10,2X,A,2X,"(",I3,")",A23,2X,A48)'
539  write(luout,fmt) numb,nemo,lchr2(1:nchr),nchr,unit,desc
540  endif
541  endif
542 
543  enddo
544 
545  write(luout,'(/A/)') ' >>> END OF SUBSET <<< '
546 
547  return
548 end subroutine ufdump
549 
579 recursive subroutine dxdump(lunit,ldxot)
580 
581  use modv_vars, only: im8b, reps
582 
583  use moda_tababd
584  use moda_nmikrp
585 
586  implicit none
587 
588  integer, intent(in) :: lunit, ldxot
589  integer my_lunit, my_ldxot, lun, il, im, n, na, nc, nch, ic, icms, nseq
590 
591  character card*80, cardi1*80, cardi2*80, cardi3*80, cardi4*80, cmstr*20, wrk3*10, wrk1*8, wrk2*8, adn*6
592 
593  logical tbskip, tdskip, xtrci1
594 
595  data cardi1 /'| | | |'/
596  data cardi2 /'| | |'/
597  data cardi3 /'| | | | | |-------------|'/
598  data cardi4 /'|------------------------------------------------------------------------------|'/
599 
600  ! Statement functions
601  tbskip(adn) = ((adn=='063000').or.(adn=='063255').or.(adn=='031000').or.(adn=='031001').or.(adn=='031002'))
602  tdskip(adn) = ((adn=='360001').or.(adn=='360002').or.(adn=='360003').or.(adn=='360004'))
603 
604  ! Check for I8 integers.
605 
606  if(im8b) then
607  im8b=.false.
608 
609  call x84(lunit,my_lunit,1)
610  call x84(ldxot,my_ldxot,1)
611  call dxdump(my_lunit,my_ldxot)
612 
613  im8b=.true.
614  return
615  endif
616 
617  ! Determine lun from lunit.
618 
619  call status(lunit,lun,il,im)
620  if(il==0) call bort('BUFRLIB: DXDUMP - BUFR FILE IS CLOSED, IT MUST BE OPEN')
621 
622  ! Create and write out (to ldxot) the header cards for the descriptor definition section.
623 
624  card=cardi4
625  card( 1: 1)='.'
626  card(80:80)='.'
627  write (ldxot,'(A)') card
628 
629  card=cardi4
630  card( 2: 2)=' '
631  card(79:79)=' '
632  card(15:64)=' USER DEFINITIONS FOR TABLE-A TABLE-B TABLE D '
633  write (ldxot,'(A)') card
634 
635  write (ldxot,'(A)') cardi4
636 
637  card=cardi1
638  card( 3:10)='MNEMONIC'
639  card(14:19)='NUMBER'
640  card(23:33)='DESCRIPTION'
641  write (ldxot,'(A)') card
642 
643  card=cardi4
644  card(12:12)='|'
645  card(21:21)='|'
646  write (ldxot,'(A)') card
647 
648  ! Create and write out (to ldxot) the Table D descriptor definition cards.
649 
650  write (ldxot,'(A)') cardi1
651 
652  xtrci1=.false.
653  do n=1,ntbd(lun)
654  if(.not.tdskip(tabd(n,lun)(1:6))) then
655  card=cardi1
656  card( 3:10)=tabd(n,lun)( 7:14)
657  card(14:19)=tabd(n,lun)( 1: 6)
658  card(23:77)=tabd(n,lun)(16:70)
659  ! 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
660  ! last of the Table A mnemonics, in which case an extra cardi1 line will be written to ldxot in order to separate
661  ! the Table A mnemonics from the other Table D mnemonics.
662  do na=1,ntba(lun)
663  if(taba(na,lun)(4:11)==tabd(n,lun)(7:14)) then
664  card(14:14)='A'
665  if(na==ntba(lun)) xtrci1=.true.
666  exit
667  end if
668  end do
669  write (ldxot,'(A)') card
670  if(xtrci1) then
671  write (ldxot,'(A)') cardi1
672  xtrci1=.false.
673  end if
674  end if
675  end do
676 
677  ! Create and write out (to ldxot) the Table B descriptor definition cards.
678 
679  write (ldxot,'(A)') cardi1
680 
681  do n=1,ntbb(lun)
682  if(.not.tbskip(tabb(n,lun)(1:6))) then
683  card=cardi1
684  card( 3:10)=tabb(n,lun)( 7:14)
685  card(14:19)=tabb(n,lun)( 1: 6)
686  card(23:77)=tabb(n,lun)(16:70)
687  write (ldxot,'(A)') card
688  end if
689  end do
690 
691  write (ldxot,'(A)') cardi1
692 
693  ! Create and write out (to ldxot) the header cards for the sequence definition section.
694 
695  write (ldxot,'(A)') cardi4
696 
697  card=cardi2
698  card( 3:10)='MNEMONIC'
699  card(14:21)='SEQUENCE'
700  write (ldxot,'(A)') card
701 
702  card=cardi4
703  card(12:12)='|'
704  write (ldxot,'(A)') card
705 
706  ! Create and write out (to ldxot) the Table D sequence definition cards.
707 
708  write (ldxot,'(A)') cardi2
709 
710  do n=1,ntbd(lun)
711  if(.not.tdskip(tabd(n,lun)(1:6))) then
712  card=cardi2
713  card( 3:10)=tabd(n,lun)( 7:14)
714  ic = 14
715  ! Get the list of child mnemonics for this Table D descriptor, and then add each one (including any replication tags)
716  ! to the sequence definition card for this Table D descriptor.
717  call nemtbd(lun,n,nseq,nem(1,1),irp(1,1),krp(1,1))
718  if(nseq>0) then
719  do nc=1,nseq
720  cmstr=' '
721  icms=0
722  call strsuc(nem(nc,1),wrk2,nch)
723  if(irp(nc,1)/=0) then
724  ! Add the opening replication tag.
725  icms=icms+1
726  cmstr(icms:icms)=reps(irp(nc,1))
727  end if
728  cmstr(icms+1:icms+nch)=wrk2(1:nch)
729  icms=icms+nch
730  if(irp(nc,1)/=0) then
731  ! Add the closing replication tag.
732  icms=icms+1
733  cmstr(icms:icms)=reps(irp(nc,1)+5)
734  end if
735  if(krp(nc,1)/=0) then
736  ! Add the fixed replication count.
737  wrk1=' '
738  write (wrk1,'(I3)') krp(nc,1)
739  call strsuc(wrk1,wrk2,nch)
740  cmstr(icms+1:icms+nch)=wrk2(1:nch)
741  icms=icms+nch
742  end if
743  ! Will this child (and its replication tags, if any) fit into the current sequence definition card? If not, then
744  ! write out (to ldxot) the current card and initialize a new one to hold this child.
745  if(ic>(79-icms)) then
746  write (ldxot,'(A)') card
747  card=cardi2
748  card( 3:10)=tabd(n,lun)( 7:14)
749  ic = 14
750  end if
751  card(ic:ic+icms-1)=cmstr(1:icms)
752  ! Note that we want to leave 2 blank spaces between each child within the sequence definition card, to improve
753  ! readability.
754  ic=ic+icms+2
755  end do
756  write (ldxot,'(A)') card
757  write (ldxot,'(A)') cardi2
758  end if
759  end if
760  end do
761 
762  ! Create and write out (to ldxot) the header cards for the element definition section.
763 
764  write (ldxot,'(A)') cardi4
765 
766  card=cardi3
767  card( 3:10)='MNEMONIC'
768  card(14:17)='SCAL'
769  card(21:29)='REFERENCE'
770  card(35:37)='BIT'
771  card(41:45)='UNITS'
772  write (ldxot,'(A)') card
773 
774  card=cardi4
775  card(12:12)='|'
776  card(19:19)='|'
777  card(33:33)='|'
778  card(39:39)='|'
779  card(66:66)='|'
780  write (ldxot,'(A)') card
781 
782  ! Create and write out (to ldxot) the Table B element definition cards.
783 
784  write (ldxot,'(A)') cardi3
785 
786  do n=1,ntbb(lun)
787  if(.not.tbskip(tabb(n,lun)(1:6))) then
788  card=cardi3
789  card( 3:10)=tabb(n,lun)( 7:14)
790  card(41:64)=tabb(n,lun)(71:94)
791  ! Add the scale factor.
792  call strsuc(tabb(n,lun)(96:98),wrk2,nch)
793  card(17-nch+1:17)=wrk2
794  if(tabb(n,lun)(95:95)=='-') card(17-nch:17-nch)='-'
795  ! Add the reference value.
796  call strsuc(tabb(n,lun)(100:109),wrk3,nch)
797  card(31-nch+1:31)=wrk3
798  if(tabb(n,lun)(99:99)=='-') card(31-nch:31-nch)='-'
799  ! Add the bit width.
800  call strsuc(tabb(n,lun)(110:112),wrk2,nch)
801  card(37-nch+1:37)=wrk2
802  write (ldxot,'(a)') card
803  end if
804  end do
805 
806  write (ldxot,'(A)') cardi3
807 
808  ! Create and write out (to ldxot) the closing card.
809 
810  card=cardi4
811  card( 1: 1)='`'
812  card(80:80)=''''
813  write (ldxot,'(A)') card
814 
815  return
816 end subroutine dxdump
817 
828 recursive subroutine getabdb(lunit,tabdb,itab,jtab)
829 
830  use modv_vars, only: im8b
831 
832  use moda_tababd
833  use moda_nmikrp
834 
835  implicit none
836 
837  integer, intent(in) :: lunit, itab
838  integer, intent(out) :: jtab
839  integer my_lunit, my_itab, lun, il, im, i, j, k, nseq
840 
841  character*128, intent(out) :: tabdb(*)
842  character*8 nemo
843 
844  ! Check for I8 integers
845 
846  if(im8b) then
847  im8b=.false.
848  call x84(lunit,my_lunit,1)
849  call x84(itab,my_itab,1)
850  call getabdb(my_lunit,tabdb,my_itab,jtab)
851  call x48(jtab,jtab,1)
852  im8b=.true.
853  return
854  endif
855 
856  jtab = 0
857 
858  ! Make sure the file is open
859 
860  call status(lunit,lun,il,im)
861  if(il==0) return
862 
863  ! Write out the Table D entries for this file
864 
865  do i=1,ntbd(lun)
866  nemo = tabd(i,lun)(7:14)
867  call nemtbd(lun,i,nseq,nem(1,1),irp(1,1),krp(1,1))
868  do j=1,nseq,10
869  jtab = jtab+1
870  if(jtab<=itab) then
871  write(tabdb(jtab),fmt='(A,A8,10(1X,A10))') 'D ', nemo, (nem(k,1),k=j,min(j+9,nseq))
872  endif
873  enddo
874  enddo
875 
876  ! Add the Table B entries
877 
878  do i=1,ntbb(lun)
879  jtab = jtab+1
880  if(jtab<=itab) then
881  write(tabdb(jtab),fmt='(A,A8,1X,A42)') 'B ', tabb(i,lun)(7:14), tabb(i,lun)(71:112)
882  endif
883  enddo
884 
885  return
886 end subroutine getabdb
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:829
recursive subroutine dxdump(lunit, ldxot)
Print a copy of the DX BUFR table associated with a specified Fortran logical unit.
Definition: dumpdata.F90:580
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:1346
subroutine nemtab(lun, nemo, idn, tab, iret)
Get information about a descriptor, based on a mnemonic.
Definition: fxy.F90:432
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:220
integer function isize(num)
Compute the number of characters needed to encode an integer as a string.
Definition: misc.F90:408
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