Skip to content

Commit

Permalink
Adds a test to the test reading in a slice of the z axis
Browse files Browse the repository at this point in the history
  • Loading branch information
uramirez8707 committed Oct 30, 2024
1 parent bd9cbeb commit 13ad4e4
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions test_fms/fms2_io/test_domain_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ program test_domain_read
call read_data_wrapper(fileobj, "var3", 3, var_data_out, var_data_in)
call read_data_wrapper(fileobj, "var4", 4, var_data_out, var_data_in)
call read_data_wrapper(fileobj, "var5", 5, var_data_out, var_data_in)
call read_data_wrapper(fileobj, "var3", 6, var_data_out, var_data_in)
call read_data_wrapper(fileobj, "var4", 7, var_data_out, var_data_in)
call read_data_wrapper(fileobj, "var5", 8, var_data_out, var_data_in)

call close_file(fileobj)
endif
Expand Down Expand Up @@ -295,6 +298,72 @@ subroutine read_data_wrapper(fileob, var_name, dim, var_data, ref_data)

call read_data(fileob, trim(var_name)//"_i8", var_data%var_i8(:,:,:,:,:))
call compare_var_data(mpp_chksum(var_data%var_i8(:,:,:,:,:)), mpp_chksum(ref_data%var_i8(:,:,:,:,:)), "var5_i8")
case(6)
!Only read the second third dimension (3d case)
call var_data_init(var_data)
call read_data(fileob, trim(var_name)//"_r4", var_data%var_r4(:,:,1:1,1,1), &
corner=(/1, 1, 2/), edge_lengths=(/ nx, ny, 1/))
call compare_var_data(mpp_chksum(var_data%var_r4(:,:,1:1,1,1)), mpp_chksum(ref_data%var_r4(:,:,2:2,1,1)), &
"var3_r4-slice")

call read_data(fileob, trim(var_name)//"_r8", var_data%var_r8(:,:,1:1,1,1), &
corner=(/1, 1, 2/), edge_lengths=(/ nx, ny, 1/))
call compare_var_data(mpp_chksum(var_data%var_r8(:,:,1:1,1,1)), mpp_chksum(ref_data%var_r8(:,:,2:2,1,1)), &
"var3_r8-slice")

call read_data(fileob, trim(var_name)//"_i4", var_data%var_i4(:,:,1:1,1,1), &
corner=(/1, 1, 2/), edge_lengths=(/ nx, ny, 1/))
call compare_var_data(mpp_chksum(var_data%var_i4(:,:,1:1,1,1)), mpp_chksum(ref_data%var_i4(:,:,2:2,1,1)), &
"var3_i4-slice")

call read_data(fileob, trim(var_name)//"_i8", var_data%var_i8(:,:,1:1,1,1), &
corner=(/1, 1, 2/), edge_lengths=(/ nx, ny, 1/))
call compare_var_data(mpp_chksum(var_data%var_i8(:,:,1:1,1,1)), mpp_chksum(ref_data%var_i8(:,:,2:2,1,1)), &
"var3_i8-slice")
case(7)
!Only read the second third dimension (4d case)
call var_data_init(var_data)
call read_data(fileob, trim(var_name)//"_r4", var_data%var_r4(:,:,1:1,:,1), &
corner=(/1, 1, 2, 1/), edge_lengths=(/ nx, ny, 1, ndim4/))
call compare_var_data(mpp_chksum(var_data%var_r4(:,:,1:1,:,1)), mpp_chksum(ref_data%var_r4(:,:,2:2,:,1)), &
"var4_r4-slice")

call read_data(fileob, trim(var_name)//"_r8", var_data%var_r8(:,:,1:1,1,1), &
corner=(/1, 1, 2, 1/), edge_lengths=(/ nx, ny, 1, ndim4/))
call compare_var_data(mpp_chksum(var_data%var_r8(:,:,1:1,:,1)), mpp_chksum(ref_data%var_r8(:,:,2:2,:,1)), &
"var4_r8-slice")

call read_data(fileob, trim(var_name)//"_i4", var_data%var_i4(:,:,1:1,1,1), &
corner=(/1, 1, 2, 1/), edge_lengths=(/ nx, ny, 1, ndim4/))
call compare_var_data(mpp_chksum(var_data%var_i4(:,:,1:1,:,1)), mpp_chksum(ref_data%var_i4(:,:,2:2,:,1)), &
"var4_i4-slice")

call read_data(fileob, trim(var_name)//"_i8", var_data%var_i8(:,:,1:1,1,1), &
corner=(/1, 1, 2, 1/), edge_lengths=(/ nx, ny, 1, ndim4/))
call compare_var_data(mpp_chksum(var_data%var_i8(:,:,1:1,:,1)), mpp_chksum(ref_data%var_i8(:,:,2:2,:,1)), &
"var4_i8-slice")
case(8)
!Only read the second third dimension (5d case)
call var_data_init(var_data)
call read_data(fileob, trim(var_name)//"_r4", var_data%var_r4(:,:,1:1,:,:), &
corner=(/1, 1, 2, 1, 1/), edge_lengths=(/ nx, ny, 1, ndim4, ndim5/))
call compare_var_data(mpp_chksum(var_data%var_r4(:,:,1:1,:,:)), mpp_chksum(ref_data%var_r4(:,:,2:2,:,:)), &
"var5_r4-slice")

call read_data(fileob, trim(var_name)//"_r8", var_data%var_r8(:,:,1:1,1,1), &
corner=(/1, 1, 2, 1, 1/), edge_lengths=(/ nx, ny, 1, ndim4, ndim5/))
call compare_var_data(mpp_chksum(var_data%var_r8(:,:,1:1,:,:)), mpp_chksum(ref_data%var_r8(:,:,2:2,:,:)), &
"var5_r8-slice")

call read_data(fileob, trim(var_name)//"_i4", var_data%var_i4(:,:,1:1,1,1), &
corner=(/1, 1, 2, 1, 1/), edge_lengths=(/ nx, ny, 1, ndim4, ndim5/))
call compare_var_data(mpp_chksum(var_data%var_i4(:,:,1:1,:,:)), mpp_chksum(ref_data%var_i4(:,:,2:2,:,:)), &
"var5_i4-slice")

call read_data(fileob, trim(var_name)//"_i8", var_data%var_i8(:,:,1:1,1,1), &
corner=(/1, 1, 2, 1, 1/), edge_lengths=(/ nx, ny, 1, ndim4, ndim5/))
call compare_var_data(mpp_chksum(var_data%var_i8(:,:,1:1,:,:)), mpp_chksum(ref_data%var_i8(:,:,2:2,:,:)), &
"var5_i8-slice")
end select

end subroutine read_data_wrapper
Expand Down

0 comments on commit 13ad4e4

Please sign in to comment.