Skip to content

Commit

Permalink
Add tests to test axis_eges for decreasing array
Browse files Browse the repository at this point in the history
  • Loading branch information
uramirez8707 committed Oct 24, 2023
1 parent 7ea4bef commit 296f269
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
42 changes: 32 additions & 10 deletions test_fms/axis_utils/test_axis_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ program test_axis_utils
print "(A)", "Testing nearest_index (FAILURE)"
call test_nearest_index_fail

case ('--axis-edges')
print "(A)", "Testing axis_edges"
call test_axis_edges
case ('--axis-edges-increasing')
print "(A)", "Testing axis_edges-increasing"
call test_axis_edges(.true.)

case ('--axis-edges-decreasing')
print "(A)", "Testing axis_edges-decreasing"
call test_axis_edges(.false.)

case ('--tranlon')
print "(A)", "Testing tranlon"
Expand Down Expand Up @@ -445,24 +449,42 @@ subroutine test_nearest_index_fail
ret_test = nearest_index(5._k, arr)
end subroutine

subroutine test_axis_edges
subroutine test_axis_edges(increasing_array)
logical, intent(in) :: increasing_array !< .True. if test using an increasing array
real(k) :: data_in_var(10)
real(k) :: data_in_var_edges(2,10)
real(k) :: data_in_answers(11)
type(FmsNetcdfFile_t) :: fileobj
real(k) :: answers(11)
integer :: i
integer :: count
integer :: count_factor
integer :: factor

if (increasing_array) then
count = 0
factor = 1
count_factor = -1
else
count = 11
factor = -1
count_factor = 0
endif

do i=1,10
data_in_var(i) = real(i, k) - 0.5_k
count = count + factor
data_in_var(i) = real(count, k) - 0.5_k

data_in_var_edges(1,i) = real(i-1, k)
data_in_var_edges(2,i) = real(i, k)
data_in_var_edges(1,i) = real(count-1, k)
data_in_var_edges(2,i) = real(count, k)

data_in_answers(i) = real(i-1, k)
data_in_answers(i) = real(count + count_factor, k)
enddo

data_in_answers(11) = 10._k
if (increasing_array) then
data_in_answers(11) = real(count, k)
else
data_in_answers(11) = real(count + factor, k)
endif

call open_netcdf_w(fileobj)

Expand Down
4 changes: 2 additions & 2 deletions test_fms/axis_utils/test_axis_utils2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
# Prepare the directory to run the tests.
touch input.nml

TESTS_SUCCESS='--get-axis-modulo --get-axis-modulo-times --get-axis-cart --lon-in-range --frac-index --nearest-index-increasing --nearest-index-decreasing --axis-edges --tranlon --interp-1d-1d --interp-1d-2d --interp-1d-3d'
TESTS_SUCCESS='--get-axis-modulo --get-axis-modulo-times --get-axis-cart --lon-in-range --frac-index --nearest-index-increasing --nearest-index-decreasing --axis-edges-increasing --axis_edges-decreasing --tranlon --interp-1d-1d --interp-1d-2d --interp-1d-3d'
TESTS_FAIL='--frac-index-fail --nearest-index-fail'

# TODO: Enable these tests after tranlon's memory corruption bug is fixed.
SKIP_TESTS="test_axis_utils2.15 test_axis_utils2.16"
SKIP_TESTS="test_axis_utils2.19 test_axis_utils2.20"

# Run the tests

Expand Down

0 comments on commit 296f269

Please sign in to comment.