Skip to content

Commit

Permalink
review response - use select case (this%grid_type)
Browse files Browse the repository at this point in the history
  • Loading branch information
aekiss authored and micaeljtoliveira committed Nov 4, 2024
1 parent cb68a69 commit f7d11bd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/topography.f90
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,17 @@ subroutine topography_number_seas(this, sea_number, number_of_seas, silent)
im = i - 1
ip = i + 1
if (sea(i, j) < land .and. sea(i, j) > 0) then
if ( this%grid_type == 'C' ) then
new_sea = min(sea(i, j), sea(im, j), sea(ip, j), sea(i, jm), sea(i, jp))
else
! get chokes, assuming B-grid connectivity rules
select case (this%grid_type)
case ('B')
choke_east = .not. (any(sea(i:ip, jp) == land) .and. any(sea(i:ip, jm) == land))
choke_west = .not. (any(sea(im:i, jp) == land) .and. any(sea(im:i, jm) == land))
choke_south = .not. (any(sea(im, jm:j) == land) .and. any(sea(ip, jm:j) == land))
choke_north = .not. (any(sea(im, j:jp) == land) .and. any(sea(ip, j:jp) == land))
new_sea = min(sea(i, j), minval([sea(im, j), sea(ip, j), sea(i, jm), sea(i, jp)], &
mask=[choke_west, choke_east, choke_south, choke_north]))
end if
case ('C')
new_sea = min(sea(i, j), sea(im, j), sea(ip, j), sea(i, jm), sea(i, jp))
end select
if (sea(i, j) /= new_sea) then
sea(i, j) = new_sea
counter = counter + 1
Expand Down Expand Up @@ -387,17 +387,17 @@ subroutine topography_number_seas(this, sea_number, number_of_seas, silent)
im = i - 1
ip = i + 1
if (sea(i, j) < land .and. sea(i, j) > 0) then
if ( this%grid_type == 'C' ) then
new_sea = min(sea(i, j), sea(i, j), sea(im, j), sea(ip, j), sea(i, jm), sea(i, jp))
else
! get chokes, assuming B-grid connectivity rules
select case (this%grid_type)
case ('B')
choke_east = .not. (any(sea(i:ip, jp) == land) .and. any(sea(i:ip, jm) == land))
choke_west = .not. (any(sea(im:i, jp) == land) .and. any(sea(im:i, jm) == land))
choke_south = .not. (any(sea(im, jm:j) == land) .and. any(sea(ip, jm:j) == land))
choke_north = .not. (any(sea(im, j:jp) == land) .and. any(sea(ip, j:jp) == land))
new_sea = min(sea(i, j), minval([sea(im, j), sea(ip, j), sea(i, jm), sea(i, jp)], &
mask=[choke_west, choke_east, choke_south, choke_north]))
end if
case ('C')
new_sea = min(sea(i, j), sea(im, j), sea(ip, j), sea(i, jm), sea(i, jp))
end select
if (sea(i, j) /= new_sea) then
sea(i, j) = new_sea
counter = counter + 1
Expand Down

0 comments on commit f7d11bd

Please sign in to comment.