diff --git a/.github/workflows/Intel.yml b/.github/workflows/Intel.yml index 6fd766ab..f95f6d45 100644 --- a/.github/workflows/Intel.yml +++ b/.github/workflows/Intel.yml @@ -50,7 +50,7 @@ jobs: uses: actions/cache@v2 with: path: ~/data - key: data-3 + key: data-4 - name: build run: | diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index 132fa83f..97db7fcd 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -41,7 +41,7 @@ jobs: uses: actions/cache@v2 with: path: ~/data - key: data-3 + key: data-4 - name: build run: | diff --git a/.github/workflows/MacOS.yml b/.github/workflows/MacOS.yml index cb6cbb51..7b6e7949 100644 --- a/.github/workflows/MacOS.yml +++ b/.github/workflows/MacOS.yml @@ -37,7 +37,7 @@ jobs: uses: actions/cache@v2 with: path: ~/data - key: data-3 + key: data-4 - name: build-bufr run: | diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 8671af16..8984fd40 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -38,7 +38,7 @@ jobs: uses: actions/cache@v2 with: path: ~/data - key: data-3 + key: data-4 - name: build run: | diff --git a/src/openbf.f b/src/openbf.f index ebd95b01..3fa672be 100644 --- a/src/openbf.f +++ b/src/openbf.f @@ -169,18 +169,19 @@ RECURSIVE SUBROUTINE OPENBF(LUNIT,IO,LUNDX) IF(IO.EQ.'QUIET') THEN c .... override previous IPRT value (printout indicator) - IF(LUNDX.LT.-1) LUNDX = -1 - IF(LUNDX.GT. 2) LUNDX = 2 - IF(LUNDX.GE.0) THEN + IPRTPRV = IPRT + IPRT = LUNDX + IF(IPRT.LT.-1) IPRT = -1 + IF(IPRT.GT. 2) IPRT = 2 + IF(IPRT.GE.0) THEN CALL ERRWRT('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++') WRITE ( UNIT=ERRSTR, FMT='(A,I3,A,A,I3,A)' ) . 'BUFRLIB: OPENBF - DEGREE OF MESSAGE PRINT INDICATOR '// - . 'CHNGED FROM',IPRT,CPRINT(IPRT+1),' TO',LUNDX,CPRINT(LUNDX+1) + . 'CHNGED FROM',IPRTPRV,CPRINT(IPRTPRV+1),' TO',IPRT,CPRINT(IPRT+1) CALL ERRWRT(ERRSTR) CALL ERRWRT('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++') CALL ERRWRT(' ') ENDIF - IPRT = LUNDX ENDIF IF(IFOPBF.EQ.0) THEN diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9b4c4de9..d5424056 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -115,7 +115,7 @@ foreach(test_script ${test_scripts}) endforeach() foreach(kind ${test_kinds}) - foreach(innum RANGE 1 9) + foreach(innum RANGE 1 10) create_test(intest ${kind} ${innum}) endforeach() foreach(outnum RANGE 1 9) diff --git a/test/intest10.F90 b/test/intest10.F90 new file mode 100644 index 00000000..3ac3d80b --- /dev/null +++ b/test/intest10.F90 @@ -0,0 +1,99 @@ +! This is a test for NCEPLIBS-bufr. +! +! Reads test file 'testfiles/IN_10' to test ERRWRT branches in ARALLOCF, UFBMEM, UFBMEX, and OPENBT. +! +! J. Ator, 3/13/2023 + +module Share_errstr + ! This module is needed in order to share information between the test program and subroutine errwrt, because + ! the latter is not called by the former but rather is called directly from within the BUFRLIB software. + + character*4000 errstr + + integer errstr_len +end module Share_errstr + +subroutine errwrt(str) + ! This subroutine supersedes the subroutine of the same name within the BUFRLIB software, so that we can + ! easily test the generation of error messages from within the library. + + use Share_errstr + + character*(*) str + + integer str_len + + str_len = len(str) + errstr ( errstr_len + 1 : errstr_len + str_len + 1 ) = str + errstr_len = errstr_len + str_len + + return +end subroutine errwrt + +program intest10 + use Share_errstr + + implicit none + + integer*4 isetprm + + integer icnt, iunt, imesg(150), idate, iret, ios1, ios2, lundx + + character cmgtag*8 + + print *, 'Testing reading IN_10 to test ERRWRT branches in ARALLOCF, UFBMEM, UFBMEX, and OPENBT' + +#ifdef KIND_8 + call setim8b ( .true. ) +#endif + + if ( ( isetprm ( 'MAXMSG', 125 ) .ne. 0 ) .or. ( isetprm ( 'MAXMEM', 125000 ) .ne. 0 ) ) stop 1 + + ! Test some various out-of-bounds verbosity settings, and test the errwrt branch in arallocf. + ! The verbosity level is the 3rd argument whenever the 2nd argument to openbf is 'QUIET'. Any + ! request greater than 3 should automatically reset internally to the max value of 2, and any + ! request less than -1 should automatically reset internally to the min value of -1. + errstr_len = 0 + call openbf ( 21, 'QUIET', 3 ) + if ( index( errstr(1:errstr_len), 'ARRAYS WILL BE DYNAMICALLY ALLOCATED USING THE FOLLOWING VALUES' ) .eq. 0 ) stop 2 + call openbf ( 21, 'QUIET', -2 ) + call openbf ( 21, 'QUIET', 1 ) + + ! Test the errwrt branches in ufbmem. + open ( unit = 21, file = 'testfiles/IN_10_infile1', form = 'unformatted', iostat = ios1 ) + open ( unit = 22, file = 'testfiles/IN_10_infile2', form = 'unformatted', iostat = ios2 ) + if ( ( ios1 .ne. 0 ) .or. ( ios2 .ne. 0 ) ) stop 3 + errstr_len = 0 + call ufbmem ( 21, 0, icnt, iunt ) + if ( ( icnt .ne. 125 ) .or. & + ( index( errstr(1:errstr_len), 'UFBMEM - THE NO. OF MESSAGES REQUIRED TO STORE ALL MESSAGES' ) .eq. 0 ) ) stop 4 + call ufbmem ( 22, 0, icnt, iunt ) + if ( ( icnt .ne. 97 ) .or. & + ( index( errstr(1:errstr_len), 'UFBMEM - THE NO. OF BYTES REQUIRED TO STORE ALL MESSAGES' ) .eq. 0 ) ) stop 5 + + ! Reset the input files. + call closbf ( 21 ) + call closbf ( 22 ) + open ( unit = 21, file = 'testfiles/IN_10_infile1', form = 'unformatted', iostat = ios1 ) + open ( unit = 22, file = 'testfiles/IN_10_infile2', form = 'unformatted', iostat = ios2 ) + if ( ( ios1 .ne. 0 ) .or. ( ios2 .ne. 0 ) ) stop 6 + + ! Test the errwrt branches in ufbmex. + errstr_len = 0 + call ufbmex ( 21, 21, 0, icnt, imesg ) + if ( ( icnt .ne. 125 ) .or. & + ( index( errstr(1:errstr_len), 'UFBMEX - THE NO. OF MESSAGES REQUIRED TO STORE ALL MESSAGES' ) .eq. 0 ) ) stop 7 + call ufbmex ( 22, 22, 0, icnt, imesg ) + if ( ( icnt .ne. 97 ) .or. & + ( index( errstr(1:errstr_len), 'UFBMEX - THE NO. OF BYTES REQUIRED TO STORE ALL MESSAGES' ) .eq. 0 ) ) stop 8 + + ! Test the errwrt branch in openbt, both indirectly and directly. + errstr_len = 0 + call rdmemm ( 50, cmgtag, idate, iret ) + if ( index( errstr(1:errstr_len), 'OPENBT - THIS IS A DUMMY BUFRLIB ROUTINE' ) .eq. 0 ) stop 9 + errstr_len = 0 + call openbt ( lundx, 255 ) + if ( index( errstr(1:errstr_len), 'OPENBT - THIS IS A DUMMY BUFRLIB ROUTINE' ) .eq. 0 ) stop 10 + + print *, 'SUCCESS!' +end program intest10 diff --git a/test/intest7.F90 b/test/intest7.F90 index be52ffec..ba74773c 100644 --- a/test/intest7.F90 +++ b/test/intest7.F90 @@ -60,7 +60,7 @@ program intest7 ! Check error messages in ISETPRM. iret = isetprm ( 'MXNRV', 5 ) if ( iret .ne. 0 ) stop 1 - errstr_len = 1 + errstr_len = 0 iret = isetprm ( 'DUMMY', 20 ) if ( ( iret .ne. -1 ) .or. & ( index( errstr(1:errstr_len), 'ISETPRM - UNKNOWN INPUT PARAMETER DUMMY' ) .eq. 0 ) ) stop 2 @@ -74,7 +74,7 @@ program intest7 ! Check error messages in IGETPRM. iret = igetprm ( 'MXNRV' ) if ( iret .ne. 5 ) stop 3 - errstr_len = 1 + errstr_len = 0 iret = igetprm ( 'DUMMY' ) if ( ( iret .ne. -1 ) .or. & ( index( errstr(1:errstr_len), 'IGETPRM - UNKNOWN INPUT PARAMETER DUMMY' ) .eq. 0 ) ) stop 4 @@ -85,11 +85,11 @@ program intest7 call ufbrep ( 11, r8arr, mxr8pm, mxr8lv, nr8v, 'TIDER' ) if ( ( nr8v .ne. 2 ) .or. & ( nint ( r8arr(1,1) ) .ne. -10000 ) .or. ( nint ( r8arr(1,2) ) .ne. 16 ) ) stop 6 - errstr_len = 1 + errstr_len = 0 call ufbrep ( 11, r8val, 1, 1, nr8v, 'DUMMY' ) idx = index( errstr(1:errstr_len), 'UFBREP - NO SPECIFIED VALUES READ IN' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 7 - errstr_len = 1 + errstr_len = 0 call ufbrep ( 11, r8val, 0, 1, nr8v, 'TIDER' ) idx = index( errstr(1:errstr_len), 'UFBREP - 3rd ARG. (INPUT) IS .LE. 0' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 8 @@ -100,11 +100,11 @@ program intest7 if ( ( nr8v .ne. 1 ) .or. & ( nint ( r8arr(1,1)*100000 ) .ne. 2001191 ) .or. ( nint ( r8arr(2,1)*100000 ) .ne. -3785017 ) .or. & ( nint ( r8arr(3,1)*100 ) .ne. 30035 ) .or. ( nint ( r8arr(4,1) ) .ne. 2187000 ) ) stop 9 - errstr_len = 1 + errstr_len = 0 call ufbint ( 11, r8val, 1, 1, nr8v, 'DUMMY' ) idx = index( errstr(1:errstr_len), 'UFBINT - NO SPECIFIED VALUES READ IN' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 10 - errstr_len = 1 + errstr_len = 0 call ufbint ( 11, r8val, 1, 0, nr8v, 'TMDB' ) idx = index( errstr(1:errstr_len), 'UFBINT - 4th ARG. (INPUT) IS .LE. 0' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 11 @@ -115,11 +115,11 @@ program intest7 if ( ( nr8v .ne. 1 ) .or. & ( nint ( r8arr(1,1)*100 ) .ne. 3163 ) .or. ( nint ( r8arr(2,1)*100 ) .ne. -11017 ) .or. & ( nint ( r8arr(3,1) ) .ne. 1205 ) ) stop 12 - errstr_len = 1 + errstr_len = 0 call ufbstp ( 11, r8val, 1, 1, nr8v, 'DUMMY' ) idx = index( errstr(1:errstr_len), 'UFBSTP - NO SPECIFIED VALUES READ IN' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 13 - errstr_len = 1 + errstr_len = 0 call ufbstp ( 11, r8val, 1, 0, nr8v, 'CLON' ) idx = index( errstr(1:errstr_len), 'UFBSTP - 4th ARG. (INPUT) IS .LE. 0' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 14 @@ -130,11 +130,11 @@ program intest7 if ( ( nr8v .ne. 1 ) .or. & ( nint ( r8arr(6,1)*100000 ) .ne. 2967000 ) .or. ( nint ( r8arr(7,1)*100000 ) .ne. -9512833 ) .or. & ( nint ( r8arr(5,1) ) .ne. 482011039 ) ) stop 15 - errstr_len = 1 + errstr_len = 0 call ufbseq ( 11, r8val, 1, 1, nr8v, 'DUMMY' ) idx = index( errstr(1:errstr_len), 'UFBSEQ - NO SPECIFIED VALUES READ IN' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 16 - errstr_len = 1 + errstr_len = 0 call ufbseq ( 11, r8val, 0, 1, nr8v, 'CLON' ) idx = index( errstr(1:errstr_len), 'UFBSEQ - 3rd ARG. (INPUT) IS .LE. 0' ) if ( ( nr8v .ne. 0 ) .or. ( idx .eq. 0 ) ) stop 17 @@ -144,7 +144,7 @@ program intest7 if ( ( nsub .ne. 402 ) .or. ( ibfms ( r8val ) .ne. 1 ) ) stop 18 ! Test the error handling inside of VALX. - errstr_len = 1 + errstr_len = 0 r8val = valx ( '75.DUMMY' ) if ( ( index( errstr(1:errstr_len), 'VALX - ERROR READING STRING' ) .eq. 0 ) ) stop 19 diff --git a/test/outtest9.F90 b/test/outtest9.F90 index c6f0de01..353417ee 100644 --- a/test/outtest9.F90 +++ b/test/outtest9.F90 @@ -108,6 +108,7 @@ program outtest9 call closmg (21) ! Check the invmrg output. + errstr_len = 0 call mrginv if ( ( index( errstr(1:errstr_len), 'NUMBER OF DRB EXPANSIONS = 3' ) .eq. 0 ) .or. & ( index( errstr(1:errstr_len), 'NUMBER OF MERGES = 42' ) .eq. 0 ) ) stop 10