Skip to content

Commit

Permalink
Update fvcom_tools unit test - ftst_readfvcomnetcdf.F90 -
Browse files Browse the repository at this point in the history
to check new variables ingested from FVCOM and for the new
MPI support.

Fixes ufs-community#623.
  • Loading branch information
GeorgeGayno-NOAA committed Feb 17, 2022
1 parent ea85976 commit 2a7788c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Ed Hartnett 2/11/21

# Add the test subdirecotries.
#add_subdirectory(fvcom_tools)
add_subdirectory(filter_topo)
add_subdirectory(chgres_cube)
add_subdirectory(fre-nctools)
Expand Down
47 changes: 33 additions & 14 deletions tests/fvcom_tools/ftst_readfvcomnetcdf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,36 @@ program readfvcomnetcdf
integer :: fv3sst_expected(NUM_VALUES) !expected fv3 sst values
real :: fv3ice_expected(NUM_VALUES) !expected fv3 ice values
real :: fv3iceT_expected(NUM_VALUES) !expected fv3 ice temp values
real :: fv3zorl_expected(NUM_VALUES) !expected fv3 surface roughness values
real :: fv3hice_expected(NUM_VALUES) !exepcted fv3 ice thickness values
integer :: lbcmask_expected(NUM_VALUES) !expected fvcom mask values
real :: lbcsst_expected(NUM_VALUES) !expected fvcom sst values
real :: lbcice_expected(NUM_VALUES) !expected fvcom ice values
real :: lbciceT_expected(NUM_VALUES) !expected fvcom ice temp values
real :: lbcvice_expected(NUM_VALUES) !expected fvcom ice thickness values

! Create allocabable arrays to read from .nc files
real, allocatable :: fv3ice(:,:), fv3sst(:,:)
real, allocatable :: fv3sfcT(:,:), fv3mask(:,:)
real, allocatable :: fv3iceT(:,:), fv3sfcTl(:,:)
real, allocatable :: fv3zorl(:,:), fv3hice(:,:)
real, allocatable :: lbcice(:,:), lbcsst(:,:)
real, allocatable :: lbcsfcT(:,:), lbcmask(:,:)
real, allocatable :: lbciceT(:,:)

real, allocatable :: lbciceT(:,:), lbchice(:,:)
real, allocatable :: lbczorl(:,:)
! Expected values from the dummy files
data lat_lon_expected_values /5, 5/
data fv3mask_expected /1, 0/
data fv3sst_expected /1, 0/
data fv3ice_expected /.1, 0/
data fv3iceT_expected /.1, 0/
data fv3zorl_expected /1.1, 0/
data fv3hice_expected /.1, 0/
data lbcmask_expected /1, 0/
data lbcsst_expected /1, -99.99999/
data lbcice_expected /1, -99.99999/
data lbciceT_expected /1, -99.99999/
data lbcvice_expected /1, -99.99999/
data t2_expected /2 / !expect second time index from fvcom file

type(ncio) :: geo !grid data object
Expand Down Expand Up @@ -93,16 +100,20 @@ program readfvcomnetcdf
allocate(fv3mask(nlon,nlat))
allocate(fv3iceT(nlon,nlat))
allocate(fv3sfcTl(nlon,nlat))
allocate(fv3zorl(nlon,nlat))
allocate(fv3hice(nlon,nlat))

allocate(lbcice(nlon,nlat))
allocate(lbcsfcT(nlon,nlat))
allocate(lbcsst(nlon,nlat))
allocate(lbcmask(nlon,nlat))
allocate(lbciceT(nlon,nlat))
allocate(lbczorl(nlon,nlat))
allocate(lbchice(nlon,nlat))

!Initialize and read in fv3 sfc data
call fcst%initial('FV3LAM',wcstart)
call fcst%read_n(trim(fv3file),'FV3LAM',wcstart,fv3lon,fv3lat,fv3times,t1,fv3mask,fv3sst,fv3ice,fv3sfcT,fv3iceT,fv3sfcTl)
call fcst%read_n(trim(fv3file),'FV3LAM',wcstart,fv3lon,fv3lat,fv3times,t1,fv3mask,fv3sst,fv3ice,fv3sfcT,fv3iceT,fv3sfcTl,fv3zorl,fv3hice,1,nlat)
call fcst%finish('FV3LAM',wcstart)
!If variables in fv3 sfc file do not match expected, stop
if (abs(fv3mask(1,1) - fv3mask_expected(1)) > EPSILON) stop 5
Expand All @@ -117,27 +128,35 @@ program readfvcomnetcdf
if (abs(fv3iceT(1,1) - fv3iceT_expected(1)) > EPSILON) stop 9
if (abs(fv3iceT(5,5) - fv3iceT_expected(2)) > EPSILON) stop 10

if (abs(fv3zorl(1,1) - fv3zorl_expected(1)) > EPSILON) stop 11
if (abs(fv3zorl(5,5) - fv3zorl_expected(2)) > EPSILON) stop 12

if (abs(fv3hice(1,1) - fv3hice_expected(1)) > EPSILON) stop 13
if (abs(fv3hice(5,5) - fv3hice_expected(2)) > EPSILON) stop 14

!Initialize and read in fvcom data
call fcst%initial(' FVCOM',wcstart)
call fcst%get_time_ind(trim(fvcomfile),inputFVCOMselStr,t2)
!If second time index is not returned, stop
if (abs(t2 - t2_expected) > EPSILON) stop 11
call fcst%read_n(trim(fvcomfile),' FVCOM',wcstart,lbclon,lbclat,lbctimes,t2,lbcmask,lbcsst,lbcice,lbcsfcT,lbciceT,fv3sfcTl)
if (abs(t2 - t2_expected) > EPSILON) stop 15
call fcst%read_n(trim(fvcomfile),' FVCOM',wcstart,lbclon,lbclat,lbctimes,t2,lbcmask,lbcsst,lbcice,lbcsfcT,lbciceT,fv3sfcTl,lbczorl,lbchice,1,nlat)
call fcst%finish(' FVCOM',wcstart)
!If variables in fvcom file do not match expected, stop
if (abs(lbcmask(1,1) - lbcmask_expected(1)) > EPSILON) stop 12
if (abs(lbcmask(5,5) - lbcmask_expected(2)) > EPSILON) stop 13
if (abs(lbcmask(1,1) - lbcmask_expected(1)) > EPSILON) stop 16
if (abs(lbcmask(5,5) - lbcmask_expected(2)) > EPSILON) stop 17

if (abs(lbcsst(1,1) - lbcsst_expected(1)) > EPSILON) stop 14
if (abs(lbcsst(5,5) - lbcsst_expected(2)) > EPSILON) stop 15
if (abs(lbcsst(1,1) - lbcsst_expected(1)) > EPSILON) stop 18
if (abs(lbcsst(5,5) - lbcsst_expected(2)) > EPSILON) stop 19

if (abs(lbcice(1,1) - lbcice_expected(1)) > EPSILON) stop 16
if (abs(lbcice(5,5) - lbcice_expected(2)) > EPSILON) stop 17
if (abs(lbcice(1,1) - lbcice_expected(1)) > EPSILON) stop 20
if (abs(lbcice(5,5) - lbcice_expected(2)) > EPSILON) stop 21

if (abs(lbciceT(1,1) - lbciceT_expected(1)) > EPSILON) stop 18
if (abs(lbciceT(5,5) - lbciceT_expected(2)) > EPSILON) stop 19
if (abs(lbciceT(1,1) - lbciceT_expected(1)) > EPSILON) stop 22
if (abs(lbciceT(5,5) - lbciceT_expected(2)) > EPSILON) stop 23

if (abs(lbchice(1,1) - lbcvice_expected(1)) > EPSILON) stop 24
if (abs(lbchice(5,5) - lbcvice_expected(2)) > EPSILON) stop 25


print*,"OK"

print*,"SUCCESS!"
Expand Down

0 comments on commit 2a7788c

Please sign in to comment.