30 use modv_vars,
only: iprt
34 integer,
intent(in) :: lunit, lun, lundx
35 integer lud, ildx, imdx
41 call status(lundx,lud,ildx,imdx)
45 if (lunit==lundx)
then
48 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
49 write ( unit=errstr, fmt=
'(A,A,I3,A)' )
'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ', &
50 'INPUT BUFR FILE IN UNIT ', lundx,
' INTO INTERNAL ARRAYS'
52 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
60 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
61 write ( unit=errstr, fmt=
'(A,A,I3,A,A,I3)' )
'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ', &
62 'ARRAYS ASSOC. W/ INPUT UNIT ', lundx,
' TO THOSE ASSOC. W/ UNIT ', lunit
64 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
72 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
73 write ( unit=errstr, fmt=
'(A,A,I3,A,A,I3)' )
'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ', &
74 'ARRAYS ASSOC. W/ OUTPUT UNIT ', lundx,
' TO THOSE ASSOC. W/ UNIT ', lunit
76 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
84 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
85 write ( unit=errstr, fmt=
'(A,A,I3,A)' )
'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ', &
86 'USER-SUPPLIED TEXT FILE IN UNIT ', lundx,
' INTO INTERNAL ARRAYS'
88 call errwrt(
'++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
94 call bort(
'BUFRLIB: READDX - CANNOT DETERMINE SOURCE OF INPUT DICTIONARY TABLE')
124 use modv_vars,
only: iprt
130 integer,
intent(in) :: lunit, lun
131 integer ict, ier, idxmsg, iupbs3
144 do while ( .not. done )
146 if ( ier == -1 )
then
152 else if ( ier == -2 )
then
153 call bort(
'BUFRLIB: RDBFDX - ERROR READING A BUFR DICTIONARY MESSAGE')
154 else if ( idxmsg(
mgwa) /= 1 )
then
159 else if ( iupbs3(
mgwa,
'NSUB') == 0 )
then
170 if ( iprt >= 2 )
then
171 call errwrt(
'+++++++++++++++++++++++++++++++++++++++++++++++++')
172 write ( unit=errstr, fmt=
'(A,I3,A)' )
'BUFRLIB: RDBFDX - STORED NEW DX TABLE CONSISTING OF (', ict,
') MESSAGES;'
174 errstr =
'WILL APPLY THIS TABLE TO ALL SUBSEQUENT DATA IN FILE UNTIL NEXT DX TABLE IS FOUND'
176 call errwrt(
'+++++++++++++++++++++++++++++++++++++++++++++++++')
202 integer,
intent(in) :: lundx, lun
203 integer ios, iret, n, numbck, nemock, igetntbi
205 character*128 bort_str1
206 character*156 bort_str2
209 character*6 numb, nmb2
220 read(lundx,
'(A80)', iostat = ios) card
226 if(card(1: 1)==
'*') cycle
227 if(card(3:10)==
'--------') cycle
228 if(card(3:10)==
' ') cycle
229 if(card(3:10)==
'MNEMONIC') cycle
230 if(card(3:10)==
'TABLE D') cycle
231 if(card(3:10)==
'TABLE B') cycle
233 if(card(12:12)==
'|' .and. card(21:21)==
'|')
then
239 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
240 write(bort_str2,
'(18X,"MNEMONIC ",A," IN USER DICTIONARY HAS INVALID CHARACTERS")') nemo
241 call bort2(bort_str1,bort_str2)
245 if(nmb2(1:1)==
'A') nmb2(1:1) =
'3'
248 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
249 write(bort_str2,
'(18X,"DESCRIPTOR NUMBER ",A," IN USER '// &
250 'DICTIONARY HAS AN INVALID FIRST CHARACTER (F VALUE) - MUST BE A, 0 OR 3")') numb
251 call bort2(bort_str1,bort_str2)
254 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
255 write(bort_str2,
'(18X,"DESCRIPTOR NUMBER ",A," IN USER '// &
256 'DICTIONARY HAS NON-NUMERIC VALUES IN CHARACTERS 2-6 (X AND Y VALUES)")') numb
257 call bort2(bort_str1,bort_str2)
260 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
261 write(bort_str2,
'(18X,"DESCRIPTOR NUMBER ",A," IN USER '// &
262 'DICTIONARY HAS INVALID NUMBER IN CHARACTERS 2-3 (X VALUE) - MUST BE BETWEEN 00 AND 63")') numb
263 call bort2(bort_str1,bort_str2)
266 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
267 write(bort_str2,
'(18X,"DESCRIPTOR NUMBER ",A," IN USER '// &
268 'DICTIONARY HAS INVALID NUMBER IN CHARACTERS 4-6 (Y VALUE) - MUST BE BETWEEN 000 AND 255")') numb
269 call bort2(bort_str1,bort_str2)
272 if(numb(1:1)==
'A')
then
274 n = igetntbi( lun,
'A' )
275 call stntbia ( n, lun, numb, nemo, card(23:) )
276 if (
idna(n,lun,1) == 11 )
then
277 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
278 write(bort_str2,
'(18X,"USER-DEFINED MESSAGE TYPE ""011"" IS RESERVED FOR DICTIONARY MESSAGES")')
279 call bort2(bort_str1,bort_str2)
285 if(numb(1:1)==
'0')
then
287 call stntbi ( igetntbi(lun,
'B'), lun, numb, nemo, card(23:) )
291 if(numb(1:1)==
'3')
then
293 call stntbi ( igetntbi(lun,
'D'), lun, numb, nemo, card(23:) )
297 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
298 write(bort_str2,
'(18X,"DESCRIPTOR NUMBER ",A," IN USER '// &
299 'DICTIONARY HAS AN INVALID FIRST CHARACTER (F VALUE) - MUST BE A, 0 OR 3")') numb
300 call bort2(bort_str1,bort_str2)
304 if(card(12:12)==
'|' .and. card(19:19)/=
'|')
then
310 if(card(12:12)==
'|' .and. card(19:19)==
'|')
then
317 write(bort_str1,
'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
318 write(bort_str2,
'(18X,"THIS CARD HAS A BAD FORMAT - IT IS NOT RECOGNIZED BY THIS SUBROUTINE")')
319 call bort2(bort_str1,bort_str2)
334 use modv_vars,
only: reps, idnr
338 integer,
intent(in) :: lun
339 integer ntag, idn, jdn, iseq, irep, i, j, n, itab, iret, ier, numr, nemock
340 integer,
parameter :: maxtgs = 250, maxtag = 13
342 character*128 bort_str1, bort_str2
344 character*80,
intent(in) :: card
345 character*(maxtag) atag, tags(maxtgs)
346 character*8 nemo, nema, nemb
347 character*6 adn30, clemon
361 call nemtab(lun,nemo,idn,tab,iseq)
363 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
364 write(bort_str2,
'(18X,"MNEMONIC ",A," IS NOT A TABLE D ENTRY (UNDEFINED, TAB=",A,")")') nemo,tab
365 call bort2(bort_str1,bort_str2)
367 call parstr(seqs,tags,maxtgs,ntag,
' ',.true.)
369 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
370 write(bort_str2,
'(18X,"TABLE D SEQUENCE (PARENT) MNEMONIC ",A," DOES NOT CONTAIN ANY CHILD MNEMONICS")') nemo
371 call bort2(bort_str1,bort_str2)
381 if(atag(1:1)==reps(i))
then
386 if(atag(j:j)==reps(i+5))
then
391 call strnum(atag(j+1:maxtag),numr,ier)
392 if(i==1 .and. numr<=0)
then
393 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
394 write(bort_str2,
'(9X,"TBL D MNEM. ",A," CONTAINS REG. REPL. '// &
395 'CHILD MNEM. ",A," W/ INVALID # OF REPLICATIONS (",I3,") AFTER 2ND QUOTE")') nemo,tags(n),numr
396 call bort2(bort_str1,bort_str2)
398 if(i==1 .and. numr>255)
then
399 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
400 write(bort_str2,
'(18X,"TBL D MNEM. ",A," CONTAINS REG. REPL. '// &
401 'CHILD MNEM. ",A," W/ # OF REPLICATIONS (",I3,") > LIMIT OF 255")') nemo,tags(n),numr
402 call bort2(bort_str1,bort_str2)
404 if(i/=1 .and. numr/=0)
then
405 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
406 write(bort_str2,
'(18X,"TBL D MNEM. ",A," CONTAINS DELAYED REPL. '// &
407 'CHILD MNEM. ",A," W/ # OF REPL. (",I3,") SPECIFIED - A NO-NO")') nemo,tags(n),numr
408 call bort2(bort_str1,bort_str2)
415 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
416 write(bort_str2,
'(18X,"TABLE D SEQUENCE (PARENT) MNEMONIC ",A,'// &
417 '" CONTAINS A BADLY FORMED CHILD MNEMONIC ",A)') nemo,tags(n)
418 call bort2(bort_str1,bort_str2)
426 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
427 write(bort_str2,
'(18X,"TABLE D (PARENT) MNEMONIC ",A," CONTAINS'// &
428 ' A CHILD MNEMONIC ",A," NOT BETWEEN 1 & 8 CHARACTERS")') nemo,tags(n)
429 call bort2(bort_str1,bort_str2)
432 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
433 write(bort_str2,
'(18X,"TABLE D (PARENT) MNEMONIC ",A," CONTAINS'// &
434 ' A CHILD MNEMONIC ",A," WITH INVALID CHARACTERS")') nemo,tags(n)
435 call bort2(bort_str1,bort_str2)
437 call nemtab(lun,atag,idn,tab,iret)
442 if(tab==
'B' .and. irep/=0)
then
443 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
444 write(bort_str2,
'(18X,"TABLE D (PARENT) MNEMONIC ",A," CONTAINS'// &
445 ' A REPLICATED CHILD TABLE B MNEMONIC ",A," - A NO-NO")') nemo,tags(n)
446 call bort2(bort_str1,bort_str2)
448 if(atag(1:1)==
'.')
then
453 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
454 write(bort_str2,
'(18X,"TBL D (PARENT) MNEM. ",A," CONTAINS A '// &
455 '''FOLLOWING VALUE'' MNEMONIC WHICH IS LAST IN THE STRING")') nemo
456 call bort2(bort_str1,bort_str2)
458 nemb = tags(n+1)(1:8)
459 call numtab(lun,idn,nema,tab,itab)
460 call nemtab(lun,nemb,jdn,tab,iret)
463 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
464 write(bort_str2,
'(18X,"TBL D (PARENT) MNEM. ",A," CONTAINS AN '// &
465 'INVALID ''FOLLOWING VALUE'' MNEMONIC ",A,"(SHOULD BE ",A,")")') nemo,tags(n),nema
466 call bort2(bort_str1,bort_str2)
469 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
470 write(bort_str2,
'(18X,"TBL D (PARENT) MNEM. ",A,", THE MNEM. ",'// &
471 'A," FOLLOWING A ''FOLLOWING VALUE'' MNEM. IS NOT A TBL B ENTRY")') nemo,nemb
472 call bort2(bort_str1,bort_str2)
476 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
477 write(bort_str2,
'(18X,"TABLE D SEQUENCE (PARENT) MNEMONIC ",A,'// &
478 '" CONTAINS A CHILD MNEMONIC ",A," NOT FOUND IN ANY TABLE")') nemo,tags(n)
479 call bort2(bort_str1,bort_str2)
483 if(irep>0)
call pktdd(iseq,lun,idnr(irep)+numr,iret)
485 clemon = adn30(idnr(irep)+numr,6)
486 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
487 write(bort_str2,
'(9X,"TBL D (PARENT) MNEM. ",A," - BAD RETURN '// &
488 'FROM PKTDD TRYING TO STORE REPL. DESC. ",A,", SEE PREV. WARNING MSG")') nemo,clemon
489 call bort2(bort_str1,bort_str2)
491 call pktdd(iseq,lun,idn,iret)
493 write(bort_str1,
'("BUFRLIB: SEQSDX - CARD READ IN IS: ",A)') card
494 write(bort_str2,
'(9X,"TBL D (PARENT) MNEM. ",A," - BAD RETURN '// &
495 'FROM PKTDD TRYING TO STORE CHILD MNEM. ",A,", SEE PREV. WARNING MSG")') nemo,tags(n)
496 call bort2(bort_str1,bort_str2)
519 integer,
intent(in) :: lun
520 integer idsn, iele, iret
522 character*128 bort_str1, bort_str2
523 character*80,
intent(in) :: card
525 character*11 refr, refr_orig
527 character*4 scal, scal_orig
528 character*3 bitw, bitw_orig
545 call nemtab(lun,nemo,idsn,tab,iele)
547 write(bort_str1,
'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
548 write(bort_str2,
'(18X,"MNEMONIC ",A," IS NOT A TABLE B ENTRY (UNDEFINED, TAB=",A,")")') nemo,tab
549 call bort2(bort_str1,bort_str2)
556 write(bort_str1,
'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
557 write(bort_str2,
'(18X,"UNITS FIELD IS EMPTY")')
558 call bort2(bort_str1,bort_str2)
560 tabb(iele,lun)(71:94) = unit
563 call jstnum(scal,sign,iret)
565 write(bort_str1,
'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
566 write(bort_str2,
'(18X,"PARSED SCALE VALUE (=",A,") IS NOT NUMERIC")') scal_orig
567 call bort2(bort_str1,bort_str2)
569 tabb(iele,lun)(95:95) = sign
570 tabb(iele,lun)(96:98) = scal(1:3)
573 call jstnum(refr,sign,iret)
575 write(bort_str1,
'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
576 write(bort_str2,
'(18X,"PARSED REFERENCE VALUE (=",A,") IS NOT NUMERIC")') refr_orig
577 call bort2(bort_str1,bort_str2)
579 tabb(iele,lun)( 99: 99) = sign
580 tabb(iele,lun)(100:109) = refr(1:10)
583 call jstnum(bitw,sign,iret)
584 if(iret/=0 .or. sign==
'-')
then
585 write(bort_str1,
'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
586 write(bort_str2,
'(18X,"PARSED BIT WIDTH VALUE (=",A,") IS NOT NUMERIC")') bitw_orig
587 call bort2(bort_str1,bort_str2)
589 tabb(iele,lun)(110:112) = bitw
605 use modv_vars,
only: idnr, fxy_fbit, fxy_sbyct, fxy_drf16, fxy_drf8, fxy_drf1
611 integer,
intent(in) :: lun, ioi
612 integer ninib, ninid, n, i, iret, ifxy
614 character*8 inib(6,5),inid(5)
617 data inib /
'------',
'BYTCNT ',
'BYTES ',
'+0',
'+0',
'16', &
618 '------',
'BITPAD ',
'NONE ',
'+0',
'+0',
'1 ', &
619 fxy_drf1,
'DRF1BIT ',
'NUMERIC',
'+0',
'+0',
'1 ', &
620 fxy_drf8,
'DRF8BIT ',
'NUMERIC',
'+0',
'+0',
'8 ', &
621 fxy_drf16,
'DRF16BIT',
'NUMERIC',
'+0',
'+0',
'16'/
645 call pktdd(i,lun,0,iret)
652 inib(1,1) = fxy_sbyct
657 idnb(i,lun) = ifxy(inib(1,i))
658 tabb(i,lun)( 1: 6) = inib(1,i)(1:6)
659 tabb(i,lun)( 7: 70) = inib(2,i)
660 tabb(i,lun)( 71: 94) = inib(3,i)
661 tabb(i,lun)( 95: 98) = inib(4,i)(1:4)
662 tabb(i,lun)( 99:109) = inib(5,i)
663 tabb(i,lun)(110:112) = inib(6,i)(1:3)
668 idnd(n,lun) = idnr(i)
669 tabd(n,lun)(1: 6) = adn30(idnr(i),6)
670 tabd(n,lun)(7:70) = inid(i)
671 call pktdd(n,lun,idnr(1),iret)
672 call pktdd(n,lun,idnr(i+5),iret)
690 subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd)
692 use modv_vars,
only: mxmsgld4, mtv, nby0, nby1, nby2, nby5, bmostr, idxv
696 integer,
intent(out) :: mbay(*), mbyt, mb4, mba, mbb, mbd
697 integer nxstr, ldxa, ldxb, ldxd, ld30, mtyp, msbt, mbit, ih, id, im, iy, i, nsub, idxs, ldxs, &
700 character*128 bort_str
703 common /dxtab/ nxstr(10), ldxa(10), ldxb(10), ldxd(10), ld30(10), dxstr(10)
725 len3 = 7 + nxstr(idxs) + 1
727 mbyt = nby0+nby1+nby2+len3+nby4+nby5
729 if(mod(len3,2)/=0)
call bort (
'BUFRLIB: DXMINI - LENGTH OF SECTION 3 IS NOT A MULTIPLE OF 2')
733 call pkc(bmostr , 4 , mbay,mbit)
734 call pkb( mbyt , 24 , mbay,mbit)
735 call pkb( 3 , 8 , mbay,mbit)
739 call pkb( nby1 , 24 , mbay,mbit)
740 call pkb( 0 , 8 , mbay,mbit)
741 call pkb( 3 , 8 , mbay,mbit)
742 call pkb( 7 , 8 , mbay,mbit)
743 call pkb( 0 , 8 , mbay,mbit)
744 call pkb( 0 , 8 , mbay,mbit)
745 call pkb( mtyp , 8 , mbay,mbit)
746 call pkb( msbt , 8 , mbay,mbit)
747 call pkb( mtv , 8 , mbay,mbit)
748 call pkb( idxv , 8 , mbay,mbit)
749 call pkb( iy , 8 , mbay,mbit)
750 call pkb( im , 8 , mbay,mbit)
751 call pkb( id , 8 , mbay,mbit)
752 call pkb( ih , 8 , mbay,mbit)
753 call pkb( 0 , 8 , mbay,mbit)
754 call pkb( 0 , 8 , mbay,mbit)
758 call pkb( len3 , 24 , mbay,mbit)
759 call pkb( 0 , 8 , mbay,mbit)
760 call pkb( 1 , 16 , mbay,mbit)
761 call pkb( 2**7 , 8 , mbay,mbit)
763 call pkb(iupm(dxstr(idxs)(i:i),8),8,mbay,mbit)
765 call pkb( 0 , 8 , mbay,mbit)
770 call pkb( nby4 , 24 , mbay,mbit)
771 call pkb( 0 , 8 , mbay,mbit)
773 call pkb( 0 , 8 , mbay,mbit)
775 call pkb( 0 , 8 , mbay,mbit)
777 call pkb( 0 , 8 , mbay,mbit)
779 if(mbit/8+nby5/=mbyt)
then
780 write(bort_str,
'("BUFRLIB: DXMINI - NUMBER OF BYTES STORED FOR '// &
781 'A MESSAGE (",I6,") IS NOT THE SAME AS FIRST CALCULATED, MBYT (",I6)') mbit/8+nby5,mbyt
803 integer,
intent(in) :: lunit, lun, lundx
805 character*128 bort_str
809 if(lunit==lundx)
then
810 write(bort_str,
'("BUFRLIB: WRITDX - FILES CONTAINING BUFR DATA '// &
811 'AND DICTIONARY TABLE CANNOT BE THE SAME (HERE BOTH SHARE FORTRAN UNIT NUMBER ",I3,")")') lunit
817 call readdx(lunit,lun,lundx)
841 use modv_vars,
only: im8b, idxv
849 integer,
intent(in) :: lundx, lunot
850 integer nxstr, ldxa, ldxb, ldxd, ld30, my_lundx, my_lunot, ldx, lot, il, im, lda, ldb, ldd, l30, nseq, &
851 mbit, mbyt, mby4, mbya, mbyb, mbyd, i, j, jj, idn, lend, len0, len1, len2, l3, l4, l5,
iupb,
iupm,
bort_target_set
853 common /dxtab/ nxstr(10), ldxa(10), ldxb(10), ldxd(10), ld30(10), dxstr(10)
864 call x84(lundx,my_lundx,1)
865 call x84(lunot,my_lunot,1)
866 call wrdxtb(my_lundx,my_lunot)
881 call status(lunot,lot,il,im)
882 if(il==0)
call bort(
'BUFRLIB: WRDXTB - OUTPUT BUFR FILE IS CLOSED, IT MUST BE OPEN FOR OUTPUT')
883 if(il<0)
call bort(
'BUFRLIB: WRDXTB - OUTPUT BUFR FILE IS OPEN FOR INPUT, IT MUST BE OPEN FOR OUTPUT')
885 call status(lundx,ldx,il,im)
886 if(il==0)
call bort(
'BUFRLIB: WRDXTB - DX TABLE FILE IS CLOSED, IT MUST BE OPEN')
890 if(lundx/=lunot)
call cpbfdx(ldx,lot)
942 nseq =
iupm(
tabd(i,lot)(ldd+1:ldd+1),8)
943 lend = ldd+1 + l30*nseq
973 mbit = (len0+len1+len2+4)*8
988 use modv_vars,
only: maxcd, idxv
994 integer,
intent(in) :: lun, mesg(*)
995 integer nxstr, ldxa, ldxb, ldxd, ld30, ldxbd(10), ldxbe(10), ja, jb, idxs, i3, i, j, n, nd, ndd, idn, &
996 jbit, len0, len1, len2, len3, l4, l5, lda, ldb, ldd, ldbd, ldbe, l30, ia, la, ib, lb, id, ld, iret, &
997 ifxy, iupb, iupbs01, igetntbi, idn30
999 character*128 bort_str
1000 character*128 tabb1, tabb2
1006 character*6 numb, cidn
1008 common /dxtab/ nxstr(10), ldxa(10), ldxb(10), ldxd(10), ld30(10), dxstr(10)
1010 data ldxbd /38, 70, 8*0/
1011 data ldxbe /42, 42, 8*0/
1014 ja(i) = ia+1+lda*(i-1)
1015 jb(i) = ib+1+ldb*(i-1)
1019 idxs = iupbs01(mesg,
'MSBT')+1
1020 if(idxs>idxv+1) idxs = iupbs01(mesg,
'MTVL')+1
1021 if(ldxa(idxs)==0 .or. ldxb(idxs)==0 .or. ldxd(idxs)==0)
call bort(
'BUFRLIB: STBFDX - UNEXPECTED DICTIONARY '// &
1022 'MESSAGE SUBTYPE OR LOCAL VERSION NUMBER (E.G., L.V.N. HIGHER THAN KNOWN)')
1024 call getlens(mesg,3,len0,len1,len2,len3,l4,l5)
1028 call upc(dxcmp,nxstr(idxs),mesg,jbit,.false.)
1029 if(dxcmp/=dxstr(idxs))
call bort(
'BUFRLIB: STBFDX - UNEXPECTED DICTIONARY MESSAGE CONTENTS')
1041 la = iupb(mesg,ia,8)
1043 lb = iupb(mesg,ib,8)
1045 ld = iupb(mesg,id,8)
1050 n = igetntbi(lun,
'A')
1052 call upc(
taba(n,lun),lda,mesg,jbit,.true.)
1053 numb =
' '//
taba(n,lun)(1:3)
1054 nemo =
taba(n,lun)(4:11)
1055 cseq =
taba(n,lun)(13:67)
1056 call stntbia(n,lun,numb,nemo,cseq)
1062 n = igetntbi(lun,
'B')
1064 call upc(tabb1,ldbd,mesg,jbit,.true.)
1065 jbit = 8*(jb(i)+ldbd-1)
1066 call upc(tabb2,ldbe,mesg,jbit,.true.)
1067 tabb(n,lun) = tabb1(1:ldxbd(idxv+1))//tabb2(1:ldxbe(idxv+1))
1068 numb =
tabb(n,lun)(1:6)
1069 nemo =
tabb(n,lun)(7:14)
1070 call nenubd(nemo,numb,lun)
1071 idnb(n,lun) = ifxy(numb)
1072 unit =
tabb(n,lun)(71:94)
1074 tabb(n,lun)(71:94) = unit
1081 n = igetntbi(lun,
'D')
1083 call upc(
tabd(n,lun),ldd,mesg,jbit,.true.)
1084 numb =
tabd(n,lun)(1:6)
1085 nemo =
tabd(n,lun)(7:14)
1086 call nenubd(nemo,numb,lun)
1087 idnd(n,lun) = ifxy(numb)
1088 nd = iupb(mesg,id+ldd+1,8)
1090 write(bort_str,
'("BUFRLIB: STBFDX - NUMBER OF DESCRIPTORS IN '// &
1091 'TABLE D ENTRY ",A," IN BUFR TABLE (",I4,") EXCEEDS THE LIMIT (",I4,")")') nemo,nd,maxcd
1095 ndd = id+ldd+2 + (j-1)*l30
1097 call upc(cidn,l30,mesg,jbit,.true.)
1098 idn = idn30(cidn,l30)
1099 call pktdd(n,lun,idn,iret)
1100 if(iret<0)
call bort(
'BUFRLIB: STBFDX - BAD RETURN FROM BUFRLIB ROUTINE PKTDD, SEE PREVIOUS WARNING MESSAGE')
1102 id = id+ldd+1 + nd*l30
1103 if(iupb(mesg,id+1,8)==0) id = id+1
1119 integer function idxmsg( mesg )
result( iret )
1123 integer,
intent(in) :: mesg(*)
1129 if ( (
iupbs01(mesg,
'MTYP')==11) .and. &
1155 integer,
intent(in) :: lun
1158 character,
intent(in) :: ctb
1159 character*128 bort_str
1161 if ( ctb ==
'A' )
then
1162 iret =
ntba(lun) + 1
1164 else if ( ctb ==
'B' )
then
1165 iret =
ntbb(lun) + 1
1168 iret =
ntbd(lun) + 1
1171 if ( iret > imax )
then
1172 write(bort_str,
'("BUFRLIB: IGETNTBI - NUMBER OF INTERNAL TABLE",A1," ENTRIES EXCEEDS THE LIMIT (",I4,")")') ctb, imax
1199 integer,
intent(in) :: lun
1200 integer,
intent(out) :: mtyp, msbt, inod
1203 character*(*),
intent(in) :: nemo
1204 character*128 bort_str
1211 if(
taba(i,lun)(4:11)==nemo)
then
1212 mtyp =
idna(i,lun,1)
1213 msbt =
idna(i,lun,2)
1215 if(mtyp<0 .or. mtyp>255)
then
1216 write(bort_str,
'("BUFRLIB: NEMTBAX - INVALID MESSAGE TYPE (",I4,") RETURNED FOR MENMONIC ",A)') mtyp, nemo
1219 if(msbt<0 .or. msbt>255)
then
1220 write(bort_str,
'("BUFRLIB: NEMTBAX - INVALID MESSAGE SUBTYPE (",I4,") RETURNED FOR MENMONIC ",A)') msbt, nemo
1247 integer,
intent(in) :: lun
1248 integer,
intent(out) :: mtyp, msbt, inod
1250 character*(*),
intent(in) :: nemo
1251 character*128 bort_str
1255 call nemtbax(lun,nemo,mtyp,msbt,inod)
1257 write(bort_str,
'("BUFRLIB: NEMTBA - CAN''T FIND MNEMONIC ",A)') nemo
1274 subroutine nemtbb(lun,itab,unit,iscl,iref,ibit)
1280 integer,
intent(in) :: lun, itab
1281 integer,
intent(out) :: iscl, iref, ibit
1284 character*128 bort_str
1285 character*24,
intent(out) :: unit
1288 if(itab<=0 .or. itab>
ntbb(lun))
then
1289 write(bort_str,
'("BUFRLIB: NEMTBB - ITAB (",I7,") NOT FOUND IN TABLE B")') itab
1295 idn =
idnb(itab,lun)
1296 nemo =
tabb(itab,lun)( 7:14)
1297 unit =
tabb(itab,lun)(71:94)
1298 call strnum(
tabb(itab,lun)( 95: 98),iscl,ierns)
1299 call strnum(
tabb(itab,lun)( 99:109),iref,ierns)
1300 call strnum(
tabb(itab,lun)(110:112),ibit,ierns)
1304 if(unit(1:5)/=
'CCITT' .and. ibit>32)
then
1305 write(bort_str,
'("BUFRLIB: NEMTBB - BIT WIDTH FOR NON-CHARACTER TABLE B MNEMONIC ",A," (",I7,") IS > 32")') nemo,ibit
1308 if(unit(1:5)==
'CCITT' .and. mod(ibit,8)/=0)
then
1309 write(bort_str,
'("BUFRLIB: NEMTBB - BIT WIDTH FOR CHARACTER TABLE B MNEMONIC ",A," (",I7,") IS NOT A MULTIPLE OF 8")') &
1342 subroutine nemtbd(lun,itab,nseq,nems,irps,knts)
1344 use modv_vars,
only: maxcd
1350 integer,
intent(in) :: lun, itab
1351 integer,
intent(out) :: nseq, irps(*), knts(*)
1352 integer i, j, ndsc, idsc, iret
1354 character*128 bort_str
1355 character*8,
intent(out) :: nems(*)
1356 character*8 nemo, nemt, nemf
1359 if(itab<=0 .or. itab>
ntbd(lun))
then
1360 write(bort_str,
'("BUFRLIB: NEMTBD - ITAB (",I7,") NOT FOUND IN TABLE D")') itab
1376 nemo =
tabd(itab,lun)(7:14)
1377 idsc =
idnd(itab,lun)
1378 call uptdd(itab,lun,0,ndsc)
1383 if(nseq+1>maxcd)
then
1384 write(bort_str,
'("BUFRLIB: NEMTBD - THERE ARE MORE THAN '// &
1385 '(",I4,") DESCRIPTORS (THE LIMIT) IN TABLE D SEQUENCE MNEMONIC ",A)') maxcd, nemo
1388 call uptdd(itab,lun,j,idsc)
1389 call numtab(lun,idsc,nemt,tab,iret)
1394 knts(nseq+1) = abs(iret)
1399 elseif(tab==
'F')
then
1402 elseif(tab==
'D'.or.tab==
'C')
then
1405 elseif(tab==
'B')
then
1407 if((nemt(1:1)==
'.').and.(j<ndsc))
then
1409 call uptdd(itab,lun,j+1,idsc)
1410 call numtab(lun,idsc,nemf,tab,iret)
1442 recursive subroutine nemdefs ( lunit, nemo, celem, cunit, iret )
1446 use modv_vars,
only: im8b
1452 integer,
intent(in) :: lunit
1453 integer,
intent(out) :: iret
1456 character*(*),
intent(in) :: nemo
1457 character*(*),
intent(out) :: celem, cunit
1467 call x84 ( lunit, my_lunit, 1 )
1468 call nemdefs ( my_lunit, nemo, celem, cunit, iret )
1469 call x48 ( iret, iret, 1 )
1477 call strsuc( nemo, cnemo, lcn )
1479 ls = min(len(celem),55)
1480 celem(1:ls) = ccelem(1:ls)
1481 ls = min(len(cunit),24)
1482 cunit(1:ls) = ccunit(1:ls)
1491 call status( lunit, lun, il, im )
1492 if ( il == 0 )
return
1496 call nemtab( lun, nemo, idn, tab, iloc )
1497 if ( ( iloc == 0 ) .or. ( tab /=
'B' ) )
return
1502 ls = min(len(celem),55)
1503 celem(1:ls) =
tabb(iloc,lun)(16:15+ls)
1506 ls = min(len(cunit),24)
1507 cunit(1:ls) =
tabb(iloc,lun)(71:70+ls)
1534 character,
intent(in) :: nemo*8, numb*6
1535 character*128 bort_str
1537 integer,
intent(in) :: lun
1541 if(numb==
tabb(n,lun)(1:6))
then
1542 write(bort_str,
'("BUFRLIB: NENUBD - TABLE B FXY VALUE (",A,") HAS ALREADY BEEN DEFINED (DUPLICATE)")') numb
1545 if(nemo==
tabb(n,lun)(7:14))
then
1546 write(bort_str,
'("BUFRLIB: NENUBD - TABLE B MNEMONIC (",A,") HAS ALREADY BEEN DEFINED (DUPLICATE)")') nemo
1552 if(numb==
tabd(n,lun)(1:6))
then
1553 write(bort_str,
'("BUFRLIB: NENUBD - TABLE D FXY VALUE (",A,") HAS ALREADY BEEN DEFINED (DUPLICATE)")') numb
1556 if(nemo==
tabd(n,lun)(7:14))
then
1557 write(bort_str,
'("BUFRLIB: NENUBD - TABLE D MNEMONIC (",A,") HAS ALREADY BEEN DEFINED (DUPLICATE)")') nemo
1580 integer,
intent(in) :: n, lun
1581 integer i, mtyp, msbt
1583 character*(*),
intent(in) :: numb, nemo, celsq
1584 character*128 bort_str
1589 if(numb(4:6)==
taba(i,lun)(1:3))
then
1590 write(bort_str,
'("BUFRLIB: STNTBIA - TABLE A FXY VALUE (",A,") HAS ALREADY BEEN DEFINED (DUPLICATE)")') numb
1593 if(nemo(1:8)==
taba(i,lun)(4:11))
then
1594 write(bort_str,
'("BUFRLIB: STNTBIA - TABLE A MNEMONIC (",A,") HAS ALREADY BEEN DEFINED (DUPLICATE)")') nemo
1601 taba(n,lun)(1:3) = numb(4:6)
1602 taba(n,lun)(4:11) = nemo(1:8)
1603 taba(n,lun)(13:67) = celsq(1:55)
1607 if ( verify( nemo(3:8),
'1234567890' ) == 0 )
then
1609 read ( nemo,
'(2X,2I3)') mtyp, msbt
1610 idna(n,lun,1) = mtyp
1611 idna(n,lun,2) = msbt
1614 read ( numb(4:6),
'(I3)')
idna(n,lun,1)
1635 subroutine stntbi ( n, lun, numb, nemo, celsq )
1641 integer,
intent(in) :: n, lun
1644 character*(*),
intent(in) :: numb, nemo, celsq
1646 call nenubd ( nemo, numb, lun )
1648 if ( numb(1:1) ==
'0')
then
1649 idnb(n,lun) = ifxy(numb)
1650 tabb(n,lun)(1:6) = numb(1:6)
1651 tabb(n,lun)(7:14) = nemo(1:8)
1652 tabb(n,lun)(16:70) = celsq(1:55)
1655 idnd(n,lun) = ifxy(numb)
1656 tabd(n,lun)(1:6) = numb(1:6)
1657 tabd(n,lun)(7:14) = nemo(1:8)
1658 tabd(n,lun)(16:70) = celsq(1:55)
1682 use modv_vars,
only: maxcd, iprt, idxv
1688 integer,
intent(in) :: id, lun, idn
1689 integer,
intent(out) :: iret
1690 integer nxstr, ldxa, ldxb, ldxd, ld30, ldd, nd, idm, iupm
1692 character*128 errstr
1695 common /dxtab/ nxstr(10), ldxa(10), ldxb(10), ldxd(10), ld30(10), dxstr(10)
1699 ldd = ldxd(idxv+1)+1
1703 call ipkm(
tabd(id,lun)(ldd:ldd),1,0)
1710 nd = iupm(
tabd(id,lun)(ldd:ldd),8)
1712 if(nd<0 .or. nd==maxcd)
then
1714 call errwrt(
'+++++++++++++++++++++WARNING+++++++++++++++++++++++')
1716 write ( unit=errstr, fmt=
'(A,I4,A)' )
'BUFRLIB: PKTDD - BAD COUNTER VALUE (=', nd,
') - RETURN WITH IRET = -1'
1718 write ( unit=errstr, fmt=
'(A,I4,A,A)' )
'BUFRLIB: PKTDD - MAXIMUM NUMBER OF CHILD MNEMONICS (=', &
1719 maxcd,
') ALREADY STORED FOR THIS PARENT - RETURN WITH IRET = -1'
1722 call errwrt(
'+++++++++++++++++++++WARNING+++++++++++++++++++++++')
1729 call ipkm(
tabd(id,lun)(ldd:ldd),1,nd)
1735 idm = ldd+1 + (nd-1)*2
1736 call ipkm(
tabd(id,lun)(idm:idm+1),2,idn)
1739 end subroutine pktdd
1756 use modv_vars,
only: idxv
1762 integer,
intent(in) :: id, lun, ient
1763 integer,
intent(out) :: iret
1764 integer nxstr, ldxa, ldxb, ldxd, ld30, ldd, ndsc, idsc, iupm
1766 character*128 bort_str
1769 common /dxtab/ nxstr(10), ldxa(10), ldxb(10), ldxd(10), ld30(10), dxstr(10)
1773 ldd = ldxd(idxv+1)+1
1774 ndsc = iupm(
tabd(id,lun)(ldd:ldd),8)
1778 elseif(ient<0 .or. ient>ndsc)
then
1779 write(bort_str,
'("BUFRLIB: UPTDD - VALUE OF THIRD ARGUMENT IENT (INPUT) IS OUT OF RANGE (IENT =",I4,")")') ient
1785 idsc = ldd+1 + (ient-1)*2
1786 iret = iupm(
tabd(id,lun)(idsc:idsc+1),16)
1789 end subroutine uptdd
1814 character*8,
intent(inout) :: nem1
1815 character*8,
intent(in) :: nem2
1824 if(nem1(i:i)==
'.')
then
1825 nem1(i:i) = nem2(j:j)
recursive subroutine bort(str)
Log an error message, then either return to or abort the application program.
subroutine bort_target_unset
Clear any existing bort target.
recursive subroutine bort2(str1, str2)
Log two error messages, then either return to or abort the application program.
integer function bort_target_set()
Sets a new bort target, if bort catching is enabled and such a target doesn't already exist.
recursive integer function iupb(mbay, nbyt, nbit)
Decode an integer value from within a specified number of bits of an integer array,...
recursive integer function iupm(cbay, nbits)
Decode an integer value from within a specified number of bits of a character string,...
subroutine upc(chr, nchr, ibay, ibit, cnvnull)
Decode a character string from within a specified number of bytes of an integer array,...
subroutine pkc(chr, nchr, ibay, ibit)
Encode a character string within a specified number of bytes of an integer array, starting at the bit...
recursive subroutine ipkm(cbay, nbyt, n)
Encode an integer value within a specified number of bytes of a character string, up to a maximum of ...
subroutine pkb(nval, nbits, ibay, ibit)
Encode an integer value within a specified number of bits of an integer array, starting at the bit im...
subroutine cpbfdx(lud, lun)
Copy all of the DX BUFR table information from one unit to another within internal memory.
subroutine elemdx(card, lun)
Decode the scale factor, reference value, bit width and units (i.e., the "elements") from a Table B m...
subroutine nemtbb(lun, itab, unit, iscl, iref, ibit)
Get information about a Table B descriptor from the internal DX BUFR tables.
subroutine dxmini(mbay, mbyt, mb4, mba, mbb, mbd)
Initialize a DX BUFR tables (dictionary) message, writing all the preliminary information into Sectio...
subroutine nemtba(lun, nemo, mtyp, msbt, inod)
Get information about a Table A descriptor from the internal DX BUFR tables.
subroutine rdusdx(lundx, lun)
Read and parse a file containing a user-supplied DX BUFR table in character format,...
subroutine rsvfvm(nem1, nem2)
Process a "following value" mnemonic.
subroutine seqsdx(card, lun)
Decode the Table D sequence information from a mnemonic definition card that was previously read from...
recursive subroutine wrdxtb(lundx, lunot)
Generate one or more BUFR messages from the DX BUFR tables information associated with a given BUFR f...
subroutine nemtbax(lun, nemo, mtyp, msbt, inod)
Get information about a Table A descriptor from the internal DX BUFR tables.
subroutine nemtbd(lun, itab, nseq, nems, irps, knts)
Get information about a Table D descriptor from the internal DX BUFR tables.
subroutine stntbi(n, lun, numb, nemo, celsq)
Store a new entry within internal BUFR Table B or D.
subroutine pktdd(id, lun, idn, iret)
Store information about a child mnemonic within the internal BUFR Table D.
subroutine stntbia(n, lun, numb, nemo, celsq)
Store a new entry within internal BUFR Table A.
subroutine stbfdx(lun, mesg)
Copy a DX BUFR tables message into the internal memory arrays in module moda_tababd.
subroutine writdx(lunit, lun, lundx)
Write DX BUFR table (dictionary) messages to the beginning of an output BUFR file in lunit.
recursive subroutine nemdefs(lunit, nemo, celem, cunit, iret)
Get the element name and units associated with a Table B descriptor.
integer function igetntbi(lun, ctb)
Get the next available index for storing an entry within a specified internal DX BUFR table.
subroutine readdx(lunit, lun, lundx)
Initialize modules moda_tababd and moda_msgcwd with DX BUFR (dictionary) tables.
subroutine dxinit(lun, ioi)
Clear out the internal arrays (in module moda_tababd) holding the DX BUFR table, then optionally init...
subroutine nenubd(nemo, numb, lun)
Confirm that a mnemonic and FXY value haven't already been defined.
integer function idxmsg(mesg)
Check whether a BUFR message contains DX BUFR tables information that was generated by the NCEPLIBS-b...
subroutine uptdd(id, lun, ient, iret)
Get the WMO bit-wise representation of the FXY value corresponding to a child mnemonic in a Table D s...
subroutine rdbfdx(lunit, lun)
Beginning at the current file pointer location within lunit, read a complete DX BUFR table into inter...
subroutine errwrt(str)
Specify a custom location for the logging of error and diagnostic messages generated by the NCEPLIBS-...
subroutine nemtab(lun, nemo, idn, tab, iret)
Get information about a descriptor, based on a mnemonic.
subroutine numtab(lun, idn, nemo, tab, iret)
Get information about a descriptor, based on the WMO bit-wise representation of an FXY value.
character *(*) function adn30(idn, ldn)
Convert an FXY value from its WMO bit-wise representation to a character string of length 5 or 6.
subroutine makestab
Build the entire internal jump/link table within module moda_tables, using all of the internal BUFR t...
subroutine jstnum(str, sign, iret)
Left-justify a character string containing an encoded integer, by removing all leading blanks and any...
recursive subroutine strnum(str, num, iret)
Decode an integer from a character string.
subroutine strsuc(str1, str2, lens)
Remove leading and trailing blanks from a character string.
subroutine capit(str)
Capitalize all of the alphabetic characters in a string.
Wrap C NCEPLIBS-bufr functions so they can be called from within the Fortran part of the library.
Declare arrays and variables used to store BUFR messages internally for multiple file IDs.
integer maxbyt
Maximum length of an output BUFR message.
Declare an array used by various subroutines and functions to hold a temporary working copy of a BUFR...
integer, dimension(:), allocatable mgwa
Temporary working copy of BUFR message.
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 mtab
Entries within jump/link table corresponding to taba.
integer, dimension(:,:,:), allocatable idna
Message types (in array element 1) and subtypes (in array element 2) corresponding to taba.
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...
integer, dimension(:,:), allocatable idnd
WMO bit-wise representations of the FXY values corresponding to tabd.
integer, dimension(:,:), allocatable idnb
WMO bit-wise representations of the FXY values corresponding to tabb.
character *128, dimension(:,:), allocatable tabb
Table B entries for each file ID.
recursive subroutine status(lunit, lun, il, im)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
logical function msgfull(msiz, itoadd, mxsiz)
Check whether the current data subset in the internal arrays will fit within the current BUFR message...
recursive subroutine getlens(mbay, ll, len0, len1, len2, len3, len4, len5)
Read the section lengths of a BUFR message, up to a specified point in the message.
subroutine rdmsgw(lunit, mesg, iret)
Read the next BUFR message from logical unit lunit as an array of integer words.
subroutine msgwrt(lunit, mesg, mgbyt)
Perform final checks and updates on a BUFR message before writing it to a specified Fortran logical u...
recursive integer function iupbs01(mbay, s01mnem)
Read a specified value from within Section 0 or Section 1 of a BUFR message.
subroutine parstr(str, tags, mtag, ntag, sep, limit80)
Parse a string containing one or more substrings into an array of substrings.
subroutine x48(iin4, iout8, nval)
Encode one or more 4-byte integer values as 8-byte integer values.
subroutine x84(iin8, iout4, nval)
Encode one or more 8-byte integer values as 4-byte integer values.