Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mosaic2 tests with strict debug flags #1597

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions mosaic2/include/mosaic2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@
!> <br>Example usage:
!! call calc_mosaic_grid_area(lon, lat, area)
subroutine CALC_MOSAIC_GRID_AREA_(lon, lat, area)
real(kind=FMS_MOS_KIND_), dimension(:,:), intent(in) :: lon
real(kind=FMS_MOS_KIND_), dimension(:,:), intent(in) :: lat
real(kind=FMS_MOS_KIND_), dimension(:,:), intent(inout) :: area
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am asking purely for my own learning and do not know what is best: Why would you decide to change the intent instead of just initializing the output variable in the code before this subroutine is called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CALC_MOSAIC_GRID_AREA_ is a wrapper around get_grid_area, which sets the area but doesn't read the value that's passed in. So intent(out) more clearly communicates to the user what the code is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or in other words, there's no reason it should need to be initialized, because it gets set by get_grid_area.

real(kind=FMS_MOS_KIND_), dimension(:,:), intent(in) :: lon
real(kind=FMS_MOS_KIND_), dimension(:,:), intent(in) :: lat
real(kind=FMS_MOS_KIND_), dimension(:,:), intent(out) :: area
integer :: nlon, nlat

real(r8_kind) :: area_r8(size(area,1),size(area,2))

area_r8=real(area,r8_kind)

nlon = size(area,1)
nlat = size(area,2)
! make sure size of lon, lat and area are consitency
Expand Down
6 changes: 3 additions & 3 deletions test_fms/mosaic2/test_mosaic2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ subroutine test_is_inside_polygon
z2(1)=2.0_lkind ; z2(2)=4.0_lkind ; z2(3)=4.0_lkind ; z2(4)=2.0_lkind ; z2(5)=2.0_lkind
do i=1, n
r = sqrt( x2(i)**2 + y2(i)**2 + z2(i)**2 )
lon2(i)=atan(y2(i)/x2(i))
lon2(i)=atan2(y2(i), x2(i))
lat2(i)=asin(z2(i)/r)
end do

Expand All @@ -263,7 +263,7 @@ subroutine test_is_inside_polygon
y1=5.0_lkind
z1=4.2_lkind
r = sqrt(x1**2+y1**2+z1**2)
lon1=atan(y1/x1)
lon1=atan2(y1, x1)
lat1=asin(z1/r)

answer=.false.
Expand All @@ -275,7 +275,7 @@ subroutine test_is_inside_polygon
y1=3.0_lkind
z1=2.5_lkind
r = sqrt(x1**2+y1**2+z1**2)
lon1=atan(y1/x1)
lon1=atan2(y1, x1)
lat1=asin(z1/r)

answer=.true.
Expand Down
Loading