Skip to content

Commit

Permalink
+Convective adjustment outside regridding_main
Browse files Browse the repository at this point in the history
  Eliminated the option to do convective adjustment within regridding_main,
including making the optional argument conv_adjust mandatory, with an error
message if it is set to .true., so that there will not be the possibility of
this code change silently changing the code behavior or solutions.  After a
decent interval, this argument can be safely eliminated.  As a result of these
changes, the intent of two key arguments to regridding_main() could be changed
from intent(inout) to intent(in), which should help clarify the purpose of this
routine. All answers are bitwise identical, but there are interface changes.
  • Loading branch information
Hallberg-NOAA authored and marshallward committed Apr 9, 2022
1 parent fd2060c commit 28ff86e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/ALE/MOM_ALE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ subroutine ALE_main( G, GV, US, h, u, v, tv, Reg, CS, OBC, dt, frac_shelf_h)

! Build new grid. The new grid is stored in h_new. The old grid is h.
! Both are needed for the subsequent remapping of variables.
call regridding_main( CS%remapCS, CS%regridCS, G, GV, h, tv, h_new, dzRegrid, &
frac_shelf_h, conv_adjust=.false., PCM_cell=PCM_cell)
call regridding_main( CS%remapCS, CS%regridCS, G, GV, h, tv, h_new, dzRegrid, conv_adjust=.false., &
frac_shelf_h=frac_shelf_h, PCM_cell=PCM_cell)

call check_grid( G, GV, h, 0. )

Expand Down
24 changes: 15 additions & 9 deletions src/ALE/MOM_regridding.F90
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,8 @@ end subroutine end_regridding

!------------------------------------------------------------------------------
!> Dispatching regridding routine for orchestrating regridding & remapping
subroutine regridding_main( remapCS, CS, G, GV, h, tv, h_new, dzInterface, frac_shelf_h, &
conv_adjust, PCM_cell)
subroutine regridding_main( remapCS, CS, G, GV, h, tv, h_new, dzInterface, conv_adjust, &
frac_shelf_h, PCM_cell)
!------------------------------------------------------------------------------
! This routine takes care of (1) building a new grid and (2) remapping between
! the old grid and the new grid. The creation of the new grid can be based
Expand All @@ -794,22 +794,29 @@ subroutine regridding_main( remapCS, CS, G, GV, h, tv, h_new, dzInterface, frac_
type(regridding_CS), intent(in) :: CS !< Regridding control structure
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
type(verticalGrid_type), intent(in) :: GV !< Ocean vertical grid structure
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h !< Current 3D grid obtained after
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< Current 3D grid obtained after
!! the last time step
type(thermo_var_ptrs), intent(inout) :: tv !< Thermodynamical variables (T, S, ...)
type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamical variables (T, S, ...)
real, dimension(SZI_(G),SZJ_(G),CS%nk), intent(inout) :: h_new !< New 3D grid consistent with target coordinate
real, dimension(SZI_(G),SZJ_(G),CS%nk+1), intent(inout) :: dzInterface !< The change in position of each interface
logical, intent(in ) :: conv_adjust !< If true, regridding_main should do
!! convective adjustment, but because it no
!! longer does convective adjustment this must
!! be false. This argument has been retained to
!! trap inconsistent code, but will eventually
!! be eliminated.
real, dimension(SZI_(G),SZJ_(G)), optional, intent(in ) :: frac_shelf_h !< Fractional ice shelf coverage
logical, optional, intent(in ) :: conv_adjust !< If true, do convective adjustment
logical, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
optional, intent(out ) :: PCM_cell !< Use PCM remapping in cells where true

! Local variables
real :: trickGnuCompiler
logical :: do_convective_adjustment

do_convective_adjustment = .true.
if (present(conv_adjust)) do_convective_adjustment = conv_adjust
if (conv_adjust) call MOM_error(FATAL, &
"regridding_main: convective adjustment no longer is done inside of regridding_main. "//&
"The code needs to be modified to call regridding_main() with conv_adjust=.false, "//&
"and a call to convective_adjustment added before calling regridding_main() "//&
"if regridding_preadjust_reqs() indicates that this is necessary.")
if (present(PCM_cell)) PCM_cell(:,:,:) = .false.

select case ( CS%regridding_scheme )
Expand All @@ -824,7 +831,6 @@ subroutine regridding_main( remapCS, CS, G, GV, h, tv, h_new, dzInterface, frac_
call build_sigma_grid( CS, G, GV, h, dzInterface )
call calc_h_new_by_dz(CS, G, GV, h, dzInterface, h_new)
case ( REGRIDDING_RHO )
if (do_convective_adjustment) call convective_adjustment(G, GV, h, tv)
call build_rho_grid( G, GV, G%US, h, tv, dzInterface, remapCS, CS, frac_shelf_h )
call calc_h_new_by_dz(CS, G, GV, h, dzInterface, h_new)
case ( REGRIDDING_ARBITRARY )
Expand Down
4 changes: 2 additions & 2 deletions src/initialization/MOM_state_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2725,8 +2725,8 @@ subroutine MOM_temp_salt_initialize_from_Z(h, tv, depth_tot, G, GV, US, PF, just

call regridding_preadjust_reqs(regridCS, do_conv_adj, ignore)
if (do_conv_adj) call convective_adjustment(G, GV_loc, h1, tv_loc)
call regridding_main( remapCS, regridCS, G, GV_loc, h1, tv_loc, h, dz_interface, frac_shelf_h, &
conv_adjust=.false. )
call regridding_main( remapCS, regridCS, G, GV_loc, h1, tv_loc, h, dz_interface, conv_adjust=.false., &
frac_shelf_h=frac_shelf_h )

deallocate( dz_interface )
endif
Expand Down

0 comments on commit 28ff86e

Please sign in to comment.