Skip to content

Commit

Permalink
Merge branch 'develop' into ejh_error_3
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett authored Mar 16, 2023
2 parents 1ae3a36 + bddfcaa commit 1dee10b
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/data
key: data-3
key: data-4

- name: build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/data
key: data-3
key: data-4

- name: build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/data
key: data-3
key: data-4

- name: build-bufr
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/data
key: data-3
key: data-4

- name: build
run: |
Expand Down
11 changes: 6 additions & 5 deletions src/openbf.f
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
99 changes: 99 additions & 0 deletions test/intest10.F90
Original file line number Diff line number Diff line change
@@ -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
22 changes: 11 additions & 11 deletions test/intest7.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/outtest9.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1dee10b

Please sign in to comment.