-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for specpack()/specunpack() (#517)
* spec test * spec test * fixing test * adding test * turned off test for spec packing with _d library * fixing memory problems in test * trying to fix _d test run
- Loading branch information
1 parent
66d1532
commit c84ba05
Showing
4 changed files
with
75 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
! This program tests the specpack subroutine of the NCEPLIBS-g2 | ||
! project. | ||
! | ||
! Ed Hartnett 7/31/23 | ||
program test_specpack | ||
implicit none | ||
|
||
integer, parameter :: width = 2, height = 2, ndpts = 4 | ||
real, parameter :: delta = 0.2 | ||
real :: fld(ndpts*2) | ||
real :: fld2(ndpts*2) | ||
integer :: idrstmpl(10) | ||
character*1 :: cpack(200) | ||
integer :: lcpack = 200 | ||
integer :: ii | ||
integer :: jj, kk, mm | ||
|
||
|
||
! Create the fld variable with data to pack. | ||
fld = (/1.1, 2.2, 3.3, 4.4, 1.1, 2.2, 3.3, 4.4/) | ||
fld2 = (/0, 0, 0, 0, 0, 0, 0, 0/) | ||
|
||
idrstmpl(1) = 0 | ||
idrstmpl(2) = 1 | ||
idrstmpl(3) = 1 | ||
idrstmpl(4) = 32 | ||
idrstmpl(5) = 1 | ||
idrstmpl(6) = 1 | ||
idrstmpl(7) = 1 | ||
idrstmpl(8) = 0 | ||
idrstmpl(9) = ndpts | ||
idrstmpl(10) = 1 | ||
|
||
! Pack the data. | ||
jj = 1 | ||
kk = 1 | ||
mm = 1 | ||
call specpack(fld, ndpts, jj, kk, mm, idrstmpl, cpack, lcpack) | ||
print *, 'lcpack: ', lcpack | ||
|
||
! Unpack the data. | ||
call specunpack(cpack, lcpack, idrstmpl, ndpts, jj, kk, mm, fld2) | ||
|
||
! Compare each value to see match, remember, comparing reals | ||
! print *, 'fld ', fld | ||
! print *, 'fld2 ', fld2 | ||
do ii = 1, ndpts | ||
#ifdef KIND_4 | ||
if (abs(fld(ii) - fld2(ii)) .gt. delta) then | ||
print *, fld(ii), fld2(ii), 'do not match' | ||
stop 4 | ||
end if | ||
#endif | ||
end do | ||
print *, 'SUCCESS!' | ||
end program test_specpack |