Skip to content

Commit

Permalink
Add dorebin and docleanup optional arguments to icepack_step_ridge (C…
Browse files Browse the repository at this point in the history
…ICE-Consortium#503)

Add dorebin and docleanup optional arguments to icepack_step_ridge to support NOT calling cleanup_itd and NOT calling rebin in the ridge_ice.
Closes CICE-Consortium#478

Rename limit_aice_in argument in ridge_ice to limit_aice. This argument is not used in Icepack or CICE at the moment.

Update interface document

Based on https://github.com/ESMG/Icepack/tree/optional_cleanup
  • Loading branch information
apcraig authored Oct 24, 2024
1 parent f5f03b9 commit 6da5668
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 21 deletions.
39 changes: 24 additions & 15 deletions columnphysics/icepack_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,8 @@ end subroutine column_conservation_check
!=======================================================================

! Cleanup subroutine that rebins thickness categories if necessary,
! eliminates very small ice areas while conserving mass and energy,
! aggregates state variables, and does a boundary call.
! eliminates very small ice areas while conserving mass and energy
! and aggregates state variables.
! It is a good idea to call this subroutine after the thermodynamics
! (thermo_vertical/thermo_itd) and again after the dynamics
! (evp/transport/ridging).
Expand All @@ -758,7 +758,8 @@ subroutine cleanup_itd (dt, hin_max, &
fpond, fresh, &
fsalt, fhocn, &
faero_ocn, fiso_ocn, &
flux_bio, Tf, limit_aice_in)
flux_bio, Tf, &
limit_aice, dorebin)

real (kind=dbl_kind), intent(in) :: &
dt ! time step
Expand Down Expand Up @@ -817,8 +818,9 @@ subroutine cleanup_itd (dt, hin_max, &
fiso_ocn ! isotope flux to ocean (kg/m^2/s)

logical (kind=log_kind), intent(in), optional :: &
limit_aice_in ! if false, allow aice to be out of bounds
! may want to allow this for unit tests
dorebin, & ! if false, do not call rebin (default true)
limit_aice ! if false, allow aice to be out of bounds
! may want to allow this for unit tests (default true)

! local variables

Expand All @@ -842,18 +844,25 @@ subroutine cleanup_itd (dt, hin_max, &
dflux_bio ! zapped biology flux (mmol/m^2/s)

logical (kind=log_kind) :: &
limit_aice ! if true, check for aice out of bounds
ldorebin , & ! if true, call rebin
llimit_aice ! if true, check for aice out of bounds

character(len=*),parameter :: subname='(cleanup_itd)'

!-----------------------------------------------------------------
! Initialize
!-----------------------------------------------------------------

if (present(limit_aice_in)) then
limit_aice = limit_aice_in
if (present(limit_aice)) then
llimit_aice = limit_aice
else
limit_aice = .true.
llimit_aice = .true.
endif

if (present(dorebin)) then
ldorebin = dorebin
else
ldorebin = .true.
endif

dfpond = c0
Expand All @@ -871,7 +880,7 @@ subroutine cleanup_itd (dt, hin_max, &
call aggregate_area (aicen, aice, aice0)
if (icepack_warnings_aborted(subname)) return

if (limit_aice) then ! check for aice out of bounds
if (llimit_aice) then ! check for aice out of bounds
if (aice > c1+puny .or. aice < -puny) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//' aggregate ice area out of bounds')
Expand All @@ -883,13 +892,13 @@ subroutine cleanup_itd (dt, hin_max, &
enddo
return
endif
endif ! limit_aice
endif ! llimit_aice

!-----------------------------------------------------------------
! Identify grid cells with ice.
!-----------------------------------------------------------------

if (aice > puny) then
if (ldorebin .and. aice > puny) then

!-----------------------------------------------------------------
! Make sure ice in each category is within its thickness bounds.
Expand All @@ -898,7 +907,7 @@ subroutine cleanup_itd (dt, hin_max, &
! correctly (e.g., very fast ice growth).
!-----------------------------------------------------------------

call rebin (trcr_depend, &
call rebin (trcr_depend, &
trcr_base, &
n_trcr_strata, &
nt_strata, &
Expand All @@ -913,7 +922,7 @@ subroutine cleanup_itd (dt, hin_max, &
! Zero out ice categories with very small areas.
!-----------------------------------------------------------------

if (limit_aice) then
if (llimit_aice) then
call zap_small_areas (dt, &
aice, aice0, &
aicen, trcrn, &
Expand All @@ -937,7 +946,7 @@ subroutine cleanup_itd (dt, hin_max, &
return
endif

endif ! l_limit_aice
endif ! llimit_aice

!-------------------------------------------------------------------
! Zap snow that has out of bounds temperatures
Expand Down
34 changes: 29 additions & 5 deletions columnphysics/icepack_mechred.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,9 @@ subroutine icepack_step_ridge(dt, ndtd, &
araftn, vraftn, &
aice, fsalt, &
first_ice, fzsal, &
flux_bio, closing, Tf )
flux_bio, closing, &
Tf, &
docleanup, dorebin)

real (kind=dbl_kind), intent(in) :: &
dt ! time step
Expand Down Expand Up @@ -1815,13 +1817,21 @@ subroutine icepack_step_ridge(dt, ndtd, &
logical (kind=log_kind), dimension(:), intent(inout) :: &
first_ice ! true until ice forms

logical (kind=log_kind), intent(in), optional :: &
docleanup, & ! if false, do not call cleanup_itd (default true)
dorebin ! if false, do not call rebin in cleanup_itd (default true)

!autodocument_end

! local variables

real (kind=dbl_kind) :: &
dtt ! thermo time step

logical (kind=log_kind) :: &
ldocleanup, &! if true, call cleanup_itd
ldorebin ! if true, call rebin in cleanup_itd

logical (kind=log_kind), save :: &
first_call = .true. ! first call flag

Expand All @@ -1841,6 +1851,17 @@ subroutine icepack_step_ridge(dt, ndtd, &
endif
endif

if (present(docleanup)) then
ldocleanup = docleanup
else
ldocleanup = .true.
endif

if (present(dorebin)) then
ldorebin = dorebin
else
ldorebin = .true.
endif

!-----------------------------------------------------------------
! Identify ice-ocean cells.
Expand Down Expand Up @@ -1880,8 +1901,9 @@ subroutine icepack_step_ridge(dt, ndtd, &
! categories with very small areas.
!-----------------------------------------------------------------

dtt = dt * ndtd ! for proper averaging over thermo timestep
call cleanup_itd (dtt, hin_max, &
if (ldocleanup) then
dtt = dt * ndtd ! for proper averaging over thermo timestep
call cleanup_itd(dtt, hin_max, &
aicen, trcrn, &
vicen, vsnon, &
aice0, aice, &
Expand All @@ -1893,8 +1915,10 @@ subroutine icepack_step_ridge(dt, ndtd, &
fpond, fresh, &
fsalt, fhocn, &
faero_ocn, fiso_ocn, &
flux_bio, Tf)
if (icepack_warnings_aborted(subname)) return
flux_bio, Tf, &
dorebin = ldorebin)
if (icepack_warnings_aborted(subname)) return
endif

first_call = .false.

Expand Down
8 changes: 7 additions & 1 deletion doc/source/user_guide/interfaces.include
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,9 @@ icepack_step_ridge
araftn, vraftn, &
aice, fsalt, &
first_ice, fzsal, &
flux_bio, closing, Tf )
flux_bio, closing, &
Tf, &
docleanup, dorebin)

real (kind=dbl_kind), intent(in) :: &
dt ! time step
Expand Down Expand Up @@ -572,6 +574,10 @@ icepack_step_ridge
logical (kind=log_kind), dimension(:), intent(inout) :: &
first_ice ! true until ice forms

logical (kind=log_kind), intent(in), optional :: &
docleanup, & ! if false, do not call cleanup_itd (default true)
dorebin ! if false, do not call rebin in cleanup_itd (default true)



icepack_mushy_physics.F90
Expand Down

0 comments on commit 6da5668

Please sign in to comment.