Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added more CI testing #456

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .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-5
key: data-6

- name: build
run: |
Expand All @@ -71,5 +71,3 @@ jobs:
run: |
mkdir ~/data
cp $GITHUB_WORKSPACE/bufr/build/test/bufr-11.6.0.tgz ~/data


3 changes: 1 addition & 2 deletions .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-5
key: data-6

- name: build
run: |
Expand Down Expand Up @@ -73,4 +73,3 @@ jobs:
run: |
mkdir ~/data
cp $GITHUB_WORKSPACE/bufr/build/test/bufr-11.6.0.tgz ~/data

3 changes: 1 addition & 2 deletions .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-5
key: data-6

- name: build-bufr
run: |
Expand All @@ -60,4 +60,3 @@ jobs:
run: |
mkdir ~/data
cp $GITHUB_WORKSPACE/bufr/build/test/bufr-11.6.0.tgz ~/data

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-5
key: data-6

- name: build
run: |
Expand Down
20 changes: 10 additions & 10 deletions src/status.f
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ RECURSIVE SUBROUTINE STATUS(LUNIT,LUN,IL,IM)

IF(LUNIT.LE.0 .OR. LUNIT.GT.99) GOTO 900

IF ( .NOT. ALLOCATED(IOLUN) ) THEN
CALL ERRWRT('++++++++++++++++++++WARNING++++++++++++++++++++++')
ERRSTR = 'BUFRLIB: STATUS WAS CALLED WITHOUT HAVING ' //
. 'PREVIOUSLY CALLED OPENBF'
CALL ERRWRT(ERRSTR)
CALL ERRWRT('++++++++++++++++++++WARNING++++++++++++++++++++++')
RETURN
ENDIF

C CLEAR THE STATUS INDICATORS
C ---------------------------

Expand All @@ -81,8 +72,17 @@ RECURSIVE SUBROUTINE STATUS(LUNIT,LUN,IL,IM)
C SEE IF UNIT IS ALREADY CONNECTED TO BUFR ARCHIVE LIBRARY SOFTWARE
C -----------------------------------------------------------------

IF ( .NOT. ALLOCATED(IOLUN) ) THEN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should call bort().

I don't see how the user can proceed with any function which tries to call status() before initialization of the internal arrays. So even if status() issues a warning and returns, there will still be a segfault when the function calling status tries to use internal memory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since status returns lun=0 in this case, the program will know that openbf has not been called yet and could then do that. In other words it could be asking that question. But there is ambiguity because lun returned as zero could also mean there is no more table space to open a file, which is a different matter with a different solution. Lun could return -1 in one case to clear that up. Plus there should also be at least an errwrt if there's no more file table space. Thanks @edwardhartnett for pointing out the contradiction. And certainly borting is also a reasonable alternative for either problem.

CALL ERRWRT('++++++++++++++++++++WARNING++++++++++++++++++++++')
ERRSTR = 'BUFRLIB: STATUS WAS CALLED WITHOUT HAVING ' //
. 'PREVIOUSLY CALLED OPENBF'
CALL ERRWRT(ERRSTR)
CALL ERRWRT('++++++++++++++++++++WARNING++++++++++++++++++++++')
RETURN
ENDIF

DO I=1,NFILES
IF(ABS(IOLUN(I)).EQ.LUNIT) LUN = I
IF(ABS(IOLUN(I)).EQ.LUNIT) LUN = I
ENDDO

C IF NOT, TRY TO DEFINE IT SO AS TO CONNECT IT TO BUFR ARCHIVE LIBRARY
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ foreach(kind ${test_kinds})
foreach(innum RANGE 1 10)
create_test(intest ${kind} ${innum})
endforeach()
foreach(outnum RANGE 1 9)
foreach(outnum RANGE 1 10)
create_test(outtest ${kind} ${outnum})
endforeach()
endforeach()
Expand Down
19 changes: 15 additions & 4 deletions test/intest4.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ program intest4

implicit none

integer*4 ireadsb, iupbs01, iupbs3, ibfms
integer*4 ireadsb, iupbs01, iupbs3, ibfms, lmsg, nmwrd
integer*4 mxbf, nbyt, ierr

integer ier, imgdt, nds3
integer ier, imgdt, nds3, ii
integer nr8lv, ntag

integer mxbfd4, mxds3, mxr8lv, mxr8pm
Expand All @@ -26,7 +26,7 @@ program intest4

integer ibfmg (mxbfd4)

character cmgtag*8, bfmg(mxbf), cds3(mxds3)*6, tag*8
character cmgtag*8, bfmg(mxbf), cds3(mxds3)*6, tag*8, sec0*8, cbay*3
character*20 filnam / 'testfiles/IN_4' /
character filost / 'r' /

Expand Down Expand Up @@ -73,7 +73,7 @@ program intest4

! Pass the message into the library so that Section 4 data can be read.
call readerme(ibfmg, 11, cmgtag, imgdt, ier)
If (ier .ne. 0 .or. cmgtag .ne. 'MSTTB001' .or. imgdt .ne. 2016041815 ) stop 5
if (ier .ne. 0 .or. cmgtag .ne. 'MSTTB001' .or. imgdt .ne. 2016041815 ) stop 5

! Read a data subset from the BUFR message.
if (ireadsb(11) .ne. 0) stop 6
Expand All @@ -98,6 +98,17 @@ program intest4
call gettagre(11, '224255', 65, tag, ntag, ier)
if ( ier .ne. 0 .or. ntag .ne. 10 .or. tag .ne. 'RDNE ' ) stop 12

! Check the output from lmsg, nmwrd, and ipkm.
do ii = 1, 8
sec0(ii:ii) = bfmg(ii)
end do
if ( lmsg(sec0) .ne. 898 ) stop 13
if ( nmwrd(ibfmg) .ne. 898 ) stop 14
call ipkm(cbay,3,3588)
do ii = 1, 3
if ( cbay(ii:ii) .ne. sec0(ii+4:ii+4) ) stop 15
end do

! Close the test file.
call ccbfl_c()

Expand Down
104 changes: 104 additions & 0 deletions test/outtest10.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
! This is a test for NCEPLIBS-bufr.
!
! Writes test file 'testfiles/OUT_10' with subsets larger than 65530 bytes and non-matching BUFR DX tables
!
! J. Ator, 4/20/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 NCEPLIBS-bufr software.

character*1500 errstr

integer errstr_len
end module Share_errstr

subroutine errwrt(str)
! This subroutine supersedes the subroutine of the same name within the NCEPLIBS-bufr 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 outtest10
use Share_errstr

implicit none

integer*4 ireadmg

integer iostat1, iostat2, iostat3, iostat4, mesgtyp, icomp, jdate, mgct, iret
! integer iostat1, iostat2, iostat3, iostat4, jdate, mgct, iret

character subset*8

print *, 'Testing writing OUT_10 with subsets larger than 65530 bytes and non-matching BUFR DX tables'

#ifdef KIND_8
call setim8b ( .true. )
#endif

errstr_len = 0

! Open the files.
open ( unit = 21, file = 'testfiles/OUT_10_infile1', iostat = iostat1 )
open ( unit = 22, file = 'testfiles/OUT_10_infile2', iostat = iostat2 )
open ( unit = 23, file = 'testfiles/OUT_10_bufrtab', iostat = iostat3 )
open ( unit = 50, file = 'out10.bufr', form = 'unformatted', iostat = iostat4 )
if ( ( iostat1 .ne. 0 ) .or. ( iostat2 .ne. 0 ) .or. ( iostat3 .ne. 0 ) .or. ( iostat4 .ne. 0 ) ) stop 1

! Get some information from infile1.
call mesgbc ( 21, mesgtyp, icomp )
if ( ( mesgtyp .ne. -11 ) .or. ( icomp .ne. -2 ) ) stop 2

! (Re)open infile1 since the call to mesgbc will have closed it.
rewind ( 21 )
open ( unit = 21, file = 'testfiles/OUT_10_infile1', iostat = iostat1 )
if ( iostat1 .ne. 0 ) stop 3

! Open infile2 and the output file to the library.
call openbf ( 21, 'IN', 21 )
call openbf ( 22, 'IN', 23 )
call maxout ( 150000 )
call openbf ( 50, 'OUT', 21 )

! Turn on verbose output so can check error strings.
call openbf ( 21, 'QUIET', 1 )

! Copy 5 data subsets from infile2 to the output file. Each data subset is inside of its own message,
! even though only subsets 1, 3, and 5 are larger than 65530 bytes. The first 3 copies will exercise
! logic in cpyupd, and the last 2 will exercise logic in msgupd.
mgct = 0
do while ( ireadmg ( 22, subset, jdate ) .eq. 0 )
mgct = mgct + 1
errstr_len = 0
call openmb ( 50, subset, jdate )
if ( mgct .le. 3 ) then
call copysb ( 22, 50, iret )
if ( iret .ne. 0 ) stop 4
if ( ( mod(mgct,2) .eq. 1 ) .and. &
index( errstr(1:errstr_len), 'CPYUPD - SUBSET HAS BYTE COUNT =' ) .eq. 0 ) stop 5
else
call readsb ( 22, iret )
if ( iret .ne. 0 ) stop 6
call ufbcpy ( 22, 50 )
call writsb ( 50 )
if ( ( mod(mgct,2) .eq. 1 ) .and. &
index( errstr(1:errstr_len), 'MSGUPD - SUBSET HAS BYTE COUNT =' ) .eq. 0 ) stop 7
end if
end do

! Close the output file.
call closbf ( 50 )

end program outtest10