From 931cce117a7d775c4f62af96c8a4db52e5511b17 Mon Sep 17 00:00:00 2001 From: Jeff Ator Date: Tue, 10 Dec 2024 20:57:44 +0000 Subject: [PATCH 1/5] replace common /quiet/ block with module variable --- src/arallocf.F90 | 6 ++--- src/copydata.F90 | 6 ++--- src/dxtable.F90 | 17 +++++++------ src/jumplink.F90 | 28 ++++++++++------------ src/mastertable.F90 | 10 ++++---- src/memmsgs.F90 | 41 +++++++++++-------------------- src/misc.F90.in | 11 +++++---- src/modules_vars.F90 | 10 ++++++++ src/openbt.F90 | 6 ++--- src/openclosebf.F90 | 22 +++++++---------- src/readwritemg.F90 | 23 +++++++----------- src/readwritesb.F90 | 17 ++++++------- src/readwriteval.F90 | 57 ++++++++++++++++---------------------------- src/s013vals.F90 | 23 +++++++----------- src/strings.F90 | 2 +- 15 files changed, 117 insertions(+), 162 deletions(-) diff --git a/src/arallocf.F90 b/src/arallocf.F90 index 0d56070a..4d65ec48 100644 --- a/src/arallocf.F90 +++ b/src/arallocf.F90 @@ -19,7 +19,7 @@ subroutine arallocf use modv_vars, only: maxcd, maxjl, maxmem, maxmsg, maxss, maxtba, maxtbb, maxtbd, mxbtm, mxbtmse, & mxcdv, mxcsb, mxdxts, mxlcc, mxmsgl, mxmsgld4, mxmtbb, mxmtbd, mxnrv, mxrst, & - mxs01v, mxtamc, mxtco, mxh4wlc, nfiles, mxcnem, maxnc, maxrcr + mxs01v, mxtamc, mxtco, mxh4wlc, nfiles, mxcnem, maxnc, maxrcr, iprt use moda_usrint use moda_usrbit @@ -63,9 +63,7 @@ subroutine arallocf character*80 errstr character*36 brtstr - integer iost, iprt - - common /quiet/ iprt + integer iost if ( iprt >= 1 ) then call errwrt ('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++') diff --git a/src/copydata.F90 b/src/copydata.F90 index b5591d00..bfdf41e3 100644 --- a/src/copydata.F90 +++ b/src/copydata.F90 @@ -511,18 +511,18 @@ end subroutine cpymem !> @author Woollen @date 1994-01-06 subroutine cpyupd(lunit,lin,lun,ibyt) + use modv_vars, only: iprt + use moda_msgcwd use moda_bitbuf implicit none integer, intent(in) :: lunit, lin, lun, ibyt - integer nby0, nby1, nby2, nby3, nby4, nby5, iprt, lbit, lbyt, nbyt, iupb + integer nby0, nby1, nby2, nby3, nby4, nby5, lbit, lbyt, nbyt, iupb common /msgptr/ nby0,nby1,nby2,nby3,nby4,nby5 - common /quiet/ iprt - character*128 bort_str, errstr logical msgfull diff --git a/src/dxtable.F90 b/src/dxtable.F90 index f19d9ed9..12f57f4a 100644 --- a/src/dxtable.F90 +++ b/src/dxtable.F90 @@ -27,15 +27,15 @@ !> @author Woollen @date 1994-01-06 subroutine readdx(lunit,lun,lundx) + use modv_vars, only: iprt + implicit none integer, intent(in) :: lunit, lun, lundx - integer iprt, lud, ildx, imdx + integer lud, ildx, imdx character*128 errstr - common /quiet/ iprt - ! Get the status of unit lundx call status(lundx,lud,ildx,imdx) @@ -121,19 +121,19 @@ subroutine rdbfdx(lunit,lun) use bufrlib + use modv_vars, only: iprt + use moda_mgwa implicit none integer, intent(in) :: lunit, lun - integer iprt, ict, ier, idxmsg, iupbs3 + integer ict, ier, idxmsg, iupbs3 character*128 errstr logical done - common /quiet/ iprt - call dxinit(lun,0) ict = 0 @@ -1660,7 +1660,7 @@ end subroutine stntbi !> @author Woollen @date 1994-01-06 subroutine pktdd(id,lun,idn,iret) - use modv_vars, only: maxcd + use modv_vars, only: maxcd, iprt use moda_tababd @@ -1668,13 +1668,12 @@ subroutine pktdd(id,lun,idn,iret) integer, intent(in) :: id, lun, idn integer, intent(out) :: iret - integer maxdx, idxv, nxstr, ldxa, ldxb, ldxd, ld30, iprt, ldd, nd, idm, iupm + integer maxdx, idxv, nxstr, ldxa, ldxb, ldxd, ld30, ldd, nd, idm, iupm character*128 errstr character*56 dxstr common /dxtab/ maxdx, idxv, nxstr(10), ldxa(10), ldxb(10), ldxd(10), ld30(10), dxstr(10) - common /quiet/ iprt ! ldd points to the byte within tabd(id,lun) which contains (in packed integer format) a count of the number of child ! mnemonics stored thus far for this parent mnemonic. diff --git a/src/jumplink.F90 b/src/jumplink.F90 index 366b06e3..03969c4c 100644 --- a/src/jumplink.F90 +++ b/src/jumplink.F90 @@ -21,7 +21,7 @@ !> @author J. Woollen @date 1994-01-06 subroutine makestab - use modv_vars, only: bmiss, maxjl, nfiles + use modv_vars, only: bmiss, maxjl, nfiles, iprt use moda_usrint use moda_stbfr @@ -34,15 +34,13 @@ subroutine makestab implicit none - integer iprt, lunit, lundx, lun, lum, n, itba, inc, newn, noda, node, inod, icmpdx, ishrdx + integer lunit, lundx, lun, lum, n, itba, inc, newn, noda, node, inod, icmpdx, ishrdx character*128 bort_str, errstr character*8 nemo logical expand - common /quiet/ iprt - ! Reset pointer table and string cache. ntab = 0 @@ -1185,18 +1183,17 @@ end subroutine gettagpr !> @author Woollen @date 1994-01-06 integer function invtag(node,lun,inv1,inv2) result(iret) + use modv_vars, only: iprt + use moda_usrint use moda_tables implicit none integer, intent(in) :: node, lun, inv1, inv2 - integer iprt character*10 tagn - common /quiet/ iprt - if(node/=0) then tagn = tag(node) ! Search between inv1 and inv2 @@ -1233,17 +1230,17 @@ end function invtag !> @author Woollen @date 1994-01-06 integer function invwin(node,lun,inv1,inv2) result(iret) + use modv_vars, only: iprt + use moda_usrint implicit none integer, intent(in) :: node, lun, inv1, inv2 - integer iprt, idx + integer idx character*80 errstr - common /quiet/ iprt - iret = 0 if(node/=0) then ! Search between inv1 and inv2 @@ -1435,15 +1432,16 @@ end subroutine conwin !> @author Woollen @date 1994-01-06 integer function invcon(nc,lun,inv1,inv2) result(iret) + use modv_vars, only: iprt + use moda_usrint implicit none integer, intent(in) :: nc, lun, inv1, inv2 - integer nnod, ncon, nods, nodc, ivls, kons, iprt + integer nnod, ncon, nods, nodc, ivls, kons common /usrstr/ nnod, ncon, nods(20), nodc(10), ivls(10), kons(10) - common /quiet/ iprt if(inv1>0 .and. inv1<=nval(lun) .and. inv2>0 .and. inv2<=nval(lun)) then do iret=inv1,inv2 @@ -1583,18 +1581,18 @@ end subroutine nxtwin !> @author Woollen @date 1994-01-06 integer function nvnwin(node,lun,inv1,inv2,invn,nmax) result(iret) + use modv_vars, only: iprt + use moda_usrint implicit none integer, intent(in) :: node, lun, inv1, inv2, nmax integer, intent(out) :: invn(*) - integer iprt, i, n + integer i, n character*128 bort_str - common /quiet/ iprt - iret = 0 if(node==0) then diff --git a/src/mastertable.F90 b/src/mastertable.F90 index e53cfa48..ca854f03 100644 --- a/src/mastertable.F90 +++ b/src/mastertable.F90 @@ -85,10 +85,12 @@ end subroutine mtinfo !> @author Ator @date 2017-10-16 subroutine mtfnam ( imt, imtv, iogce, imtvl, tbltyp, stdfil, locfil ) + use modv_vars, only: iprt + implicit none integer, intent(in) :: imt, imtv, iogce, imtvl - integer iprt, lun1, lun2, lmtd, ltbt, isize + integer lun1, lun2, lmtd, ltbt, isize character*(*), intent(in) :: tbltyp character*(*), intent(out) :: stdfil, locfil @@ -100,7 +102,6 @@ subroutine mtfnam ( imt, imtv, iogce, imtvl, tbltyp, stdfil, locfil ) logical found - common /quiet/ iprt common /mstinf/ lun1, lun2, lmtd, mtdir call strsuc ( tbltyp, tbltyp2, ltbt ) @@ -178,7 +179,7 @@ integer function ireadmt ( lun ) result ( iret ) use bufrlib - use modv_vars, only: maxnc, maxcd, mxmtbb, mxmtbd + use modv_vars, only: maxnc, maxcd, mxmtbb, mxmtbd, iprt use moda_mstabs use moda_bitbuf @@ -190,7 +191,7 @@ integer function ireadmt ( lun ) result ( iret ) implicit none integer, intent(in) :: lun - integer iprt, lun1, lun2, lmtd, lmt, lmtv, logce, lmtvl, imt, imtv, iogce, imtvl, ii, jj, idx, ncds3, ier, & + integer lun1, lun2, lmtd, lmt, lmtv, logce, lmtvl, imt, imtv, iogce, imtvl, ii, jj, idx, ncds3, ier, & ibmt, ibmtv, ibogce, ibltv, idmt, idmtv, idogce, idltv, iupbs01, ifxy, istdesc character*(*), parameter :: bort_str1 = 'BUFRLIB: IREADMT - COULD NOT OPEN STANDARD FILE:' @@ -200,7 +201,6 @@ integer function ireadmt ( lun ) result ( iret ) logical allstd - common /quiet/ iprt common /mstinf/ lun1, lun2, lmtd, mtdir ! Initializing the following value ensures that new master tables are read during the first call to this subroutine. diff --git a/src/memmsgs.F90 b/src/memmsgs.F90 index bbaa3288..dd6fe294 100644 --- a/src/memmsgs.F90 +++ b/src/memmsgs.F90 @@ -39,7 +39,7 @@ recursive subroutine ufbmem(lunit,inew,iret,iunit) use bufrlib - use modv_vars, only: im8b, maxmem, maxmsg + use modv_vars, only: im8b, maxmem, maxmsg, iprt use moda_mgwa use moda_msgmem @@ -48,12 +48,10 @@ recursive subroutine ufbmem(lunit,inew,iret,iunit) integer, intent(in) :: lunit, inew integer, intent(out) :: iret, iunit - integer iprt, my_lunit, my_inew, iflg, itim, lun, il, im, itemp, ier, nmsg, lmem, i, mlast0, idxmsg, nmwrd + integer my_lunit, my_inew, iflg, itim, lun, il, im, itemp, ier, nmsg, lmem, i, mlast0, idxmsg, nmwrd character*128 bort_str, errstr - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -215,7 +213,7 @@ end subroutine ufbmem !> @author J. Woollen @date 2012-01-26 recursive subroutine ufbmex(lunit,lundx,inew,iret,mesg) - use modv_vars, only: im8b, maxmem, maxmsg + use modv_vars, only: im8b, maxmem, maxmsg, iprt use moda_mgwa use moda_msgmem @@ -226,9 +224,7 @@ recursive subroutine ufbmex(lunit,lundx,inew,iret,mesg) integer, intent(in) :: lunit, lundx, inew integer, intent(out) :: mesg(*), iret - integer iprt, my_lunit, my_lundx, my_inew, nmesg, iflg, itim, ier, nmsg, lmem, i, mlast0, iupbs01, nmwrd - - common /quiet/ iprt + integer my_lunit, my_lundx, my_inew, nmesg, iflg, itim, ier, nmsg, lmem, i, mlast0, iupbs01, nmwrd ! Check for I8 integers @@ -485,7 +481,7 @@ end function ireadmm !> @author J. Woollen @date 1994-01-06 recursive subroutine rdmemm(imsg,subset,jdate,iret) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_msgcwd use moda_bitbuf @@ -496,15 +492,13 @@ recursive subroutine rdmemm(imsg,subset,jdate,iret) integer, intent(in) :: imsg integer, intent(out) :: jdate, iret - integer iprt, my_imsg, lun, il, im, ii, jj, kk, nwrd, iptr, lptr, ier + integer my_imsg, lun, il, im, ii, jj, kk, nwrd, iptr, lptr, ier character*128 bort_str, errstr character*8, intent(out) :: subset logical known - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -633,7 +627,7 @@ end subroutine rdmemm !> @author J. Woollen @date 1994-01-06 recursive subroutine rdmems(isub,iret) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_msgcwd use moda_unptyp @@ -644,12 +638,10 @@ recursive subroutine rdmems(isub,iret) integer, intent(in) :: isub integer, intent(out) :: iret - integer my_isub, iprt, lun, il, im, mbym, nbyt, i, iupb + integer my_isub, lun, il, im, mbym, nbyt, i, iupb character*128 bort_str, errstr - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -730,7 +722,7 @@ subroutine cpdxmm( lunit ) use bufrlib - use modv_vars, only: mxdxts + use modv_vars, only: mxdxts, iprt use moda_mgwa use moda_msgmem @@ -738,14 +730,12 @@ subroutine cpdxmm( lunit ) implicit none integer, intent(in) :: lunit - integer iprt, ict, lun, il, im, ier, j, lmem, idxmsg, iupbs3, nmwrd + integer ict, lun, il, im, ier, j, lmem, idxmsg, iupbs3, nmwrd character*128 errstr logical done - common /quiet/ iprt - if ( ndxts >= mxdxts ) call bort('BUFRLIB: CPDXMM - MXDXTS OVERFLOW') ict = 0 @@ -975,7 +965,7 @@ end subroutine ufbmns !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbrms(imsg,isub,usr,i1,i2,iret,str) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_msgcwd use moda_msgmem @@ -984,7 +974,7 @@ recursive subroutine ufbrms(imsg,isub,usr,i1,i2,iret,str) integer, intent(in) :: imsg, isub, i1, i2 integer, intent(out) :: iret - integer iprt, my_imsg, my_isub, my_i1, my_i2, jdate, lun, il, im + integer my_imsg, my_isub, my_i1, my_i2, jdate, lun, il, im real*8, intent(out) :: usr(i1,i2) @@ -992,8 +982,6 @@ recursive subroutine ufbrms(imsg,isub,usr,i1,i2,iret,str) character*128 bort_str, errstr character*8 subset - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -1101,7 +1089,7 @@ end subroutine ufbrms !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbtam(tab,i1,i2,iret,str) - use modv_vars, only: im8b, bmiss + use modv_vars, only: im8b, bmiss, iprt use moda_usrint use moda_msgcwd @@ -1119,14 +1107,13 @@ recursive subroutine ufbtam(tab,i1,i2,iret,str) integer*8 mps, ival integer, intent(in) :: i1, i2 integer, intent(out) :: iret - integer iprt, maxtg, nnod, ncon, nods, nodc, ivls, kons, my_i1, my_i2, i, irec, isub, itbl, lun, il, im, jdate, mret, & + integer maxtg, nnod, ncon, nods, nodc, ivls, kons, my_i1, my_i2, i, irec, isub, itbl, lun, il, im, jdate, mret, & kbit, mbit, nbit, n, node, imsg, kmsg, nrep, ntg, nbyt, nbmp, nmsub real*8, intent(out) :: tab(i1,i2) real*8 rval, ups common /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10) - common /quiet/ iprt equivalence (cval,rval) diff --git a/src/misc.F90.in b/src/misc.F90.in index 82259d29..37657600 100644 --- a/src/misc.F90.in +++ b/src/misc.F90.in @@ -300,17 +300,17 @@ end function irev !> @author J. Woollen @date 1994-01-06 subroutine jstnum(str,sign,iret) + use modv_vars, only: iprt + implicit none integer, intent(out) :: iret - integer iprt, lstr, num, ier + integer lstr, num, ier character*(*), intent(inout) :: str character, intent(out) :: sign character*128 errstr - common /quiet/ iprt - iret = 0 if(str==' ') call bort('BUFRLIB: JSTNUM - INPUT BLANK CHARACTER STRING NOT ALLOWED') @@ -511,14 +511,15 @@ end function iokoper !> @author J. Woollen @date 1996-10-09 subroutine mrginv + use modv_vars, only: iprt + implicit none - integer nrpl, nmrg, namb, ntot, iprt + integer nrpl, nmrg, namb, ntot character*128 errstr common /mrgcom/ nrpl, nmrg, namb, ntot - common /quiet/ iprt if(iprt>=0) then call errwrt('+++++++++++++++++++++BUFRLIB+++++++++++++++++++++++') diff --git a/src/modules_vars.F90 b/src/modules_vars.F90 index 77d58434..212903de 100644 --- a/src/modules_vars.F90 +++ b/src/modules_vars.F90 @@ -45,6 +45,16 @@ module modv_vars !> - 1 = Yes integer :: ifopbf = 0 + !> Indicator for degree of printout: + !> - -1 = no printout except for abort messages + !> - 0 = limited printout + !> - 1 = all warning messages are printed + !> - 2 = all warning and info messages are printed + !> - 3 = all warning, info and debug messages are printed + !> The default value is 0, but this value can be changed at any time via a call to + !> subroutine openbf() with call argument io set to 'QUIET'. + integer :: iprt = 0 + !> Status indicator to keep track of whether future calls to subroutine parusr() should !> allow an input mnemonic to exist in multiple replication sequences: !> - 0 = No diff --git a/src/openbt.F90 b/src/openbt.F90 index d115a129..1991364d 100644 --- a/src/openbt.F90 +++ b/src/openbt.F90 @@ -29,15 +29,13 @@ !> @author J. Woollen @date 1998-07-08 recursive subroutine openbt(lundx,mtyp) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt implicit none integer, intent(in) :: mtyp integer, intent(out) :: lundx - integer iprt, my_mtyp - - common /quiet/ iprt + integer my_mtyp character*128 errstr diff --git a/src/openclosebf.F90 b/src/openclosebf.F90 index 506d44ad..32513878 100644 --- a/src/openclosebf.F90 +++ b/src/openclosebf.F90 @@ -149,7 +149,7 @@ end subroutine fortran_close !> - 'APX' = same as 'APN', except backspace before appending !> - 'NUL' = same as 'OUT', except don't write any messages whatsoever to lunit (e.g. when subroutine writsa() is to be used) !> - 'INUL' = same as 'IN', except don't read any messages whatsoever from lunit (e.g. when subroutine readerme() is to be used) -!> - 'QUIET' = lunit is ignored; this is an indicator that the value for iprt in common block /quiet/ is being reset to the +!> - 'QUIET' = lunit is ignored; this is an indicator that the value for module variable iprt is being reset to the !> value in lundx !> - 'FIRST' = lunit and lundx are ignored; this is an indicator to initialize the NCEPLIBS-bufr software, in case this !> subroutine was never previously called @@ -158,7 +158,7 @@ end subroutine fortran_close !> reading/writing from/to lunit (depending on the case); this value may be set equal to lunit if DX BUFR table information is !> already embedded in lunit !> - If io is set to 'QUIET' = indicator for degree of printout: -!> - -1 = no printout except for ABORT messages +!> - -1 = no printout except for abort messages !> - 0 = limited printout (default) !> - 1 = all warning messages are printed !> - 2 = all warning and info messages are printed @@ -169,7 +169,7 @@ recursive subroutine openbf(lunit,io,lundx) use bufrlib - use modv_vars, only: im8b, ifopbf, nfiles + use modv_vars, only: im8b, ifopbf, nfiles, iprt use moda_msgcwd use moda_stbfr @@ -181,17 +181,15 @@ recursive subroutine openbf(lunit,io,lundx) implicit none integer, intent(in) :: lunit, lundx - integer my_lunit, my_lundx, iprt, iprtprv, lun, il, im + integer my_lunit, my_lundx, iprtprv, lun, il, im character*(*), intent(in) :: io character*255 filename, fileacc character*128 bort_str, errstr character*28 cprint(0:4) - common /quiet/ iprt - data cprint/ & - ' (only ABORTs) ', & + ' (only aborts) ', & ' (limited -default) ', & ' (all warnings) ', & ' (all warnings+infos) ', & @@ -210,12 +208,11 @@ recursive subroutine openbf(lunit,io,lundx) return endif - ! If this is the first call to this subroutine, initialize iprt in /quiet/ as 0 - + ! reset iprt to default value in case of a previous call to subroutine exitbufr() if(ifopbf==0) iprt = 0 if(io=='QUIET') then - ! override previous iprt value (printout indicator) + ! override previous iprt value iprtprv = iprt iprt = lundx if(iprt<-1) iprt = -1 @@ -860,7 +857,7 @@ end subroutine rewnbf !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbtab(lunin,tab,i1,i2,iret,str) - use modv_vars, only: im8b, bmiss, iac + use modv_vars, only: im8b, bmiss, iac, iprt use moda_usrint use moda_msgcwd @@ -874,7 +871,7 @@ recursive subroutine ufbtab(lunin,tab,i1,i2,iret,str) integer, intent(in) :: lunin, i1, i2 integer, intent(out) :: iret integer, parameter :: maxtg = 100 - integer nnod, ncon, nods, nodc, ivls, kons, iprt, my_lunin, my_i1, my_i2, lunit, lun, il, im, irec, isub, i, n, ntg, & + integer nnod, ncon, nods, nodc, ivls, kons, my_lunin, my_i1, my_i2, lunit, lun, il, im, irec, isub, i, n, ntg, & jdate, jbit, kbit, lbit, mbit, nbit, nibit, nbyt, nsb, node, nbmp, nrep, lret, linc, iac_prev, ityp, & ireadmg, ireadsb, nmsub @@ -890,7 +887,6 @@ recursive subroutine ufbtab(lunin,tab,i1,i2,iret,str) real*8 rval, ups common /usrstr/ nnod, ncon, nods(20), nodc(10), ivls(10), kons(10) - common /quiet/ iprt equivalence (cval,rval) diff --git a/src/readwritemg.F90 b/src/readwritemg.F90 index 07cb899b..73ac5954 100644 --- a/src/readwritemg.F90 +++ b/src/readwritemg.F90 @@ -44,7 +44,7 @@ recursive subroutine readmg(lunxx,subset,jdate,iret) use bufrlib - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_msgcwd use moda_sc3bfr @@ -54,13 +54,11 @@ recursive subroutine readmg(lunxx,subset,jdate,iret) integer, intent(in) :: lunxx integer, intent(out) :: jdate, iret - integer iprt, my_lunxx, lunit, lun, il, im, ier, idxmsg + integer my_lunxx, lunit, lun, il, im, ier, idxmsg character*8, intent(out) :: subset character*128 errstr - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -215,7 +213,7 @@ end function ireadmg !> @authors J. Woollen J. Ator @date 1995-06-28 recursive subroutine readerme(mesg,lunit,subset,jdate,iret) - use modv_vars, only: mxmsgl, im8b, nbytw + use modv_vars, only: mxmsgl, im8b, nbytw, iprt use moda_sc3bfr use moda_idrdm @@ -225,7 +223,7 @@ recursive subroutine readerme(mesg,lunit,subset,jdate,iret) integer, intent(in) :: lunit, mesg(*) integer, intent(out) :: jdate, iret - integer iprt, my_lunit, iec0(2), lun, il, im, ii, lnmsg, lmsg, idxmsg, iupbs3 + integer my_lunit, iec0(2), lun, il, im, ii, lnmsg, lmsg, idxmsg, iupbs3 character*8, intent(out) :: subset character*8 sec0 @@ -235,8 +233,6 @@ recursive subroutine readerme(mesg,lunit,subset,jdate,iret) equivalence (sec0,iec0) - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -598,7 +594,7 @@ subroutine msgwrt(lunit,mesg,mgbyt) use bufrlib - use modv_vars, only: mxmsgld4 + use modv_vars, only: mxmsgld4, iprt use moda_nulbfr use moda_bufrmg @@ -611,14 +607,12 @@ subroutine msgwrt(lunit,mesg,mgbyt) implicit none integer, intent(in) :: lunit, mgbyt, mesg(*) - integer iprt, iec0(2), mbyt, ibit, kbit, ii, jj, len0, len1, len2, len3, len4, l5, iad4, iad5, lun, il, im, npbyt, mwrd, & + integer iec0(2), mbyt, ibit, kbit, ii, jj, len0, len1, len2, len3, len4, l5, iad4, iad5, lun, il, im, npbyt, mwrd, & nmwrd, iupbs01, idxmsg character*128 errstr character*4 bufr, sevn - common /quiet/ iprt - data bufr /'BUFR'/ data sevn /'7777'/ @@ -973,20 +967,19 @@ end function msgfull !> @authors J. Woollen, J. Ator @date 2002-05-14 recursive subroutine maxout(maxo) - use modv_vars, only: mxmsgl, im8b + use modv_vars, only: mxmsgl, im8b, iprt use moda_bitbuf implicit none integer, intent(in) :: maxo - integer my_maxo, iprt, newsiz, maxdx, idxv, nxstr, ldxa, ldxb, ldxd, ld30 + integer my_maxo, newsiz, maxdx, idxv, nxstr, ldxa, ldxb, ldxd, ld30 character*128 errstr character*56 dxstr common /dxtab/ maxdx,idxv,nxstr(10),ldxa(10),ldxb(10),ldxd(10),ld30(10),dxstr(10) - common /quiet/ iprt ! Check for I8 integers diff --git a/src/readwritesb.F90 b/src/readwritesb.F90 index 5c9eac34..620b186a 100644 --- a/src/readwritesb.F90 +++ b/src/readwritesb.F90 @@ -611,6 +611,8 @@ end subroutine rdmgsb !> @author Woollen @date 1994-01-06 subroutine msgupd(lunit,lun) + use modv_vars, only: iprt + use moda_msgcwd use moda_bitbuf use moda_h4wlc @@ -618,14 +620,13 @@ subroutine msgupd(lunit,lun) implicit none integer, intent(in) :: lunit, lun - integer nby0, nby1, nby2, nby3, nby4, nby5, iprt, ibyt, lbyt, lbit, nbyt, ii, iupb + integer nby0, nby1, nby2, nby3, nby4, nby5, ibyt, lbyt, lbit, nbyt, ii, iupb logical msgfull character*128 errstr common /msgptr/ nby0, nby1, nby2, nby3, nby4, nby5 - common /quiet/ iprt ! Pad the subset buffer @@ -1151,7 +1152,7 @@ end subroutine wrtree !> @author Woollen @date 1994-01-06 subroutine rcstpl(lun,iret) - use modv_vars, only: maxjl, maxss, maxrcr + use modv_vars, only: maxjl, maxss, maxrcr, iprt use moda_usrint use moda_usrbit @@ -1166,9 +1167,7 @@ subroutine rcstpl(lun,iret) integer, intent(in) :: lun integer, intent(out) :: iret - integer nbmp(2,maxrcr), newn(2,maxrcr), knx(maxrcr), iprt, nodi, node, mbmp, nr, i, j, n, nn, n1, n2, new, ivob, igetrfel - - common /quiet/ iprt + integer nbmp(2,maxrcr), newn(2,maxrcr), knx(maxrcr), nodi, node, mbmp, nr, i, j, n, nn, n1, n2, new, ivob, igetrfel iret = 0 @@ -1289,7 +1288,7 @@ end subroutine rcstpl !> @author J. Woollen @date 1994-01-06 subroutine usrtpl(lun,invn,nbmp) - use modv_vars, only: maxjl, maxss + use modv_vars, only: maxjl, maxss, iprt use moda_usrint use moda_msgcwd @@ -1300,14 +1299,12 @@ subroutine usrtpl(lun,invn,nbmp) implicit none integer, intent(in) :: lun, invn, nbmp - integer iprt, i, j, ival, jval, n, n1, n2, nodi, node, newn, invr, knvn + integer i, j, ival, jval, n, n1, n2, nodi, node, newn, invr, knvn character*128 bort_str, errstr logical drp, drs, drb, drx - common /quiet/ iprt - if(iprt>=2) then call errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++') write ( unit=errstr, fmt='(A,I3,A,I7,A,I5,A,A10)' ) & diff --git a/src/readwriteval.F90 b/src/readwriteval.F90 index cefaa74d..29959077 100644 --- a/src/readwriteval.F90 +++ b/src/readwriteval.F90 @@ -198,7 +198,7 @@ end function getvalnb !> @author J. Woollen @author J. Ator @date 2003-11-04 recursive subroutine writlc(lunit,chr,str) - use modv_vars, only: im8b, mxlcc + use modv_vars, only: im8b, mxlcc, iprt use moda_usrint use moda_msgcwd @@ -209,7 +209,7 @@ recursive subroutine writlc(lunit,chr,str) implicit none integer, intent(in) :: lunit - integer my_lunit, maxtg, iprt, lun, il, im, ntg, nnod, kon, ii, n, node, ioid, ival, mbit, nbit, nbmp, nchr, nbyt, nsubs, & + integer my_lunit, maxtg, lun, il, im, ntg, nnod, kon, ii, n, node, ioid, ival, mbit, nbit, nbmp, nchr, nbyt, nsubs, & itagct, len0, len1, len2, len3, l4, l5, mbyte, iupbs3 character*(*), intent(in) :: chr, str @@ -219,8 +219,6 @@ recursive subroutine writlc(lunit,chr,str) real roid - common /quiet/ iprt - data maxtg /10/ ! Check for I8 integers @@ -405,7 +403,7 @@ end subroutine writlc !> @authors J. Woollen J. Ator @date 2003-11-04 recursive subroutine readlc(lunit,chr,str) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_usrint use moda_usrbit @@ -417,7 +415,7 @@ recursive subroutine readlc(lunit,chr,str) implicit none integer, intent(in) :: lunit - integer my_lunit, maxtg, iprt, lchr, lun, il, im, ntg, nnod, kon, ii, n, nod, ioid, itagct, nchr, kbit + integer my_lunit, maxtg, lchr, lun, il, im, ntg, nnod, kon, ii, n, nod, ioid, itagct, nchr, kbit character*(*), intent(in) :: str character*(*), intent(out) :: chr @@ -428,8 +426,6 @@ recursive subroutine readlc(lunit,chr,str) real roid - common /quiet/ iprt - data maxtg /10/ ! Check for I8 integers @@ -644,7 +640,7 @@ end subroutine readlc !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbint(lunin,usr,i1,i2,iret,str) - use modv_vars, only: im8b, bmiss + use modv_vars, only: im8b, bmiss, iprt use moda_usrint use moda_msgcwd @@ -658,10 +654,9 @@ recursive subroutine ufbint(lunin,usr,i1,i2,iret,str) integer, intent(in) :: lunin, i1, i2 integer, intent(out) :: iret - integer iprt, nnod, ncon, nods, nodc, ivls, kons, ifirst1, ifirst2, my_lunin, my_i1, my_i2, lunit, lun, il, im, io + integer nnod, ncon, nods, nodc, ivls, kons, ifirst1, ifirst2, my_lunin, my_i1, my_i2, lunit, lun, il, im, io common /usrstr/ nnod, ncon, nods(20), nodc(10), ivls(10), kons(10) - common /quiet/ iprt data ifirst1 /0/, ifirst2 /0/ @@ -878,7 +873,7 @@ end subroutine ufbint !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbrep(lunin,usr,i1,i2,iret,str) - use modv_vars, only: im8b, bmiss, iac + use modv_vars, only: im8b, bmiss, iac, iprt use moda_usrint use moda_msgcwd @@ -892,9 +887,7 @@ recursive subroutine ufbrep(lunin,usr,i1,i2,iret,str) integer, intent(in) :: lunin, i1, i2 integer, intent(out) :: iret - integer iprt, ifirst1, my_lunin, my_i1, my_i2, lunit, lun, il, im, io, iac_prev - - common /quiet/ iprt + integer ifirst1, my_lunin, my_i1, my_i2, lunit, lun, il, im, io, iac_prev data ifirst1 /0/ @@ -1085,7 +1078,7 @@ end subroutine ufbrep !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbstp(lunin,usr,i1,i2,iret,str) - use modv_vars, only: im8b, bmiss + use modv_vars, only: im8b, bmiss, iprt use moda_usrint use moda_msgcwd @@ -1099,9 +1092,7 @@ recursive subroutine ufbstp(lunin,usr,i1,i2,iret,str) integer, intent(in) :: lunin, i1, i2 integer, intent(out) :: iret - integer iprt, ifirst1, my_lunin, my_i1, my_i2, lunit, lun, il, im, io - - common /quiet/ iprt + integer ifirst1, my_lunin, my_i1, my_i2, lunit, lun, il, im, io data ifirst1 /0/ @@ -1300,7 +1291,7 @@ end subroutine ufbstp !> @author J. Woollen @date 2000-09-19 recursive subroutine ufbseq(lunin,usr,i1,i2,iret,str) - use modv_vars, only: im8b, bmiss + use modv_vars, only: im8b, bmiss, iprt use moda_usrint use moda_msgcwd @@ -1311,7 +1302,7 @@ recursive subroutine ufbseq(lunin,usr,i1,i2,iret,str) integer, intent(in) :: lunin, i1, i2 integer, intent(out) :: iret integer, parameter :: mtag = 10 - integer iprt, ifirst1, ifirst2, my_lunin, my_i1, my_i2, lunit, lun, il, im, io, i, j, ntag, node, nods, ins1, ins2, insx, & + integer ifirst1, ifirst2, my_lunin, my_i1, my_i2, lunit, lun, il, im, io, i, j, ntag, node, nods, ins1, ins2, insx, & nseq, isq, ityp, invwin, invtag real*8, intent(inout) :: usr(i1,i2) @@ -1321,8 +1312,6 @@ recursive subroutine ufbseq(lunin,usr,i1,i2,iret,str) character*128 errstr character*10 tags(mtag) - common /quiet/ iprt - data ifirst1 /0/, ifirst2 /0/ save ifirst1, ifirst2 @@ -1627,7 +1616,7 @@ end subroutine drfini !> @author J. Woollen @date 1994-01-06 subroutine ufbrw(lun,usr,i1,i2,io,iret) - use modv_vars, only: bmiss + use modv_vars, only: bmiss, iprt use moda_usrint use moda_tables @@ -1637,7 +1626,7 @@ subroutine ufbrw(lun,usr,i1,i2,io,iret) integer, intent(in) :: lun, i1, i2, io integer, intent(out) :: iret - integer iprt, nnod, ncon, nods, nodc, ivls, kons, inc1, inc2, ins1, ins2, invn, i, j, invwin, ibfms, lstjpb + integer nnod, ncon, nods, nodc, ivls, kons, inc1, inc2, ins1, ins2, invn, i, j, invwin, ibfms, lstjpb real*8, intent(inout) :: usr(i1,i2) @@ -1645,7 +1634,6 @@ subroutine ufbrw(lun,usr,i1,i2,io,iret) character*10 tagstr, subset common /usrstr/ nnod, ncon, nods(20), nodc(10), ivls(10), kons(10) - common /quiet/ iprt subset=tag(inode(lun)) iret = 0 @@ -1950,22 +1938,20 @@ end subroutine ufbsp !> @author J. Ator @date 2014-02-05 recursive subroutine hold4wlc(lunit,chr,str) - use modv_vars, only: im8b, mxh4wlc + use modv_vars, only: im8b, mxh4wlc, iprt use moda_h4wlc implicit none integer, intent(in) :: lunit - integer my_lunit, iprt, lens, lenc, i + integer my_lunit, lens, lenc, i character*(*), intent(in) :: chr, str character*128 errstr character*14 mystr - common /quiet/ iprt - ! Check for I8 integers if(im8b) then im8b=.false. @@ -2101,7 +2087,7 @@ end subroutine trybump !> @author Woollen @date 1994-01-06 recursive subroutine ufbovr(lunit,usr,i1,i2,iret,str) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_usrint use moda_msgcwd @@ -2110,15 +2096,13 @@ recursive subroutine ufbovr(lunit,usr,i1,i2,iret,str) integer, intent(in) :: lunit, i1, i2 integer, intent(out) :: iret - integer iprt, ifirst1, my_lunit, my_i1, my_i2, lun, il, im, io + integer ifirst1, my_lunit, my_i1, my_i2, lun, il, im, io character*(*), intent(in) :: str character*128 bort_str1, bort_str2, errstr real*8, intent(inout) :: usr(i1,i2) - common /quiet/ iprt - data ifirst1 /0/ save ifirst1 @@ -2235,7 +2219,7 @@ end subroutine ufbovr !> @author J. Woollen @date 1994-01-06 recursive subroutine ufbevn(lunit,usr,i1,i2,i3,iret,str) - use modv_vars, only: im8b, bmiss + use modv_vars, only: im8b, bmiss, iprt use moda_usrint use moda_msgcwd @@ -2247,7 +2231,7 @@ recursive subroutine ufbevn(lunit,usr,i1,i2,i3,iret,str) integer, intent(in) :: lunit, i1, i2, i3 integer, intent(out) :: iret - integer invn(255), nnod, ncon, nods, nodc, ivls, kons, maxevn, iprt, my_lunit, my_i1, my_i2, my_i3, i, j, k, lun, il, im, & + integer invn(255), nnod, ncon, nods, nodc, ivls, kons, maxevn, my_lunit, my_i1, my_i2, my_i3, i, j, k, lun, il, im, & ins1, ins2, inc1, inc2, nnvn, nvnwin real*8, intent(out) :: usr(i1,i2,i3) @@ -2256,7 +2240,6 @@ recursive subroutine ufbevn(lunit,usr,i1,i2,i3,iret,str) common /usrstr/ nnod, ncon, nods(20), nodc(10), ivls(10), kons(10) common /ufbn3c/ maxevn - common /quiet/ iprt ! Check for I8 integers diff --git a/src/s013vals.F90 b/src/s013vals.F90 index fbd11287..0cb81238 100644 --- a/src/s013vals.F90 +++ b/src/s013vals.F90 @@ -686,7 +686,7 @@ subroutine reads3 ( lun ) use bufrlib - use modv_vars, only: maxnc, mxcnem + use modv_vars, only: maxnc, mxcnem, iprt use moda_sc3bfr use moda_bitbuf @@ -696,7 +696,7 @@ subroutine reads3 ( lun ) implicit none integer, intent(in) :: lun - integer iprt, irepct, ireadmt, igettdi, itmp, ncds3, ii, jj, ifxy, igetntbi, n, idn + integer irepct, ireadmt, igettdi, itmp, ncds3, ii, jj, ifxy, igetntbi, n, idn character*6 numb, adn30 character*55 cseq @@ -704,8 +704,6 @@ subroutine reads3 ( lun ) logical incach - common /quiet/ iprt - save irepct ! Check whether the appropriate BUFR master table information has already been read into internal memory for this message. @@ -935,7 +933,7 @@ end subroutine datelen !> @author J. Woollen @date 1994-01-06 recursive subroutine datebf(lunit,mear,mmon,mday,mour,idate) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_mgwa @@ -943,12 +941,10 @@ recursive subroutine datebf(lunit,mear,mmon,mday,mour,idate) integer, intent(in) :: lunit integer, intent(out) :: mear, mmon, mday, mour, idate - integer my_lunit, iprt, lun, jl, jm, ier, idx, idxmsg, igetdate + integer my_lunit, lun, jl, jm, ier, idx, idxmsg, igetdate character*128 errstr - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -1134,7 +1130,7 @@ end function i4dy !> @author J. Woollen @date 1996-12-11 recursive subroutine dumpbf(lunit,jdate,jdump) - use modv_vars, only: im8b + use modv_vars, only: im8b, iprt use moda_mgwa @@ -1142,12 +1138,10 @@ recursive subroutine dumpbf(lunit,jdate,jdump) integer, intent(in) :: lunit integer, intent(out) :: jdate(*), jdump(*) - integer my_lunit, lun, jl, jm, iprt, ier, ii, igetdate, idxmsg, iupbs3, iupbs01 + integer my_lunit, lun, jl, jm, ier, ii, igetdate, idxmsg, iupbs3, iupbs01 character*128 errstr - common /quiet/ iprt - ! Check for I8 integers if(im8b) then @@ -1270,6 +1264,8 @@ end subroutine minimg !> @author Woollen @date 2000-09-19 subroutine cktaba(lun,subset,jdate,iret) + use modv_vars, only: iprt + use moda_msgcwd use moda_sc3bfr use moda_unptyp @@ -1280,7 +1276,7 @@ subroutine cktaba(lun,subset,jdate,iret) integer, intent(in) :: lun integer, intent(out) :: jdate, iret integer, parameter :: ncpfx = 3 - integer ibct, ipd1, ipd2, ipd3, ipd4, iprt, mtyp, msbt, mty1, msb1, isub, ksub, len0, len1, len2, len3, l4, l5, lundx, ii, & + integer ibct, ipd1, ipd2, ipd3, ipd4, mtyp, msbt, mty1, msb1, isub, ksub, len0, len1, len2, len3, l4, l5, lundx, ii, & itab, inod, iad3, iad4, iyr, imo, idy, ihr, iupb, iupbs01, iupbs3, i4dy, igetdate character*128 bort_str, errstr @@ -1291,7 +1287,6 @@ subroutine cktaba(lun,subset,jdate,iret) logical trybt common /padesc/ ibct, ipd1, ipd2, ipd3, ipd4 - common /quiet/ iprt iret = 0 diff --git a/src/strings.F90 b/src/strings.F90 index cf75fc33..43d583ec 100644 --- a/src/strings.F90 +++ b/src/strings.F90 @@ -440,7 +440,7 @@ subroutine parutg(lun,io,utg,nod,kon,val) ! user application has been streamlined to always call subroutine ufbint() with the same str, even though some of the ! mnemonics contained within that str may not exist within the sequence definition of every possible type/subtype that is ! being written by the application. In such cases, by not being "picky", we could just allow the library to subsequently - ! (and quietly, if iprt happened to be set to -1 in common /quiet/) not actually store the value corresponding to such + ! (and quietly, if module variable iprt happened to be set to -1) not actually store the value corresponding to such ! mnemonics, rather than loudly complaining and aborting. if(kon==0 .and. (io==0 .or. atag=='NUL' .or. .not.picky)) then From 40b20b09246e69af56f783a409691188ac431c82 Mon Sep 17 00:00:00 2001 From: Jeff Ator Date: Thu, 12 Dec 2024 18:42:43 +0000 Subject: [PATCH 2/5] replace common blocks /tabccc/ and /mstinf/ with module syntax --- src/jumplink.F90 | 11 ++++------ src/mastertable.F90 | 33 +++++++++--------------------- src/misc.F90.in | 8 ++++---- src/modules_arrs.F90 | 31 +++++++++++++++++++++------- src/modules_vars.F90 | 48 ++++++++++++++++++++++++++++++++++++++------ src/openclosebf.F90 | 6 +----- 6 files changed, 84 insertions(+), 53 deletions(-) diff --git a/src/jumplink.F90 b/src/jumplink.F90 index 03969c4c..9e0d822c 100644 --- a/src/jumplink.F90 +++ b/src/jumplink.F90 @@ -332,12 +332,12 @@ subroutine tabsub(lun,nemo) use moda_nmikrp use moda_nrv203 use moda_bitmaps + use moda_tabccc implicit none integer, intent(in) :: lun - integer jmp0(10), nodl(10), ntag(10,2), icdw, icsc, icrv, incw, maxlim, node, idn, itab, nseq, limb, n, jj, iyyy, & - irep, iknt, jum0, iokoper + integer jmp0(10), nodl(10), ntag(10,2), maxlim, node, idn, itab, nseq, limb, n, jj, iyyy, irep, iknt, jum0, iokoper character*128 bort_str character*8, intent(in) :: nemo @@ -346,8 +346,6 @@ subroutine tabsub(lun,nemo) logical drop(10), ltamc - common /tabccc/ icdw, icsc, icrv, incw - data maxlim /10/ ! Check the mnemonic @@ -582,11 +580,12 @@ subroutine tabent(lun,nemo,tab,itab,irep,iknt,jum0) use moda_tables use moda_nrv203 + use moda_tabccc implicit none integer, intent(in) :: lun, itab, irep, iknt, jum0 - integer icdw, icsc, icrv, incw, i, jm0, node, iscl, iref, ibit + integer i, jm0, node, iscl, iref, ibit character*24 unit character*10 rtag @@ -594,8 +593,6 @@ subroutine tabent(lun,nemo,tab,itab,irep,iknt,jum0) character, intent(in) :: tab character*3 typt - common /tabccc/ icdw, icsc, icrv, incw - jm0 = jum0 ! Make a jump/link table entry for a replicator diff --git a/src/mastertable.F90 b/src/mastertable.F90 index ca854f03..68e6f41e 100644 --- a/src/mastertable.F90 +++ b/src/mastertable.F90 @@ -33,17 +33,14 @@ !> @author J. Ator @date 2009-03-23 recursive subroutine mtinfo ( cmtdir, lunmt1, lunmt2 ) - use modv_vars, only: im8b + use modv_vars, only: im8b, lun1, lun2, mtdir, lmtd implicit none integer, intent(in) :: lunmt1, lunmt2 - integer my_lunmt1, my_lunmt2, lun1, lun2, lmtd + integer my_lunmt1, my_lunmt2 character*(*), intent(in) :: cmtdir - character*240 mtdir - - common /mstinf/ lun1, lun2, lmtd, mtdir ! Check for I8 integers if(im8b) then @@ -69,7 +66,7 @@ end subroutine mtinfo !> !> After determining the corresponding file names, this subroutine then confirms the existence of those files on the !> filesystem, using additional information obtained from the most recent call to subroutine mtinfo(), or else as -!> defined within subroutine bfrini() if subroutine mtinfo() was never called. +!> defined within subroutine bfrini() if subroutine mtinfo() was never called by the application program. !> !> @param imt - Master table number !> @param imtv - Master table version number @@ -85,25 +82,22 @@ end subroutine mtinfo !> @author Ator @date 2017-10-16 subroutine mtfnam ( imt, imtv, iogce, imtvl, tbltyp, stdfil, locfil ) - use modv_vars, only: iprt + use modv_vars, only: iprt, mtdir, lmtd implicit none integer, intent(in) :: imt, imtv, iogce, imtvl - integer lun1, lun2, lmtd, ltbt, isize + integer ltbt, isize character*(*), intent(in) :: tbltyp character*(*), intent(out) :: stdfil, locfil character*16 tbltyp2 character*20 fmtf - character*240 mtdir character*128 bort_str logical found - common /mstinf/ lun1, lun2, lmtd, mtdir - call strsuc ( tbltyp, tbltyp2, ltbt ) ! Determine the standard master table path/filename. @@ -170,16 +164,14 @@ end subroutine mtfnam !> Information about the location of master BUFR tables on the !> local file system is obtained from the most recent call to !> subroutine mtinfo(), or else from subroutine bfrini() if -!> subroutine mtinfo() was never called, and in which case Fortran -!> logical unit numbers 98 and 99 will be used by this function -!> for opening and reading master BUFR table files. +!> subroutine mtinfo() was never called by the application program. !> !> @author J. Ator @date 2009-03-23 integer function ireadmt ( lun ) result ( iret ) use bufrlib - use modv_vars, only: maxnc, maxcd, mxmtbb, mxmtbd, iprt + use modv_vars, only: maxnc, maxcd, mxmtbb, mxmtbd, iprt, lun1, lun2, lmt, lmtv, logce, lmtvl use moda_mstabs use moda_bitbuf @@ -191,24 +183,17 @@ integer function ireadmt ( lun ) result ( iret ) implicit none integer, intent(in) :: lun - integer lun1, lun2, lmtd, lmt, lmtv, logce, lmtvl, imt, imtv, iogce, imtvl, ii, jj, idx, ncds3, ier, & - ibmt, ibmtv, ibogce, ibltv, idmt, idmtv, idogce, idltv, iupbs01, ifxy, istdesc + integer imt, imtv, iogce, imtvl, ii, jj, idx, ncds3, ier, ibmt, ibmtv, ibogce, ibltv, idmt, idmtv, idogce, idltv, & + iupbs01, ifxy, istdesc character*(*), parameter :: bort_str1 = 'BUFRLIB: IREADMT - COULD NOT OPEN STANDARD FILE:' character*(*), parameter :: bort_str2 = 'BUFRLIB: IREADMT - COULD NOT OPEN LOCAL FILE:' character*275 stdfil,locfil - character*240 mtdir logical allstd - common /mstinf/ lun1, lun2, lmtd, mtdir - ! Initializing the following value ensures that new master tables are read during the first call to this subroutine. - data lmt /-99/ - - save lmt, lmtv, logce, lmtvl - iret = 0 ! Unpack some Section 1 information from the message that was most recently read. diff --git a/src/misc.F90.in b/src/misc.F90.in index 37657600..183043bc 100644 --- a/src/misc.F90.in +++ b/src/misc.F90.in @@ -3,7 +3,7 @@ !> !> @author J. Woollen @date 1994-01-06 -!> Initialize numerous global variables and arrays within internal modules and COMMON blocks throughout the +!> Initialize numerous global variables and arrays within internal modules and common blocks throughout the !> NCEPLIBS-bufr software. !> !> This subroutine isn't normally called directly by any application @@ -14,7 +14,7 @@ !> @authors J. Woollen J. Ator @date 1994-01-06 subroutine bfrini - use modv_vars, only: maxtba, maxtbb, maxtbd, mxmsgl, nfiles, adsn, idnr + use modv_vars, only: maxtba, maxtbb, maxtbd, mxmsgl, nfiles, adsn, idnr, lun1, lun2 use moda_stbfr use moda_idrdm @@ -149,11 +149,11 @@ subroutine bfrini ncnem = 0 - ! Initialize common /mstinf/ + ! Initialize master BUFR table information cmtdir = & '@MASTER_TABLE_DIR_F@' - call mtinfo(cmtdir,98,99) + call mtinfo(cmtdir,lun1,lun2) return end subroutine bfrini diff --git a/src/modules_arrs.F90 b/src/modules_arrs.F90 index b71c777e..dc3ad8ff 100644 --- a/src/modules_arrs.F90 +++ b/src/modules_arrs.F90 @@ -454,9 +454,8 @@ module moda_nmikrp integer, allocatable :: krp(:,:) end module moda_nmikrp -!> Declare arrays and variables for use with -!> any 2-03-YYY (change reference value) operators present within the -!> internal jump/link table. +!> Declare arrays and variables for use with any 2-03-YYY (change reference value) operators +!> present within the internal jump/link table. !> !> Data values within this module are stored by subroutine tabsub(). !> @@ -491,6 +490,26 @@ module moda_nrv203 integer, allocatable :: ienrv(:) end module moda_nrv203 +!> Declare variables for use with certain Table C operators in the internal jump/link table. +!> +!> Data values within this module are stored by subroutine tabsub(). +!> +!> @author J. Ator @date 2024-12-10 +module moda_tabccc + ! Number of bits by which to modify the data width of subsequent jump/link table mnemonics whose + ! type indicator is "NUM"; set to 0 unless a 2-01-YYY or 2-07-YYY operator is in effect. + integer :: icdw + ! Number by which to modify the scale of subsequent jump/link table mnemonics whose type + ! indicator is "NUM"; set to 0 unless a 2-02-YYY or 2-07-YYY operator is in effect. + integer :: icsc + ! Factor by which to multiply the reference value of subsequent jump/link table mnemonics + ! whose type indicator is "NUM"; set to 1 unless a 2-07-YYY operator is in effect. + integer :: icrv + ! New data width (in bytes) for subsequent jump/link table mnemonics whose type indicator + ! is "CHR"; set to 0 unless a 2-08-YYY operator is in effect. + integer :: incw +end module moda_tabccc + !> Declare an array used to store a switch for each file ID, !> indicating whether any BUFR !> messages should actually be written to the corresponding logical @@ -654,11 +673,9 @@ module moda_tababd character*600, allocatable :: tabd(:,:) end module moda_tababd -!> Declare arrays and variables used to store -!> the internal jump/link table. +!> Declare arrays and variables used to store the internal jump/link table. !> -!> Data values within this module are stored by subroutines -!> makestab(), tabsub() and tabent(). +!> Data values within this module are stored by subroutines makestab(), tabsub() and tabent(). !> !> @author J. Ator @date 2014-12-10 module moda_tables diff --git a/src/modules_vars.F90 b/src/modules_vars.F90 index 212903de..1b56e277 100644 --- a/src/modules_vars.F90 +++ b/src/modules_vars.F90 @@ -40,21 +40,57 @@ module modv_vars !> time via a call to subroutine setbmiss(). real*8 :: bmiss = 10E10_8 - !> Status indicator to keep track of whether subroutine openbf() has already been called: - !> - 0 = No - !> - 1 = Yes - integer :: ifopbf = 0 - !> Indicator for degree of printout: !> - -1 = no printout except for abort messages !> - 0 = limited printout !> - 1 = all warning messages are printed !> - 2 = all warning and info messages are printed !> - 3 = all warning, info and debug messages are printed - !> The default value is 0, but this value can be changed at any time via a call to + !> The default value is 0, but it can be changed at any time via a call to !> subroutine openbf() with call argument io set to 'QUIET'. integer :: iprt = 0 + !> Directory on local file system containing master BUFR tables. This is set to a + !> default value within subroutine bfrini(), but it can be changed at any time via + !> a call to subroutine mtinfo(). + character*240 :: mtdir + + !> Length (in bytes) of directory on local file system containing master BUFR tables. + integer :: lmtd + + !> First of two Fortran logical unit numbers to use when reading master BUFR tables + !> from the local file system. The default value is 98, but it can be changed + !> at any time via a call to subroutine mtinfo(). + integer :: lun1 = 98 + + !> Second of two Fortran logical unit numbers to use when reading master BUFR tables + !> from the local file system. The default value is 99, but it can be changed + !> at any time via a call to subroutine mtinfo(). + integer :: lun2 = 99 + + !> Master table for the last BUFR message that was read from a logical unit where + !> Section 3 decoding is being used. + !> This value is initialized to an artificially low number, in order to ensure that new + !> master tables will be read in during the first internal call to subroutine ireadmt(). + integer :: lmt = -99 + + !> Version number of master table for the last BUFR message that was read from a logical + !> unit where Section 3 decoding is being used. + integer :: lmtv + + !> Originating center for the last BUFR message that was read from a logical unit where + !> Section 3 decoding is being used. + integer :: logce + + !> Version number of local table for the last BUFR message that was read from a logical + !> unit where Section 3 decoding is being used. + integer :: lmtvl + + !> Status indicator to keep track of whether subroutine openbf() has already been called: + !> - 0 = No + !> - 1 = Yes + integer :: ifopbf = 0 + !> Status indicator to keep track of whether future calls to subroutine parusr() should !> allow an input mnemonic to exist in multiple replication sequences: !> - 0 = No diff --git a/src/openclosebf.F90 b/src/openclosebf.F90 index 32513878..460dff08 100644 --- a/src/openclosebf.F90 +++ b/src/openclosebf.F90 @@ -133,7 +133,6 @@ end subroutine fortran_close !> info.), but otherwise no prior knowledge is required of the contents of the !> messages to be decoded. !> -!> !> @param lunit - Fortran logical unit number for BUFR file (unless io is set to 'FIRST' or 'QUIET', !> in which case this is a dummy argument) !> @param io - flag indicating how lunit is to be used by the software: @@ -208,11 +207,8 @@ recursive subroutine openbf(lunit,io,lundx) return endif - ! reset iprt to default value in case of a previous call to subroutine exitbufr() - if(ifopbf==0) iprt = 0 - if(io=='QUIET') then - ! override previous iprt value + ! Override previous iprt value iprtprv = iprt iprt = lundx if(iprt<-1) iprt = -1 From 07bd9c914dccee79e385d1b9719a1ec42b9c5613 Mon Sep 17 00:00:00 2001 From: Jeff Ator Date: Fri, 13 Dec 2024 22:42:52 +0000 Subject: [PATCH 3/5] replace common blocks /ufbn3c/ and /msgptr/ with module syntax --- src/compress.F90 | 16 +++++----- src/copydata.F90 | 6 ++-- src/dxtable.F90 | 18 +++++------- src/modules_vars.F90 | 69 +++++++++++++++++++++++++++++--------------- src/readwritemg.F90 | 26 +++++++---------- src/readwritesb.F90 | 6 ++-- src/readwriteval.F90 | 1 - src/s013vals.F90 | 9 +++--- src/standard.F90 | 6 ++-- 9 files changed, 82 insertions(+), 75 deletions(-) diff --git a/src/compress.F90 b/src/compress.F90 index 2feaf8e9..53dca98d 100644 --- a/src/compress.F90 +++ b/src/compress.F90 @@ -257,12 +257,14 @@ end subroutine rdcmps !> @author Woollen @date 2002-05-14 subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) + use modv_vars, only: mtv, nby1, nby5 + implicit none integer, intent(in) :: lun, idate, nsub integer, intent(inout) :: nbyt integer, intent(out) :: mesg(*) - integer mtyp, msbt, inod, isub, iret, jdate, mcen, mear, mmon, mday, mour, mmin, mbit, mbyt, len1, len3, i4dy + integer mtyp, msbt, inod, isub, iret, jdate, mcen, mear, mmon, mday, mour, mmin, mbit, mbyt, len3, i4dy character*128 bort_str character*8, intent(in) :: subset @@ -307,9 +309,7 @@ subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) ! Section 1 - len1 = 18 - - call pkb(len1 , 24 , mesg,mbit) + call pkb(nby1 , 24 , mesg,mbit) call pkb( 0 , 8 , mesg,mbit) call pkb( 3 , 8 , mesg,mbit) call pkb( 7 , 8 , mesg,mbit) @@ -317,7 +317,7 @@ subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) call pkb( 0 , 8 , mesg,mbit) call pkb(mtyp , 8 , mesg,mbit) call pkb(msbt , 8 , mesg,mbit) - call pkb( 36 , 8 , mesg,mbit) + call pkb( mtv , 8 , mesg,mbit) call pkb( 0 , 8 , mesg,mbit) call pkb(mear , 8 , mesg,mbit) call pkb(mmon , 8 , mesg,mbit) @@ -353,7 +353,7 @@ subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) ! (length of message up through fourth byte of Section 4) ! + (length of compressed data portion of Section 4) ! + (length of Section 5) - mbyt = mbit/8 + nbyt + 4 + mbyt = mbit/8 + nbyt + nby5 ! For output, make nbyt point to the current location of mbit, which is the byte after which to actually begin writing the ! compressed data into Section 4. @@ -385,7 +385,7 @@ end subroutine cmsgini !> @author Woollen @date 2002-05-14 subroutine wrcmps(lunix) - use modv_vars, only: mxcdv, mxcsb + use modv_vars, only: mxcdv, mxcsb, nby5 use moda_usrint use moda_msgcwd @@ -650,7 +650,7 @@ subroutine wrcmps(lunix) ! Add Section 5 - call pkc('7777',4,mgwa,ibit) + call pkc('7777',nby5,mgwa,ibit) ! Check that the message byte counters agree, then write the message diff --git a/src/copydata.F90 b/src/copydata.F90 index bfdf41e3..3aa3df68 100644 --- a/src/copydata.F90 +++ b/src/copydata.F90 @@ -511,7 +511,7 @@ end subroutine cpymem !> @author Woollen @date 1994-01-06 subroutine cpyupd(lunit,lin,lun,ibyt) - use modv_vars, only: iprt + use modv_vars, only: iprt, nby0, nby1, nby2, nby3 use moda_msgcwd use moda_bitbuf @@ -519,9 +519,7 @@ subroutine cpyupd(lunit,lin,lun,ibyt) implicit none integer, intent(in) :: lunit, lin, lun, ibyt - integer nby0, nby1, nby2, nby3, nby4, nby5, lbit, lbyt, nbyt, iupb - - common /msgptr/ nby0,nby1,nby2,nby3,nby4,nby5 + integer lbit, lbyt, nbyt, iupb character*128 bort_str, errstr diff --git a/src/dxtable.F90 b/src/dxtable.F90 index 12f57f4a..92aa4185 100644 --- a/src/dxtable.F90 +++ b/src/dxtable.F90 @@ -693,13 +693,13 @@ end subroutine dxinit !> @author Woollen @date 1994-01-06 subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd) - use modv_vars, only: mxmsgld4 + use modv_vars, only: mxmsgld4, mtv, nby0, nby1, nby2, nby5 implicit none integer, intent(out) :: mbay(*), mbyt, mb4, mba, mbb, mbd integer maxdx, idxv, nxstr, ldxa, ldxb, ldxd, ld30, mtyp, msbt, mbit, ih, id, im, iy, i, nsub, idxs, ldxs, & - nby0, nby1, nby2, nby3, nby4, nby5, iupm + len3, nby4, iupm character*128 bort_str character*56 dxstr @@ -726,15 +726,11 @@ subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd) idxs = idxv+1 ldxs = nxstr(idxs) - nby0 = 8 - nby1 = 18 - nby2 = 0 - nby3 = 7 + nxstr(idxs) + 1 + len3 = 7 + nxstr(idxs) + 1 nby4 = 7 - nby5 = 4 - mbyt = nby0+nby1+nby2+nby3+nby4+nby5 + mbyt = nby0+nby1+nby2+len3+nby4+nby5 - if(mod(nby3,2)/=0) call bort ('BUFRLIB: DXMINI - LENGTH OF SECTION 3 IS NOT A MULTIPLE OF 2') + if(mod(len3,2)/=0) call bort ('BUFRLIB: DXMINI - LENGTH OF SECTION 3 IS NOT A MULTIPLE OF 2') ! Section 0 @@ -752,7 +748,7 @@ subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd) call pkb( 0 , 8 , mbay,mbit) call pkb( mtyp , 8 , mbay,mbit) call pkb( msbt , 8 , mbay,mbit) - call pkb( 36 , 8 , mbay,mbit) + call pkb( mtv , 8 , mbay,mbit) call pkb( idxv , 8 , mbay,mbit) call pkb( iy , 8 , mbay,mbit) call pkb( im , 8 , mbay,mbit) @@ -763,7 +759,7 @@ subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd) ! Section 3 - call pkb( nby3 , 24 , mbay,mbit) + call pkb( len3 , 24 , mbay,mbit) call pkb( 0 , 8 , mbay,mbit) call pkb( 1 , 16 , mbay,mbit) call pkb( 2**7 , 8 , mbay,mbit) diff --git a/src/modules_vars.F90 b/src/modules_vars.F90 index 1b56e277..fc49b6c6 100644 --- a/src/modules_vars.F90 +++ b/src/modules_vars.F90 @@ -27,12 +27,12 @@ module modv_vars logical :: im8b = .false. !> Status indicator to keep track of whether all future BUFR output - !> messages should be encapsulated with IEEE Fortran control words: + !> messages should be encapsulated with IEEE Fortran control words. + !> The default value is 0, but it can be changed at any + !> time via a call to subroutine setblock(). !> - -1 = Yes, using little-endian control words !> - 0 = No !> - 1 = Yes, using big-endian control words - !> The default value is 0, but this value can be changed at any - !> time via a call to subroutine setblock(). integer :: iblock = 0 !> Current placeholder value to represent "missing" data when reading @@ -40,14 +40,14 @@ module modv_vars !> time via a call to subroutine setbmiss(). real*8 :: bmiss = 10E10_8 - !> Indicator for degree of printout: + !> Indicator for degree of printout. + !> The default value is 0, but it can be changed at any time via a call to + !> subroutine openbf() with call argument io set to 'QUIET'. !> - -1 = no printout except for abort messages !> - 0 = limited printout !> - 1 = all warning messages are printed !> - 2 = all warning and info messages are printed !> - 3 = all warning, info and debug messages are printed - !> The default value is 0, but it can be changed at any time via a call to - !> subroutine openbf() with call argument io set to 'QUIET'. integer :: iprt = 0 !> Directory on local file system containing master BUFR tables. This is set to a @@ -68,24 +68,6 @@ module modv_vars !> at any time via a call to subroutine mtinfo(). integer :: lun2 = 99 - !> Master table for the last BUFR message that was read from a logical unit where - !> Section 3 decoding is being used. - !> This value is initialized to an artificially low number, in order to ensure that new - !> master tables will be read in during the first internal call to subroutine ireadmt(). - integer :: lmt = -99 - - !> Version number of master table for the last BUFR message that was read from a logical - !> unit where Section 3 decoding is being used. - integer :: lmtv - - !> Originating center for the last BUFR message that was read from a logical unit where - !> Section 3 decoding is being used. - integer :: logce - - !> Version number of local table for the last BUFR message that was read from a logical - !> unit where Section 3 decoding is being used. - integer :: lmtvl - !> Status indicator to keep track of whether subroutine openbf() has already been called: !> - 0 = No !> - 1 = Yes @@ -327,4 +309,43 @@ module modv_vars !> application program. integer :: nfiles = 32 + !> Master table version number to be encoded in output BUFR messages. + !> This variable is initialized to a default value which can be + !> overridden by a subsequent call to subroutine pkvs01() within the + !> application program. + integer :: mtv = 36 + + !> Number of bytes in Section 0 of a BUFR message. + integer, parameter :: nby0 = 8 + + !> Number of bytes in Section 1 of a BUFR message. + integer, parameter :: nby1 = 18 + + !> Number of bytes in Section 2 of a BUFR message. + integer, parameter :: nby2 = 0 + + !> Number of bytes in Section 3 of a BUFR message. + integer, parameter :: nby3 = 20 + + !> Number of bytes in Section 5 of a BUFR message. + integer, parameter :: nby5 = 4 + + !> Master table for the last BUFR message that was read from a logical unit where + !> Section 3 decoding is being used. + !> This value is initialized to an artificially low number, in order to ensure that new + !> master tables will be read in during the first internal call to subroutine ireadmt(). + integer :: lmt = -99 + + !> Master table version number for the last BUFR message that was read from a logical + !> unit where Section 3 decoding is being used. + integer :: lmtv + + !> Originating center for the last BUFR message that was read from a logical unit where + !> Section 3 decoding is being used. + integer :: logce + + !> Local table version number for the last BUFR message that was read from a logical + !> unit where Section 3 decoding is being used. + integer :: lmtvl + end module modv_vars diff --git a/src/readwritemg.F90 b/src/readwritemg.F90 index 73ac5954..ffacaf02 100644 --- a/src/readwritemg.F90 +++ b/src/readwritemg.F90 @@ -594,7 +594,7 @@ subroutine msgwrt(lunit,mesg,mgbyt) use bufrlib - use modv_vars, only: mxmsgld4, iprt + use modv_vars, only: mxmsgld4, iprt, nby5 use moda_nulbfr use moda_bufrmg @@ -665,7 +665,7 @@ subroutine msgwrt(lunit,mesg,mgbyt) ibit = 32 call pkb(mbyt,24,mgwa,ibit) ibit = (mbyt-4)*8 - call pkc(sevn,4,mgwa,ibit) + call pkc(sevn,nby5,mgwa,ibit) call stndrd(lunit,mgwa,mxmsgld4,mgwb) ! Compute mbyt for the new standardized message mbyt = iupbs01(mgwb,'LENM') @@ -722,7 +722,7 @@ subroutine msgwrt(lunit,mesg,mgbyt) call pkb(mbyt,24,mgwa,ibit) kbit = (mbyt-4)*8 - call pkc(sevn, 4,mgwa,kbit) + call pkc(sevn,nby5,mgwa,kbit) ! Zero out the extra bytes which will be written. Note that the BUFR message is stored within the integer array mgwa(*), ! (rather than within a character array), so we need to make sure that the "7777" Is followed by zeroed-out bytes up to @@ -763,13 +763,15 @@ end subroutine msgwrt !> Initialize, within the internal arrays, a new uncompressed BUFR message for output. !> -!> Arrays are filled in common block msgptr and modules @ref moda_msgcwd and @ref moda_bitbuf. +!> Arrays are filled in modules @ref moda_msgcwd and @ref moda_bitbuf. !> !> @param lun - file ID !> !> @author Woollen @date 1994-01-06 subroutine msgini(lun) + use modv_vars, only: mtv, nby0, nby1, nby2, nby3, nby5 + use moda_msgcwd use moda_ufbcpl use moda_bitbuf @@ -778,7 +780,7 @@ subroutine msgini(lun) implicit none integer, intent(in) :: lun - integer ibct, ipd1, ipd2, ipd3, ipd4, nby0, nby1, nby2, nby3, nby4, nby5, nbyt, mtyp, msbt, inod, isub, iret, & + integer ibct, ipd1, ipd2, ipd3, ipd4, nby4, nbyt, mtyp, msbt, inod, isub, iret, & mcen, mear, mmon, mday, mour, mmin, mbit character*128 bort_str @@ -790,7 +792,6 @@ subroutine msgini(lun) data sevn /'7777'/ common /padesc/ ibct,ipd1,ipd2,ipd3,ipd4 - common /msgptr/ nby0,nby1,nby2,nby3,nby4,nby5 ! Get the message tag and type, and break up the date @@ -824,12 +825,7 @@ subroutine msgini(lun) ! Initialize the message mbit = 0 - nby0 = 8 - nby1 = 18 - nby2 = 0 - nby3 = 20 nby4 = 4 - nby5 = 4 nbyt = nby0+nby1+nby2+nby3+nby4+nby5 ! Section 0 @@ -848,7 +844,7 @@ subroutine msgini(lun) call pkb( 0 , 8 , mbay(1,lun),mbit) call pkb(mtyp , 8 , mbay(1,lun),mbit) call pkb(msbt , 8 , mbay(1,lun),mbit) - call pkb( 36 , 8 , mbay(1,lun),mbit) + call pkb( mtv , 8 , mbay(1,lun),mbit) call pkb( 0 , 8 , mbay(1,lun),mbit) call pkb(mear , 8 , mbay(1,lun),mbit) call pkb(mmon , 8 , mbay(1,lun),mbit) @@ -878,7 +874,7 @@ subroutine msgini(lun) ! Section 5 - call pkc(sevn , 4 , mbay(1,lun),mbit) + call pkc(sevn ,nby5, mbay(1,lun),mbit) ! Double check initial message length @@ -1204,7 +1200,7 @@ end function lmsg !> @author J. Ator @date 2005-11-29 recursive subroutine getlens (mbay,ll,len0,len1,len2,len3,len4,len5) - use modv_vars, only: im8b + use modv_vars, only: im8b, nby5 implicit none @@ -1253,7 +1249,7 @@ recursive subroutine getlens (mbay,ll,len0,len1,len2,len3,len4,len5) len4 = iupb(mbay,iad4+1,24) if(ll<5) return - len5 = 4 + len5 = nby5 return end subroutine getlens diff --git a/src/readwritesb.F90 b/src/readwritesb.F90 index 620b186a..d17b72a9 100644 --- a/src/readwritesb.F90 +++ b/src/readwritesb.F90 @@ -611,7 +611,7 @@ end subroutine rdmgsb !> @author Woollen @date 1994-01-06 subroutine msgupd(lunit,lun) - use modv_vars, only: iprt + use modv_vars, only: iprt, nby0, nby1, nby2, nby3 use moda_msgcwd use moda_bitbuf @@ -620,14 +620,12 @@ subroutine msgupd(lunit,lun) implicit none integer, intent(in) :: lunit, lun - integer nby0, nby1, nby2, nby3, nby4, nby5, ibyt, lbyt, lbit, nbyt, ii, iupb + integer ibyt, lbyt, lbit, nbyt, ii, iupb logical msgfull character*128 errstr - common /msgptr/ nby0, nby1, nby2, nby3, nby4, nby5 - ! Pad the subset buffer call pad(ibay,ibit,ibyt,8) diff --git a/src/readwriteval.F90 b/src/readwriteval.F90 index 29959077..36147cb3 100644 --- a/src/readwriteval.F90 +++ b/src/readwriteval.F90 @@ -2239,7 +2239,6 @@ recursive subroutine ufbevn(lunit,usr,i1,i2,i3,iret,str) logical nodgt0 common /usrstr/ nnod, ncon, nods(20), nodc(10), ivls(10), kons(10) - common /ufbn3c/ maxevn ! Check for I8 integers diff --git a/src/s013vals.F90 b/src/s013vals.F90 index 0cb81238..e6cc7ed5 100644 --- a/src/s013vals.F90 +++ b/src/s013vals.F90 @@ -245,14 +245,14 @@ end subroutine gets1loc !> @author J. Ator @date 2005-11-29 recursive integer function iupbs01(mbay,s01mnem) result(iret) - use modv_vars, only: im8b + use modv_vars, only: im8b, nby0 implicit none character*(*), intent(in) :: s01mnem integer, intent(in) :: mbay(*) - integer ival, iupb, i4dy, len0, iben, isbyt, iwid, iretgs, iyoc, icen + integer ival, iupb, i4dy, iben, isbyt, iwid, iretgs, iyoc, icen logical ok4cent @@ -277,9 +277,8 @@ recursive integer function iupbs01(mbay,s01mnem) result(iret) return endif - len0 = 8 if(s01mnem=='LEN0') then - iret = len0 + iret = nby0 return endif @@ -295,7 +294,7 @@ recursive integer function iupbs01(mbay,s01mnem) result(iret) call gets1loc(s01mnem,iben,isbyt,iwid,iretgs) if(iretgs==0) then - iret = iupb(mbay,len0+isbyt,iwid) + iret = iupb(mbay,nby0+isbyt,iwid) if(s01mnem=='CENT') then ! Test whether the returned value was a valid century value. diff --git a/src/standard.F90 b/src/standard.F90 index 7ad642b3..4c6369a8 100644 --- a/src/standard.F90 +++ b/src/standard.F90 @@ -73,7 +73,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) use bufrlib - use modv_vars, only: im8b, nbytw + use modv_vars, only: im8b, nbytw, nby5 use moda_s3list @@ -130,7 +130,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) endif mbit = (lenn-4)*8 - call upc(sevn,4,msgin,mbit,.true.) + call upc(sevn,nby5,msgin,mbit,.true.) if(sevn/='7777') then write(bort_str,'("BUFRLIB: STNDRD - INPUT MESSAGE DOES NOT END WITH ""7777"" (ENDS WITH ",A)') sevn call bort(bort_str) @@ -279,7 +279,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) lenn = len0+len1+len2+len3+len4+len5 call pkb(lenn,24,msgot,ibit) - call pkc('7777',4,msgot,jbit) + call pkc('7777',nby5,msgot,jbit) return end subroutine stndrd From 9df759f8699a3c407e33204590655cb3c753aa18 Mon Sep 17 00:00:00 2001 From: Jeff Ator Date: Mon, 16 Dec 2024 17:27:53 +0000 Subject: [PATCH 4/5] parameterize "BUFR" and "7777" strings --- src/CMakeLists.txt | 14 +++++++++++++- src/{bufrlib.h => bufrlib.h.in} | 6 ++++++ src/compress.F90 | 15 ++++++--------- src/cread.c | 4 ++-- src/crwbmg.c | 4 ++-- src/dxtable.F90 | 4 ++-- src/misc.F90.in | 24 +++++++++++------------- src/modules_vars.F90 | 6 ++++++ src/readwritemg.F90 | 26 +++++++++----------------- src/standard.F90 | 14 +++++++------- 10 files changed, 64 insertions(+), 53 deletions(-) rename src/{bufrlib.h => bufrlib.h.in} (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 75514aa6..0a1e62a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,12 +14,24 @@ list(APPEND c_src arallocc.c cpmstabs.c cread.c crwbmg.c cfe.c icvidx.c restd.c stseq.c) list(APPEND c_hdr - cread.h mstabs.h rpseqs.h bufr_interface.h bufrlib.h) + cread.h mstabs.h rpseqs.h bufr_interface.h) # Create the misc.F90 file configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc.F90.in ${CMAKE_CURRENT_BINARY_DIR}/misc.F90 @ONLY) list(APPEND fortran_src ${CMAKE_CURRENT_BINARY_DIR}/misc.F90) +# Create the bufrlib.h file +foreach(_var IN ITEMS bmostr bmcstr) + file(STRINGS modules_vars.F90 _${_var}_tempstr REGEX "character.*${_var}") + if(_${_var}_tempstr MATCHES "= '([A-Z0-9]+)") + set(${_var} ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Unable to parse variable ${_var} value from file modules_vars.F90") + endif() +endforeach() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bufrlib.h.in ${CMAKE_CURRENT_BINARY_DIR}/bufrlib.h @ONLY) +list(APPEND c_hdr ${CMAKE_CURRENT_BINARY_DIR}/bufrlib.h) + include(TestBigEndian) test_big_endian(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN) diff --git a/src/bufrlib.h b/src/bufrlib.h.in similarity index 98% rename from src/bufrlib.h rename to src/bufrlib.h.in index 714b0e35..1a18ba8c 100644 --- a/src/bufrlib.h +++ b/src/bufrlib.h.in @@ -49,6 +49,12 @@ void stseq(int lun, int *irepct, int idn, char *nemo, char *cseq, int *cdesc, in /** Size of a character string needed to store the units of a Table B descriptor. */ #define UNIT_STR_LEN 24 +/** Opening string of a BUFR message. */ +#define BMOSTR "@bmostr@" + +/** Closing string of a BUFR message. */ +#define BMCSTR "@bmcstr@" + /** * Convert an FXY value from its WMO bit-wise representation to its * six-character representation. diff --git a/src/compress.F90 b/src/compress.F90 index 53dca98d..202f1c86 100644 --- a/src/compress.F90 +++ b/src/compress.F90 @@ -196,7 +196,7 @@ subroutine rdcmps(lun) elseif(ityp==3) then ! This is a character element. If there are more than 8 characters, then only the first 8 will be unpacked by this ! routine, and a separate subsequent call to subroutine readlc() will be required to unpack the remainder of the string. - ! In this case, pointers will be saved within common /rlccmn/ for later use within readlc(). + ! In this case, pointers will be saved within module @ref moda_rlccmn for later use within readlc(). lelm = nbit/8 nchr = min(8,lelm) ibsv = ibit @@ -257,7 +257,7 @@ end subroutine rdcmps !> @author Woollen @date 2002-05-14 subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) - use modv_vars, only: mtv, nby1, nby5 + use modv_vars, only: mtv, nby1, nby5, bmostr implicit none @@ -268,11 +268,8 @@ subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) character*128 bort_str character*8, intent(in) :: subset - character*4 bufr character tab - data bufr/'BUFR'/ - ! Get the message tag and type, and break up the date which can be either YYMMDDHH or YYYYMMDDHH call nemtba(lun,subset,mtyp,msbt,inod) @@ -301,7 +298,7 @@ subroutine cmsgini(lun,mesg,subset,idate,nsub,nbyt) ! Section 0 - call pkc(bufr , 4 , mesg,mbit) + call pkc(bmostr, 4 , mesg,mbit) ! Note that the actual Section 0 length will be computed and stored below; for now, we're really only interested in ! advancing mbit by the correct amount, so we'll just store a default value of 0. call pkb( 0 , 24 , mesg,mbit) @@ -377,7 +374,7 @@ end subroutine cmsgini !> order to hold the current subset (still stored for compression). !> !> This subroutine performs functions similar to NCEPLIBS-bufr -!> subroutine msgupd() except that it acts on compressed bufr messages. +!> subroutine msgupd() except that it acts on compressed BUFR messages. !> !> @param lunix - Absolute value is Fortran logical unit number for BUFR file !> - if lunix is less than zero, then this is a "flush" call and the buffer must be cleared out @@ -385,7 +382,7 @@ end subroutine cmsgini !> @author Woollen @date 2002-05-14 subroutine wrcmps(lunix) - use modv_vars, only: mxcdv, mxcsb, nby5 + use modv_vars, only: mxcdv, mxcsb, nby5, bmcstr use moda_usrint use moda_msgcwd @@ -650,7 +647,7 @@ subroutine wrcmps(lunix) ! Add Section 5 - call pkc('7777',nby5,mgwa,ibit) + call pkc(bmcstr,nby5,mgwa,ibit) ! Check that the message byte counters agree, then write the message diff --git a/src/cread.c b/src/cread.c index 4fc18776..5466c167 100644 --- a/src/cread.c +++ b/src/cread.c @@ -120,7 +120,7 @@ crdbufr(int nfile, int *bufr, int mxwrd) { /* Find the start of the next BUFR message within the file. */ fgetpos(pb[nfile], &lstpos[nfile]); - while (strncmp(wkchr, "BUFR", 4) != 0) { + while (strncmp(wkchr, BMOSTR, 4) != 0) { memmove(wkchr, &wkchr[1], 3); if (fread(wkchr + 3, 1, 1, pb[nfile]) != 1) return -1; @@ -173,7 +173,7 @@ crdbufr(int nfile, int *bufr, int mxwrd) { fsetpos(pb[nfile], &nxtpos); return -2; } - if (strncmp(&wkchr[nbytrem-4], "7777", 4) != 0) { + if (strncmp(&wkchr[nbytrem-4], BMCSTR, 4) != 0) { fsetpos(pb[nfile], &nxtpos); return -2; } diff --git a/src/crwbmg.c b/src/crwbmg.c index a7936266..8b1f51f7 100644 --- a/src/crwbmg.c +++ b/src/crwbmg.c @@ -218,7 +218,7 @@ crbmg(char *bmg, int mxmb, int *nmb, int *iret) /* ** Look for the start of the next BUFR message. */ - while (strncmp("BUFR", bmg, 4) != 0) { + while (strncmp(BMOSTR, bmg, 4) != 0) { memmove(bmg, &bmg[1], 3); if ((*iret = rbytes(bmg, mxmb, 3, 1)) != 0) return; } @@ -238,7 +238,7 @@ crbmg(char *bmg, int mxmb, int *nmb, int *iret) /* ** Check that the "7777" is in the expected location. */ - *iret = ((strncmp("7777", &bmg[*nmb-4], 4) == 0) ? 0 : 2); + *iret = ((strncmp(BMCSTR, &bmg[*nmb-4], 4) == 0) ? 0 : 2); return; } diff --git a/src/dxtable.F90 b/src/dxtable.F90 index 92aa4185..ade6d256 100644 --- a/src/dxtable.F90 +++ b/src/dxtable.F90 @@ -693,7 +693,7 @@ end subroutine dxinit !> @author Woollen @date 1994-01-06 subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd) - use modv_vars, only: mxmsgld4, mtv, nby0, nby1, nby2, nby5 + use modv_vars, only: mxmsgld4, mtv, nby0, nby1, nby2, nby5, bmostr implicit none @@ -734,7 +734,7 @@ subroutine dxmini(mbay,mbyt,mb4,mba,mbb,mbd) ! Section 0 - call pkc('BUFR' , 4 , mbay,mbit) + call pkc(bmostr , 4 , mbay,mbit) call pkb( mbyt , 24 , mbay,mbit) call pkb( 3 , 8 , mbay,mbit) diff --git a/src/misc.F90.in b/src/misc.F90.in index 183043bc..a90b96fb 100644 --- a/src/misc.F90.in +++ b/src/misc.F90.in @@ -55,7 +55,7 @@ subroutine bfrini data nldxd / 38 , 70 , 8*0 / data nld30 / 5 , 6 , 8*0 / - ! Initialize module moda_bitbuf + ! Initialize module @ref moda_bitbuf maxbyt = min(10000,mxmsgl) @@ -67,26 +67,26 @@ subroutine bfrini ipd3 = ifxy('206001') ipd4 = ifxy('063255') - ! Initialize module moda_stbfr + ! Initialize module @ref moda_stbfr do i=1,nfiles iolun(i) = 0 iomsg(i) = 0 enddo - ! Initialize module moda_idrdm + ! Initialize module @ref moda_idrdm do i=1,nfiles idrdm(i) = 0 enddo - ! Initialize module moda_msglim + ! Initialize module @ref moda_msglim do i=1,nfiles msglim(i) = 3 enddo - ! Initialize module moda_usrint + ! Initialize module @ref moda_usrint do i=1,nfiles nval(i) = 0 @@ -98,7 +98,7 @@ subroutine bfrini idnr(i) = ifxy(adsn(i)) enddo - ! Initialize module moda_tababd + ! Initialize module @ref moda_tababd ! ntba(0) is the maximum number of entries within internal BUFR table A ntba(0) = maxtba @@ -126,7 +126,7 @@ subroutine bfrini enddo enddo - ! Initialize module moda_bufrmg + ! Initialize module @ref moda_bufrmg do i=1,nfiles msglen(i) = 0 @@ -139,13 +139,13 @@ subroutine bfrini namb = 0 ntot = 0 - ! Initialize module moda_bufrsr + ! Initialize module @ref moda_bufrsr do i=1,nfiles jsr(i) = 0 enddo - ! Initialize module moda_dscach + ! Initialize module @ref moda_dscach ncnem = 0 @@ -357,10 +357,8 @@ subroutine capit(str) integer i, j character*(*), intent(inout) :: str - character*26 upcs, lwcs - - data upcs /'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ - data lwcs /'abcdefghijklmnopqrstuvwxyz'/ + character*26, parameter :: upcs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + character*26, parameter :: lwcs = 'abcdefghijklmnopqrstuvwxyz' do i=1,len(str) do j=1,26 diff --git a/src/modules_vars.F90 b/src/modules_vars.F90 index fc49b6c6..df3b1d8c 100644 --- a/src/modules_vars.F90 +++ b/src/modules_vars.F90 @@ -330,6 +330,12 @@ module modv_vars !> Number of bytes in Section 5 of a BUFR message. integer, parameter :: nby5 = 4 + !> Opening string of a BUFR message. + character*4, parameter :: bmostr = 'BUFR' + + !> Closing string of a BUFR message. + character*4, parameter :: bmcstr = '7777' + !> Master table for the last BUFR message that was read from a logical unit where !> Section 3 decoding is being used. !> This value is initialized to an artificially low number, in order to ensure that new diff --git a/src/readwritemg.F90 b/src/readwritemg.F90 index ffacaf02..eeca94e6 100644 --- a/src/readwritemg.F90 +++ b/src/readwritemg.F90 @@ -213,7 +213,7 @@ end function ireadmg !> @authors J. Woollen J. Ator @date 1995-06-28 recursive subroutine readerme(mesg,lunit,subset,jdate,iret) - use modv_vars, only: mxmsgl, im8b, nbytw, iprt + use modv_vars, only: mxmsgl, im8b, nbytw, iprt, bmostr use moda_sc3bfr use moda_idrdm @@ -272,7 +272,7 @@ recursive subroutine readerme(mesg,lunit,subset,jdate,iret) ! Confirm that the first 4 bytes of SEC0 contain 'BUFR'. - if(sec0(1:4)/='BUFR') & + if(sec0(1:4)/=bmostr) & call bort('BUFRLIB: READERME - FIRST 4 BYTES READ FROM RECORD NOT "BUFR", DOES NOT CONTAIN BUFR DATA') ! Parse the message section contents @@ -594,7 +594,7 @@ subroutine msgwrt(lunit,mesg,mgbyt) use bufrlib - use modv_vars, only: mxmsgld4, iprt, nby5 + use modv_vars, only: mxmsgld4, iprt, nby5, bmostr, bmcstr use moda_nulbfr use moda_bufrmg @@ -611,10 +611,6 @@ subroutine msgwrt(lunit,mesg,mgbyt) nmwrd, iupbs01, idxmsg character*128 errstr - character*4 bufr, sevn - - data bufr /'BUFR'/ - data sevn /'7777'/ ! Make a local copy of the input message for use within this subroutine, since internal calls to any or all of the ! subroutines stndrd(), cnved4(), pkbs1(), atrcpt(), etc. may end up modifying the message before it finally gets @@ -665,7 +661,7 @@ subroutine msgwrt(lunit,mesg,mgbyt) ibit = 32 call pkb(mbyt,24,mgwa,ibit) ibit = (mbyt-4)*8 - call pkc(sevn,nby5,mgwa,ibit) + call pkc(bmcstr,nby5,mgwa,ibit) call stndrd(lunit,mgwa,mxmsgld4,mgwb) ! Compute mbyt for the new standardized message mbyt = iupbs01(mgwb,'LENM') @@ -718,11 +714,11 @@ subroutine msgwrt(lunit,mesg,mgbyt) ! Write Section 0 byte count and Section 5 ibit = 0 - call pkc(bufr, 4,mgwa,ibit) + call pkc(bmostr, 4,mgwa,ibit) call pkb(mbyt,24,mgwa,ibit) kbit = (mbyt-4)*8 - call pkc(sevn,nby5,mgwa,kbit) + call pkc(bmcstr,nby5,mgwa,kbit) ! Zero out the extra bytes which will be written. Note that the BUFR message is stored within the integer array mgwa(*), ! (rather than within a character array), so we need to make sure that the "7777" Is followed by zeroed-out bytes up to @@ -770,7 +766,7 @@ end subroutine msgwrt !> @author Woollen @date 1994-01-06 subroutine msgini(lun) - use modv_vars, only: mtv, nby0, nby1, nby2, nby3, nby5 + use modv_vars, only: mtv, nby0, nby1, nby2, nby3, nby5, bmostr, bmcstr use moda_msgcwd use moda_ufbcpl @@ -785,12 +781,8 @@ subroutine msgini(lun) character*128 bort_str character*8 subtag - character*4 bufr, sevn character tab - data bufr /'BUFR'/ - data sevn /'7777'/ - common /padesc/ ibct,ipd1,ipd2,ipd3,ipd4 ! Get the message tag and type, and break up the date @@ -830,7 +822,7 @@ subroutine msgini(lun) ! Section 0 - call pkc(bufr , 4 , mbay(1,lun),mbit) + call pkc(bmostr, 4 , mbay(1,lun),mbit) call pkb(nbyt , 24 , mbay(1,lun),mbit) call pkb( 3 , 8 , mbay(1,lun),mbit) @@ -874,7 +866,7 @@ subroutine msgini(lun) ! Section 5 - call pkc(sevn ,nby5, mbay(1,lun),mbit) + call pkc(bmcstr,nby5, mbay(1,lun),mbit) ! Double check initial message length diff --git a/src/standard.F90 b/src/standard.F90 index 4c6369a8..c41b723c 100644 --- a/src/standard.F90 +++ b/src/standard.F90 @@ -73,7 +73,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) use bufrlib - use modv_vars, only: im8b, nbytw, nby5 + use modv_vars, only: im8b, nbytw, nby5, bmcstr use moda_s3list @@ -87,7 +87,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) character*128 bort_str character*8 subset - character*4 sevn + character*4 s5str character*1 tab character*(*), parameter :: bort_arrayoverflow = & 'BUFRLIB: STNDRD - OVERFLOW OF OUTPUT (STANDARD) MESSAGE ARRAY; TRY A LARGER DIMENSION FOR THIS ARRAY' @@ -107,7 +107,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) return endif - ! lunit must point to an open bufr file. + ! lunit must point to an open BUFR file. call status(lunit,lun,il,im) if(il==0) call bort('BUFRLIB: STNDRD - BUFR FILE IS CLOSED, IT MUST BE OPEN') @@ -130,9 +130,9 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) endif mbit = (lenn-4)*8 - call upc(sevn,nby5,msgin,mbit,.true.) - if(sevn/='7777') then - write(bort_str,'("BUFRLIB: STNDRD - INPUT MESSAGE DOES NOT END WITH ""7777"" (ENDS WITH ",A)') sevn + call upc(s5str,nby5,msgin,mbit,.true.) + if(s5str/=bmcstr) then + write(bort_str,'("BUFRLIB: STNDRD - INPUT MESSAGE DOES NOT END WITH ""7777"" (ENDS WITH ",A)') s5str call bort(bort_str) endif @@ -279,7 +279,7 @@ recursive subroutine stndrd(lunit,msgin,lmsgot,msgot) lenn = len0+len1+len2+len3+len4+len5 call pkb(lenn,24,msgot,ibit) - call pkc('7777',nby5,msgot,jbit) + call pkc(bmcstr,nby5,msgot,jbit) return end subroutine stndrd From 0eaa22a2441c4ad2ca2d01947a1a17939110eadc Mon Sep 17 00:00:00 2001 From: Jeff Ator Date: Mon, 16 Dec 2024 20:58:16 +0000 Subject: [PATCH 5/5] fix punctuation in modules_arrs comments --- src/modules_arrs.F90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules_arrs.F90 b/src/modules_arrs.F90 index dc3ad8ff..98b72063 100644 --- a/src/modules_arrs.F90 +++ b/src/modules_arrs.F90 @@ -496,17 +496,17 @@ end module moda_nrv203 !> !> @author J. Ator @date 2024-12-10 module moda_tabccc - ! Number of bits by which to modify the data width of subsequent jump/link table mnemonics whose - ! type indicator is "NUM"; set to 0 unless a 2-01-YYY or 2-07-YYY operator is in effect. + !> Number of bits by which to modify the data width of subsequent jump/link table mnemonics whose + !> type indicator is "NUM"; set to 0 unless a 2-01-YYY or 2-07-YYY operator is in effect. integer :: icdw - ! Number by which to modify the scale of subsequent jump/link table mnemonics whose type - ! indicator is "NUM"; set to 0 unless a 2-02-YYY or 2-07-YYY operator is in effect. + !> Number by which to modify the scale of subsequent jump/link table mnemonics whose type + !> indicator is "NUM"; set to 0 unless a 2-02-YYY or 2-07-YYY operator is in effect. integer :: icsc - ! Factor by which to multiply the reference value of subsequent jump/link table mnemonics - ! whose type indicator is "NUM"; set to 1 unless a 2-07-YYY operator is in effect. + !> Factor by which to multiply the reference value of subsequent jump/link table mnemonics + !> whose type indicator is "NUM"; set to 1 unless a 2-07-YYY operator is in effect. integer :: icrv - ! New data width (in bytes) for subsequent jump/link table mnemonics whose type indicator - ! is "CHR"; set to 0 unless a 2-08-YYY operator is in effect. + !> New data width (in bytes) for subsequent jump/link table mnemonics whose type indicator + !> is "CHR"; set to 0 unless a 2-08-YYY operator is in effect. integer :: incw end module moda_tabccc