-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from AlexanderRichert-NOAA/unit_tests_may24
Add unit tests
- Loading branch information
Showing
14 changed files
with
180 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
program test_aea | ||
integer, parameter :: nchar=4 | ||
character*1 :: ia(nchar), ie(nchar), ie_ref(nchar) | ||
integer nc | ||
nc = -nchar | ||
ia(1) = 'a' | ||
ia(2) = 'A' | ||
ia(3) = 'b' | ||
ia(4) = 'B' | ||
call aea(ia, ie, nc) | ||
!! Uncomment to regenerate baseline data: | ||
! open(12, file='data/baseline/aea',access='direct',recl=nchar) | ||
! write(12, rec=1) ie | ||
! close(12) | ||
open(11, file='data/baseline/aea', access='direct',recl=nchar) | ||
read(11, rec=1) ie_ref | ||
close(11) | ||
if (any(ie.ne.ie_ref)) stop 1 | ||
nc = nchar | ||
call aea(ia, ie, nc) | ||
if (ia(1).ne.'a' .or. ia(2).ne.'A' .or. ia(3).ne.'b' .or. ia(4).ne.'B') stop 2 | ||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
program test_errexit | ||
character(len=1) :: iret_char | ||
integer :: iret | ||
call get_command_argument(1, iret_char) | ||
read(iret_char, '(i2)') iret | ||
call errexit(iret) | ||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
for i in 0 1; do | ||
./test_errexit_${1:-"Must specify 4/d/8"} $i | ||
if [ $? -ne $i ]; then | ||
echo "Failure: $? != $i" | ||
exit $i | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
program test_errmsg | ||
call errmsg("This is an error message.") | ||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
./test_errmsg_${1:-"Must specify 4/d/8"} 2>&1 | grep "This is an error message." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
program test_fparsei | ||
implicit none | ||
character(25) :: carg | ||
integer :: marg | ||
integer :: karg(4) | ||
|
||
karg = -999 | ||
carg = '8675309,1234567 098 1234' | ||
marg = 3 | ||
call fparsei(carg, marg, karg) | ||
if (any(karg .ne. (/8675309,1234567,98,-999/))) stop 1 | ||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
program test_fparser | ||
implicit none | ||
character(25) :: carg | ||
integer :: marg | ||
real :: rarg(4) | ||
real, parameter :: tinyreal=tiny(1.0) | ||
|
||
rarg = -999.9 | ||
carg = '867530.9,123456.7 09.8 123.4' | ||
marg = 3 | ||
call fparser(carg, marg, rarg) | ||
if (any((rarg-(/867530.9,123456.7,9.8,-999.9/)).gt.tinyreal)) stop 1 | ||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
program test_gbyte | ||
implicit none | ||
integer*4 :: iunpkd, ipackd | ||
real*4 :: rpackd | ||
character*4 :: kpackd | ||
|
||
equivalence(ipackd, rpackd, kpackd) | ||
|
||
call gbyte(99, iunpkd, 0, 1) | ||
if (iunpkd.ne.0) stop 10 | ||
|
||
call gbyte(-99, iunpkd, 0, 1) | ||
if (iunpkd.ne.1) stop 12 | ||
call gbyte(-99, iunpkd, 0, 32) | ||
if (iunpkd.ne.-99) stop 13 | ||
|
||
rpackd = 999.9 | ||
call gbyte(rpackd, iunpkd, 0, 1) | ||
if (iunpkd.ne.0) stop 20 | ||
|
||
rpackd = -999.9 | ||
call gbyte(rpackd, iunpkd, 0, 1) | ||
if (iunpkd.ne.1) stop 21 | ||
|
||
kpackd = 'abc' | ||
call gbyte(kpackd, iunpkd, 0, 32) | ||
if (iunpkd.ne.543384161) stop 30 | ||
|
||
end program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
! This program tests getgbemh(). | ||
program test_getgbemh | ||
implicit none | ||
character*256 cg1 | ||
integer karg(100) | ||
integer jpds1(200) | ||
data jpds1/200*-1/ | ||
|
||
integer, parameter :: mbuf=256*1024 | ||
character cbuf1(mbuf), cbuf_ref(mbuf) | ||
integer jgds(200),jens(5) | ||
integer kpds1(200),kgds1(200),kens1(5) | ||
integer lcg1,iarg,iret,iretba,k1,kr1,kr1x | ||
integer lg1,lx1,m1,mb,mnum1,nlen1,nnum1 | ||
|
||
cg1='data/input/ref_gdaswave.t00z.wcoast.0p16.f000.grib1' | ||
lcg1=len_trim(cg1) | ||
iarg=iarg+1 | ||
lg1=11 | ||
call baopenr(lg1,cg1(1:lcg1),iretba) | ||
lx1=0 | ||
|
||
! READ GRIB HEADERS | ||
mb=1 | ||
kr1=-1 | ||
jgds=-1 | ||
jens=-1 | ||
kpds1=0 | ||
kgds1=0 | ||
kens1=0 | ||
call getgbemh(lg1,lx1,kr1,jpds1,jgds,jens, & | ||
mbuf,cbuf1,nlen1,nnum1,mnum1, & | ||
k1,m1,kr1x,kpds1,kgds1,kens1,iret) | ||
!! Uncomment to regenerate baseline data: | ||
! open(51, file='getgbemh', form='unformatted') | ||
! write(51) cbuf1 | ||
if(iret.ne.0) stop 1 | ||
if(m1.le.0) stop 2 | ||
open(11, file='data/baseline/getgbemh', form='unformatted') | ||
read(11) cbuf_ref | ||
if(any(cbuf1.ne.cbuf_ref)) stop 3 | ||
|
||
end program test_getgbemh |