Skip to content

Commit

Permalink
fix: data_override test failures from input (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
uramirez8707 authored Oct 3, 2024
1 parent 44a211a commit 85475e5
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 39 deletions.
18 changes: 16 additions & 2 deletions test_fms/data_override/test_data_override2_mono.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
output_dir
[ ! -d "INPUT" ] && mkdir -p "INPUT"

cat <<_EOF > input.nml
cat <<_EOF > input_base.nml
&test_data_override_ongrid_nml
test_case = 2
write_only = .False.
/
_EOF

Expand All @@ -41,16 +42,23 @@ _EOF
for KIND in r4 r8
do
rm -rf INPUT/*
sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml
test_expect_success "Creating input files (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'

cp input_base.nml input.nml
test_expect_success "test_data_override with monotonically increasing and decreasing data sets (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'
done

rm -rf data_table

cat <<_EOF > input.nml
cat <<_EOF > input_base.nml
&test_data_override_ongrid_nml
test_case = 2
write_only = .False.
/
&data_override_nml
use_data_table_yaml = .True.
Expand Down Expand Up @@ -80,6 +88,12 @@ if [ -z $parser_skip ]; then
for KIND in r4 r8
do
rm -rf INPUT/*
sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml
test_expect_success "Creating input files (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'

cp input_base.nml input.nml
test_expect_success "test_data_override with monotonically increasing and decreasing data sets -yaml (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'
Expand Down
10 changes: 8 additions & 2 deletions test_fms/data_override/test_data_override2_ongrid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use_data_table_yaml=.False.
&test_data_override_ongrid_nml
nhalox=halo_size
nhaloy=halo_size
write_only = .False.
/
_EOF
printf '"OCN", "runoff", "runoff", "./INPUT/runoff.daitren.clim.1440x1080.v20180328.nc", "none" , 1.0' | cat > data_table
Expand All @@ -48,6 +49,7 @@ use_data_table_yaml=.True.
&test_data_override_ongrid_nml
nhalox=halo_size
nhaloy=halo_size
write_only = .False.
/
_EOF
cat <<_EOF > data_table.yaml
Expand All @@ -65,13 +67,17 @@ fi
[ ! -d "INPUT" ] && mkdir -p "INPUT"
for KIND in r4 r8
do
rm -rf INPUT/*
sed -e 's/halo_size/2/g ; s/write_only = .False./write_only = .True./g' input_base.nml > input.nml

test_expect_success "Creating input files (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'

sed 's/halo_size/2/g' input_base.nml > input.nml
test_expect_success "data_override on grid with 2 halos in x and y (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'

rm -rf INPUT/*
sed 's/halo_size/0/g' input_base.nml > input.nml
test_expect_success "data_override on grid with 0 halos in x and y (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
Expand Down
12 changes: 10 additions & 2 deletions test_fms/data_override/test_data_override2_scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ output_dir
rm -rf data_table data_table.yaml input.nml input_base.nml

if [ ! -z $parser_skip ]; then
cat <<_EOF > input.nml
cat <<_EOF > input_base.nml
&data_override_nml
use_data_table_yaml=.False.
/
&test_data_override_ongrid_nml
test_case = 3
write_only = .False.
/
_EOF
printf '"OCN", "co2", "co2", "./INPUT/scalar.nc", "none" , 1.0' | cat > data_table
else
cat <<_EOF > input.nml
cat <<_EOF > input_base.nml
&data_override_nml
use_data_table_yaml=.True.
/
&test_data_override_ongrid_nml
test_case = 3
write_only = .False.
/
_EOF
cat <<_EOF > data_table.yaml
Expand All @@ -62,6 +64,12 @@ fi
for KIND in r4 r8
do
rm -rf INPUT/*
sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml
test_expect_success "Creating input files (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'

cp input_base.nml input.nml
test_expect_success "data_override scalar field (${KIND})" '
mpirun -n 6 ../test_data_override_ongrid_${KIND}
'
Expand Down
68 changes: 36 additions & 32 deletions test_fms/data_override/test_data_override_ongrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ program test_data_override_ongrid
use netcdf, only: nf90_create, nf90_def_dim, nf90_def_var, nf90_enddef, nf90_put_var, &
nf90_close, nf90_put_att, nf90_clobber, nf90_64bit_offset, nf90_char, &
nf90_double, nf90_unlimited
use fms_mod, only: string
use fms_mod, only: string, fms_init, fms_end

implicit none

Expand All @@ -53,10 +53,11 @@ program test_data_override_ongrid
integer, parameter :: scalar = 3
integer, parameter :: weight_file = 4
integer :: test_case = ongrid
logical :: write_only=.false. !< True if creating the input files only

namelist / test_data_override_ongrid_nml / nhalox, nhaloy, test_case, nlon, nlat, layout
namelist / test_data_override_ongrid_nml / nhalox, nhaloy, test_case, nlon, nlat, layout, write_only

call mpp_init
call fms_init
call fms2_io_init

read (input_nml_file, test_data_override_ongrid_nml, iostat=io_status)
Expand All @@ -75,35 +76,38 @@ program test_data_override_ongrid
call mpp_define_io_domain(Domain, (/1,1/))
call mpp_get_data_domain(Domain, is, ie, js, je)

select case (test_case)
case (ongrid)
call generate_ongrid_input_file ()
case (bilinear)
call generate_bilinear_input_file ()
case (scalar)
call generate_scalar_input_file ()
case (weight_file)
call generate_weight_input_file ()
end select

call mpp_sync()
call mpp_error(NOTE, "Finished creating INPUT Files")

!< Initiliaze data_override
call data_override_init(Ocean_domain_in=Domain, mode=lkind)

select case (test_case)
case (ongrid)
call ongrid_test()
case (bilinear)
call bilinear_test()
case (scalar)
call scalar_test()
case (weight_file)
call weight_file_test()
end select

call mpp_exit
if (write_only) then
select case (test_case)
case (ongrid)
call generate_ongrid_input_file ()
case (bilinear)
call generate_bilinear_input_file ()
case (scalar)
call generate_scalar_input_file ()
case (weight_file)
call generate_weight_input_file ()
end select

call mpp_sync()
call mpp_error(NOTE, "Finished creating INPUT Files")

else
!< Initiliaze data_override
call data_override_init(Ocean_domain_in=Domain, mode=lkind)

select case (test_case)
case (ongrid)
call ongrid_test()
case (bilinear)
call bilinear_test()
case (scalar)
call scalar_test()
case (weight_file)
call weight_file_test()
end select
endif

call fms_end

contains

Expand Down
10 changes: 9 additions & 1 deletion test_fms/data_override/test_data_override_weights.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ data_table:
factor: 1.0
_EOF

cat <<_EOF > input.nml
cat <<_EOF > input_base.nml
&data_override_nml
use_data_table_yaml = .True.
/
Expand All @@ -58,6 +58,7 @@ cat <<_EOF > input.nml
nlon = 5
nlat = 6
layout = 1, 2
write_only = .False.
/
_EOF

Expand All @@ -66,6 +67,13 @@ if [ -z $parser_skip ]; then
for KIND in r4 r8
do
rm -rf INPUT/.

sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml
test_expect_success "Creating input files (${KIND})" '
mpirun -n 2 ../test_data_override_ongrid_${KIND}
'

cp input_base.nml input.nml
test_expect_success "test_data_override with and without weight files -yaml (${KIND})" '
mpirun -n 2 ../test_data_override_ongrid_${KIND}
'
Expand Down

0 comments on commit 85475e5

Please sign in to comment.