Skip to content

Commit

Permalink
more test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mlee03 authored and mlee03 committed Oct 3, 2023
1 parent 8b1fd31 commit 823250b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
29 changes: 18 additions & 11 deletions test_fms/interpolator/test_interpolator2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ program test_interpolator2

character(100), parameter :: ncfile='immadeup.o3.climatology.nc' !< fake climatology file.
integer, parameter :: lkind=TEST_INTP_KIND_
real(r8_kind), parameter :: tol=1.e-12_r8_kind !< the interpolation methods are not perfect.
!! Will not get perfectly agreeing answers
!> the interpolation methods are not perfect.Will not get perfectly agreeing answers
real(r8_kind) :: tol
integer :: calendar_type

!> climatology related variables and arrays (made up data)
Expand All @@ -61,7 +61,7 @@ program test_interpolator2
real(TEST_INTP_KIND_), allocatable :: lon(:) !< climatology coordinates
real(TEST_INTP_KIND_), allocatable :: latb(:) !< climatology coordinates
real(TEST_INTP_KIND_), allocatable :: lonb(:) !< climatology coordinates
real(TEST_INTP_KIND_), allocatable :: clim_time (:) !< climatology time
real(r8_kind), allocatable :: clim_time (:) !< climatology time
real(TEST_INTP_KIND_), allocatable :: pfull(:) !< climatology p level
real(TEST_INTP_KIND_), allocatable :: phalf(:) !< climatology p half level
real(TEST_INTP_KIND_), allocatable :: ozone(:,:,:,:) !< climatology ozone data
Expand All @@ -87,18 +87,25 @@ program test_interpolator2
NAMELIST / test_interpolator_nml / test_daily_noleap, test_daily_julian, &
test_yearly_noleap, test_yearly_julian, test_no_time

if(lkind==r4_kind) tol=1.e-4_r8_kind
if(lkind==r8_kind) tol=1.e-6_r8_kind

open(unit=nml_unit_var, file=nml_file)
read(unit=nml_unit_var, nml=test_interpolator_nml)
close(nml_unit_var)

if(test_daily_noleap) &
write(*,"(////10x,a/////)") " ** DAILY FILE CAL NOLEAP ** DAILY FILE CAL NOLEAP ** DAILY FILE CAL NOLEAP **"
write(*,"(////10x,a,i0////)") &
" ** DAILY FILE CAL NOLEAP ** DAILY FILE CAL NOLEAP ** DAILY FILE CAL NOLEAP ** ", lkind
if(test_daily_julian) &
write(*,"(////10x,a/////)") ' ** DAILY FILE CAL JULIAN ** DAILY FILE CAL JULIAN ** DAILY FILE CAL JULIAN **'
write(*,"(////10x,a,i0/////)") &
' ** DAILY FILE CAL JULIAN ** DAILY FILE CAL JULIAN ** DAILY FILE CAL JULIAN ** ', lkind
if(test_yearly_noleap) &
write(*,"(////10x,a/////)") ' ** YEARLY FILE CAL NOLEAP ** YEARLY FILE CAL NOLEAP ** YEARLY FILE CAL NOLEAP **'
write(*,"(////10x,a,i0/////)") &
' ** YEARLY FILE CAL NOLEAP ** YEARLY FILE CAL NOLEAP ** YEARLY FILE CAL NOLEAP ** ', lkind
if(test_yearly_julian) &
write(*,"(////10x,a/////)") ' ** YEARLY FILE CAL JULIAN ** YEARLY FILE CAL JULIAN ** YEARLY FILE CAL JULIAN **'
write(*,"(////10x,a,i0/////)") &
' ** YEARLY FILE CAL JULIAN ** YEARLY FILE CAL JULIAN ** YEARLY FILE CAL JULIAN ** ', lkind
if(test_no_time) &
write(*,"(////10x,a/////)") " ** NO TIME AXIS ** NO TIME AXIS ** NO TIME AXIS **"

Expand All @@ -108,16 +115,16 @@ program test_interpolator2

!> set data
if(test_daily_noleap) then
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=140, npfull_in=3, &
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=240, npfull_in=3, &
daily_in=.true., yearly_in=.false., noleap_in=.true.)
else if(test_daily_julian) then
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=140, npfull_in=3, &
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=240, npfull_in=3, &
daily_in=.true., yearly_in=.false., noleap_in=.false.)
else if(test_yearly_noleap) then
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=140, npfull_in=3, &
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=240, npfull_in=3, &
daily_in=.false., yearly_in=.true., noleap_in=.true.)
else if(test_yearly_julian) then
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=140, npfull_in=3, &
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=240, npfull_in=3, &
daily_in=.false., yearly_in=.true., noleap_in=.false.)
else if(test_no_time) then
call set_parameters(nlonlat_in=10, nlonlat_mod_in=10, ntime_in=0, npfull_in=3, &
Expand Down
20 changes: 7 additions & 13 deletions test_fms/interpolator/test_interpolator2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ test_no_time=.false.
/
EOF
mkdir -p INPUT
#test_expect_success "test_interpolator2 daily r4 julian unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 daily r4 julian unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 daily r8 julian unit tests" 'mpirun -n 1 ./test_interpolator2_r8'
#rm -rf INPUT *.nc test_interpolator.nml
rm -rf INPUT *.nc test_interpolator.nml

#Run the daily interpolator tests when the file calendar is in units of days and calendar type is JULIAN
cat <<EOF > test_interpolator.nml
Expand All @@ -81,11 +81,9 @@ test_no_time=.false.
/
EOF
mkdir -p INPUT
#test_expect_success "test_interpolator2 daily r4 noleap unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 daily r4 noleap unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 daily r8 noleap unit tests" 'mpirun -n 1 ./test_interpolator2_r8'
#rm -rf INPUT *.nc test_interpolator.nml

exit
rm -rf INPUT *.nc test_interpolator.nml

#Run the yearly interpolator tests when the file calendar is in units of years and calendar type is NOLEAP
cat <<EOF > test_interpolator.nml
Expand All @@ -100,7 +98,7 @@ EOF
mkdir -p INPUT
test_expect_success "test_interpolator2 yearly noleap r4 unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 yearly noleap r8 unit tests" 'mpirun -n 1 ./test_interpolator2_r8'
#rm -rf INPUT *.nc test_interpolator.nml
rm -rf INPUT *.nc test_interpolator.nml

#Run the yearly interpolator tests when the file calendar is in units of years and calendar type is JULIAN
cat <<EOF > test_interpolator.nml
Expand All @@ -115,8 +113,7 @@ EOF
mkdir -p INPUT
test_expect_success "test_interpolator2 yearly julian r4 unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 yearly julian r8 unit tests" 'mpirun -n 1 ./test_interpolator2_r8'
#rm -rf INPUT *.nc test_interpolator.nml

rm -rf INPUT *.nc test_interpolator.nml

#Run no_time_axis
cat <<EOF > test_interpolator.nml
Expand All @@ -131,9 +128,6 @@ EOF
mkdir -p INPUT
test_expect_success "test_interpolator2 no time axis r4 unit tests" 'mpirun -n 1 ./test_interpolator2_r4'
test_expect_success "test_interpolator2 no time axis r8 unit tests" 'mpirun -n 1 ./test_interpolator2_r8'
#rm -rf INPUT *.nc test_interpolator.nml


rm -rf INPUT *.nc test_interpolator.nml

#rm *.nml
test_done
22 changes: 11 additions & 11 deletions test_fms/interpolator/test_interpolator_write_climatology.inc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ subroutine set_clim_time()
dy = 15
model_time_julian(i)=set_date_julian(yr, mo, dy, hr, mn, sc)
model_time_noleap(i)=set_date_no_leap(yr, mo, dy, hr, mn, sc)
clim_time(i)=time_type_to_real(model_time_noleap(i)-base_time)/86400._lkind
clim_time(i)=time_type_to_real(model_time_noleap(i)-base_time)/86400._r8_kind
!call print_time(model_time_noleap(i))
end do
else if(test_daily_julian) then
Expand All @@ -210,7 +210,7 @@ subroutine set_clim_time()
dy = 15
model_time_julian(i)=set_date_julian(yr, mo, dy, hr, mn, sc)
model_time_noleap(i)=set_date_no_leap(yr, mo, dy, hr, mn, sc)
clim_time(i)=time_type_to_real(model_time_julian(i)-base_time)/86400._lkind
clim_time(i)=time_type_to_real(model_time_julian(i)-base_time)/86400._r8_kind
!call print_time(model_time_julian(i))
end do
else if(test_yearly_noleap) then
Expand All @@ -222,15 +222,15 @@ subroutine set_clim_time()
dy = 15
model_time_julian(i)=set_date_julian(yr, mo, dy, hr, mn, sc)
model_time_noleap(i)=set_date_no_leap(yr, mo, dy, hr, mn, sc)
clim_time(i)=real(yr-1849,lkind)
clim_time(i)=real(yr-1849,r8_kind)
do ii=1, mo-1
select case(ii)
case(1,3,5,7,8,10,12) ; clim_time(i) = clim_time(i) + 31.0_lkind/365._lkind
case(2) ; clim_time(i) = clim_time(i) + real(28,lkind)/365._lkind
case(4,6,9,11) ; clim_time(i) = clim_time(i) + 30.0_lkind/365._lkind
case(1,3,5,7,8,10,12) ; clim_time(i) = clim_time(i) + 31.0_r8_kind/365._r8_kind
case(2) ; clim_time(i) = clim_time(i) + 28._r8_kind/365._r8_kind
case(4,6,9,11) ; clim_time(i) = clim_time(i) + 30.0_r8_kind/365._r8_kind
end select
end do
clim_time(i) = clim_time(i) + real(dy-1)/real(365,lkind)
clim_time(i) = clim_time(i) + real(dy-1,r8_kind)/365._r8_kind
!call print_time(model_time_noleap(i))
end do
else if(test_yearly_julian) then
Expand All @@ -247,12 +247,12 @@ subroutine set_clim_time()
l=0 ; if(leap_year(model_time_julian(i))) l=l+1
do ii=1, mo-1
select case(ii)
case(1,3,5,7,8,10,12) ; clim_time(i) = clim_time(i) + 31.0_lkind/real(365+l,lkind)
case(2) ; clim_time(i) = clim_time(i) + real(28+l,lkind)/real(365+l,lkind)
case(4,6,9,11) ; clim_time(i) = clim_time(i) + 30.0_lkind/real(365+l,lkind)
case(1,3,5,7,8,10,12) ; clim_time(i) = clim_time(i) + 31.0_r8_kind/real(365+l,r8_kind)
case(2) ; clim_time(i) = clim_time(i) + real(28+l,r8_kind)/real(365+l,r8_kind)
case(4,6,9,11) ; clim_time(i) = clim_time(i) + 30.0_r8_kind/real(365+l,r8_kind)
end select
end do
clim_time(i) = clim_time(i) + real(dy-1)/real(365+l,lkind)
clim_time(i) = clim_time(i) + real(dy-1,r8_kind)/real(365+l,r8_kind)
!call print_time(model_time_julian(i))
end do
call set_calendar_type(0)
Expand Down

0 comments on commit 823250b

Please sign in to comment.