Skip to content

Commit

Permalink
Removed save attribute from lat and lon arrays and put these arrays i…
Browse files Browse the repository at this point in the history
…n subroutine arguement list
  • Loading branch information
abrooks1085 committed Nov 7, 2024
1 parent 6f449ef commit 3536d39
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions test_fms/topography/test_topography.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ program test_top
integer, parameter :: lkind = TEST_TOP_KIND_ ! kind parameter for mixed precision

real(kind=TEST_TOP_KIND_), parameter :: deg2rad = real(pi, TEST_TOP_KIND_)/180.0_lkind
real(kind=TEST_TOP_KIND_), dimension(2,2), save :: lon2d, lat2d ! in radians
real(kind=TEST_TOP_KIND_), dimension(2), save :: lon1d, lat1d ! in radians
real(kind=TEST_TOP_KIND_), dimension(2,2) :: lon2d, lat2d ! in radians
real(kind=TEST_TOP_KIND_), dimension(2) :: lon1d, lat1d ! in radians

call fms_init
call topography_init
Expand Down Expand Up @@ -144,20 +144,22 @@ program test_top
end if
!-------------------------------------------------------------------------------------------------------------!

call test_topog_mean ; call test_topog_stdev
call test_get_ocean_frac ; call test_get_ocean_mask
call test_get_water_frac ; call test_get_water_mask
call test_topog_mean(lat2d, lon2d, lat1d, lon1d) ; call test_topog_stdev(lat2d, lon2d, lat1d, lon1d)
call test_get_ocean_frac(lat2d, lon2d, lat1d, lon1d) ; call test_get_ocean_mask(lat2d, lon2d, lat1d, lon1d)
call test_get_water_frac(lat2d, lon2d, lat1d, lon1d) ; call test_get_water_mask(lat2d, lon2d, lat1d, lon1d)

call fms_end

contains

subroutine test_topog_mean()
subroutine test_topog_mean(lat2d, lon2d, lat1d, lon1d)
!! The naming convention of zmean2d/1d in this routine does not relate to their
!! dimensions but correlates with what dimensions of lat and lon they are being
!! tested with. In this case, the sizes of both zmean2d and zmean1d are both the
!! same size but have to be these specific dimensions per the topography_mod code
implicit none
real(kind=TEST_TOP_KIND_), dimension(2,2), intent(in) :: lat2d, lon2d
real(kind=TEST_TOP_KIND_), dimension(2), intent(in) :: lat1d, lon1d
real(kind=TEST_TOP_KIND_), dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: zmean2d
real(kind=TEST_TOP_KIND_), dimension(size(lon1d)-1,size(lat1d)-1) :: zmean1d
logical :: get_mean_answer
Expand All @@ -182,13 +184,15 @@ subroutine test_topog_mean()

end subroutine test_topog_mean

subroutine test_topog_stdev
subroutine test_topog_stdev(lat2d, lon2d, lat1d, lon1d)

!! The naming convention of stdev2d/1d in this routine does not relate to their
!! dimensions but correlates with what dimensions of lat and lon they are being
!! tested with. In this case, the sizes of both stdev2d and stdev1d are both the
!! same size but have to be these specific dimensions per the topography_mod code
implicit none
real(kind=TEST_TOP_KIND_), dimension(2,2), intent(in) :: lat2d, lon2d
real(kind=TEST_TOP_KIND_), dimension(2), intent(in) :: lat1d, lon1d
real(kind=TEST_TOP_KIND_), dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: stdev2d
real(kind=TEST_TOP_KIND_), dimension(size(lon1d)-1,size(lat1d)-1) :: stdev1d
logical :: get_stdev_answer
Expand All @@ -213,13 +217,15 @@ subroutine test_topog_stdev

end subroutine test_topog_stdev

subroutine test_get_ocean_frac
subroutine test_get_ocean_frac(lat2d, lon2d, lat1d, lon1d)

!! The naming convention of ocean_frac2d/1d in this routine does not relate to their
!! dimensions but correlates with what dimensions of lat and lon they are being
!! tested with. In this case, the sizes of both ocean_frac2d and ocean_frac1d are both the
!! same size but have to be these specific dimensions per the topography_mod code
implicit none
real(kind=TEST_TOP_KIND_), dimension(2,2), intent(in) :: lat2d, lon2d
real(kind=TEST_TOP_KIND_), dimension(2), intent(in) :: lat1d, lon1d
real(kind=TEST_TOP_KIND_), dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: ocean_frac2d
real(kind=TEST_TOP_KIND_), dimension(size(lon1d)-1,size(lat1d)-1) :: ocean_frac1d
logical :: get_ocean_frac_answer
Expand All @@ -243,16 +249,18 @@ subroutine test_get_ocean_frac
! with a larger ocean_frac1d array size
end subroutine test_get_ocean_frac

subroutine test_get_ocean_mask
subroutine test_get_ocean_mask(lat2d, lon2d, lat1d, lon1d)

!! The naming convention of ocean_mask2d/1d in this routine does not relate to their
!! dimensions but correlates with what dimensions of lat and lon they are being
!! tested with. In this case, the sizes of both ocean_mask2d and ocean_mask1d are both the
!! same size but have to be these specific dimensions per the topography_mod code
implicit none
logical, dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: ocean_mask2d
logical, dimension(size(lon1d)-1,size(lat1d)-1) :: ocean_mask1d
logical :: get_ocean_mask_answer
real(kind=TEST_TOP_KIND_), dimension(2,2), intent(in) :: lat2d, lon2d
real(kind=TEST_TOP_KIND_), dimension(2), intent(in) :: lat1d, lon1d
logical, dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: ocean_mask2d
logical, dimension(size(lon1d)-1,size(lat1d)-1) :: ocean_mask1d
logical :: get_ocean_mask_answer

!---------------------------------------- test get_ocean_mask 2d ---------------------------------------------!

Expand All @@ -275,12 +283,14 @@ subroutine test_get_ocean_mask

end subroutine test_get_ocean_mask

subroutine test_get_water_frac
subroutine test_get_water_frac(lat2d, lon2d, lat1d, lon1d)
!! The naming convention of water_frac2d/1d in this routine does not relate to their
!! dimensions but correlates with what dimensions of lat and lon they are being
!! tested with. In this case, the sizes of both water_frac2d and water_frac1d are both the
!! same size but have to be these specific dimensions per the topography_mod code
implicit none
real(kind=TEST_TOP_KIND_), dimension(2,2), intent(in) :: lat2d, lon2d
real(kind=TEST_TOP_KIND_), dimension(2), intent(in) :: lat1d, lon1d
real(kind=TEST_TOP_KIND_), dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: water_frac2d
real(kind=TEST_TOP_KIND_), dimension(size(lon1d)-1,size(lat1d)-1) :: water_frac1d
logical :: get_water_frac_answer
Expand All @@ -305,16 +315,18 @@ subroutine test_get_water_frac

end subroutine test_get_water_frac

subroutine test_get_water_mask
subroutine test_get_water_mask(lat2d, lon2d, lat1d, lon1d)

!! The naming convention of water_mask2d/1d in this routine does not relate to their
!! dimensions but correlates with what dimensions of lat and lon they are being
!! tested with. In this case, the sizes of both water_mask2d and water_mask1d are both the
!! same size but have to be these specific dimensions per the topography_mod code
implicit none
logical, dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: water_mask2d
logical, dimension(size(lon1d)-1,size(lat1d)-1) :: water_mask1d
logical :: get_water_mask_answer
real(kind=TEST_TOP_KIND_), dimension(2,2), intent(in) :: lat2d, lon2d
real(kind=TEST_TOP_KIND_), dimension(2), intent(in) :: lat1d, lon1d
logical, dimension(size(lon2d,1)-1,size(lat2d,2)-1) :: water_mask2d
logical, dimension(size(lon1d)-1,size(lat1d)-1) :: water_mask1d
logical :: get_water_mask_answer

!---------------------------------------- test get_water_mask 2d ---------------------------------------------!

Expand Down

0 comments on commit 3536d39

Please sign in to comment.