Skip to content

Commit

Permalink
Update dorebin
Browse files Browse the repository at this point in the history
  • Loading branch information
dabail10 committed Oct 25, 2024
2 parents 04ba407 + 6da5668 commit e3422e7
Show file tree
Hide file tree
Showing 4 changed files with 112 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 @@ -756,8 +756,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 @@ -776,7 +776,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 @@ -835,8 +836,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 @@ -860,18 +862,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 @@ -889,7 +898,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 @@ -901,13 +910,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 @@ -916,7 +925,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 @@ -931,7 +940,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 @@ -955,7 +964,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
33 changes: 28 additions & 5 deletions columnphysics/icepack_mechred.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,8 @@ subroutine icepack_step_ridge(dt, ndtd, &
aice, fsalt, &
first_ice, fzsal, &
flux_bio, closing, &
Tf, rdpnd )
Tf, &
docleanup, dorebin)

real (kind=dbl_kind), intent(in) :: &
dt ! time step
Expand Down Expand Up @@ -1829,13 +1830,21 @@ subroutine icepack_step_ridge(dt, ndtd, &
real (kind=dbl_kind), intent(inout), optional :: &
rdpnd ! pond drainage due to ridging (m w.e. avg. over cell)

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 @@ -1855,6 +1864,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 @@ -1894,8 +1914,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 @@ -1907,8 +1928,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
53 changes: 53 additions & 0 deletions columnphysics/icepack_therm_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ subroutine linear_itd (hin_max, trcr_depend, &
aicen, trcrn, &
vicen, vsnon, &
aice, aice0, &
<<<<<<< HEAD
fpond, Tf, &
mipnd)
=======
fpond, Tf )
>>>>>>> origin/main

real (kind=dbl_kind), dimension(0:ncat), intent(in) :: &
hin_max ! category boundaries (m)
Expand Down Expand Up @@ -885,8 +889,12 @@ subroutine lateral_melt (dt, fpond, &
aicen, vicen, &
vsnon, trcrn, &
flux_bio, d_afsd_latm,&
<<<<<<< HEAD
floe_rad_c, floe_binwidth, &
mipnd)
=======
floe_rad_c, floe_binwidth)
>>>>>>> origin/main

real (kind=dbl_kind), intent(in) :: &
dt ! time step (s)
Expand Down Expand Up @@ -948,8 +956,15 @@ subroutine lateral_melt (dt, fpond, &
real (kind=dbl_kind), dimension (ncat) :: &
aicen_init, & ! initial area fraction
vicen_init, & ! volume per unit area of ice (m)
<<<<<<< HEAD
vsnon_init, & ! volume per unit area of snow (m)
G_radialn ! rate of lateral melt (m/s)
=======
vsnon_init, & ! initial volume of snow (m)
G_radialn , & ! rate of lateral melt (m/s)
delta_an , & ! change in the ITD
rsiden ! delta_an/aicen
>>>>>>> origin/main

real (kind=dbl_kind), dimension (:,:), allocatable :: &
afsdn , & ! floe size distribution tracer
Expand Down Expand Up @@ -982,8 +997,17 @@ subroutine lateral_melt (dt, fpond, &
dfsalt = c0
dvssl = c0
dvint = c0
<<<<<<< HEAD
vicen_init(:) = vicen(:)
vsnon_init(:) = vsnon(:)
=======
bin1_arealoss = c0
tmp = c0
vicen_init = vicen(:)
G_radialn = c0
delta_an = c0
rsiden = c0
>>>>>>> origin/main

if (tr_fsd) then
call icepack_cleanup_fsd (trcrn(nt_fsd:nt_fsd+nfsd-1,:))
Expand Down Expand Up @@ -1058,7 +1082,16 @@ subroutine lateral_melt (dt, fpond, &
d_afsd_tmp(:) = c0
nsubt = 0

<<<<<<< HEAD
DO WHILE (elapsed_t.lt.dt)
=======
! state variables
vicen_init(n) = vicen(n)
vsnon_init(n) = vsnon(n)
aicen(n) = aicen(n) * (c1 - rsiden(n))
vicen(n) = vicen(n) * (c1 - rsiden(n))
vsnon(n) = vsnon(n) * (c1 - rsiden(n))
>>>>>>> origin/main

nsubt = nsubt + 1
if (nsubt.gt.100) then
Expand Down Expand Up @@ -1102,7 +1135,13 @@ subroutine lateral_melt (dt, fpond, &

END DO

<<<<<<< HEAD
afsdn(:,n) = afsd_tmp(:)
=======
! timestep required for this
subdt = get_subdt_fsd(afsd_tmp(:), d_afsd_tmp(:))
subdt = MIN(subdt, dt)
>>>>>>> origin/main

end if ! aicen
end if ! rside > 0, otherwise do nothing
Expand Down Expand Up @@ -1165,19 +1204,29 @@ subroutine lateral_melt (dt, fpond, &

if (z_tracers) &
call lateral_melt_bgc(dt, &
<<<<<<< HEAD
ncat, nblyr, &
rsiden(1), vicen_init, & !echmod: use rsiden !CMB this should be sent rsiden
trcrn, &
flux_bio, nbtrcr)
=======
rsiden, vicen_init, &
trcrn, flux_bio)
>>>>>>> origin/main
if (icepack_warnings_aborted(subname)) return


if (tr_fsd) then

trcrn(nt_fsd:nt_fsd+nfsd-1,:) = afsdn

<<<<<<< HEAD
call icepack_cleanup_fsd (ncat, nfsd, trcrn(nt_fsd:nt_fsd+nfsd-1,:) )
if (icepack_warnings_aborted(subname)) return
=======
call icepack_cleanup_fsd (trcrn(nt_fsd:nt_fsd+nfsd-1,:) )
if (icepack_warnings_aborted(subname)) return
>>>>>>> origin/main

! diagnostics
do k = 1, nfsd
Expand Down Expand Up @@ -2158,8 +2207,12 @@ subroutine icepack_step_therm2(dt, hin_max, &
vsnon, trcrn, &
flux_bio, &
d_afsd_latm, &
<<<<<<< HEAD
floe_rad_c,floe_binwidth, &
mipnd)
=======
floe_rad_c,floe_binwidth)
>>>>>>> origin/main
if (icepack_warnings_aborted(subname)) return

! Floe welding during freezing conditions
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 e3422e7

Please sign in to comment.