Skip to content

Commit

Permalink
Merge pull request #16 from apcraig/e3smup1
Browse files Browse the repository at this point in the history
Merge Icepack Consortium #cabfe0f111b61057db16c Nov 20, 2022
  • Loading branch information
apcraig authored Nov 21, 2022
2 parents 6a4533b + 0899390 commit 4d131da
Show file tree
Hide file tree
Showing 36 changed files with 125 additions and 1,402 deletions.
177 changes: 0 additions & 177 deletions columnphysics/icepack_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,6 @@ subroutine cleanup_itd (dt, ntrcr, &
nbtrcr, nblyr, &
tr_aero, &
tr_pond_topo, &
#ifdef UNDEPRECATE_0LAYER
heat_capacity, &
#endif
first_ice, &
trcr_depend, trcr_base, &
n_trcr_strata,nt_strata, &
Expand Down Expand Up @@ -825,12 +822,7 @@ subroutine cleanup_itd (dt, ntrcr, &

logical (kind=log_kind), intent(in) :: &
tr_aero, & ! aerosol flag
#ifdef UNDEPRECATE_0LAYER
tr_pond_topo, & ! topo pond flag
heat_capacity ! if false, ice and snow have zero heat capacity
#else
tr_pond_topo ! topo pond flag
#endif

logical (kind=log_kind), dimension(ncat), intent(inout) :: &
first_ice ! For bgc and S tracers. set to true if zapping ice.
Expand Down Expand Up @@ -987,11 +979,7 @@ subroutine cleanup_itd (dt, ntrcr, &
!-------------------------------------------------------------------

call zap_snow_temperature(dt, ncat, &
#ifdef UNDEPRECATE_0LAYER
heat_capacity, nblyr, &
#else
nblyr, &
#endif
nslyr, aicen, &
trcrn, vsnon, &
dfresh, dfhocn, &
Expand Down Expand Up @@ -1031,21 +1019,6 @@ subroutine cleanup_itd (dt, ntrcr, &
if (present(fzsal)) &
fzsal = fzsal + dfzsal

#ifdef UNDEPRECATE_0LAYER
!----------------------------------------------------------------
! If using zero-layer model (no heat capacity), check that the
! energy of snow and ice is correct.
!----------------------------------------------------------------

if ((.not. heat_capacity) .and. aice > puny) then
call zerolayer_check (ncat, nilyr, &
nslyr, aicen, &
vicen, vsnon, &
trcrn)
if (icepack_warnings_aborted(subname)) return
endif
#endif

end subroutine cleanup_itd

!=======================================================================
Expand Down Expand Up @@ -1480,9 +1453,6 @@ end subroutine zap_snow
!=======================================================================

subroutine zap_snow_temperature(dt, ncat, &
#ifdef UNDEPRECATE_0LAYER
heat_capacity, &
#endif
nblyr, &
nslyr, aicen, &
trcrn, vsnon, &
Expand All @@ -1502,10 +1472,6 @@ subroutine zap_snow_temperature(dt, ncat, &
real (kind=dbl_kind), intent(in) :: &
dt ! time step

#ifdef UNDEPRECATE_0LAYER
logical (kind=log_kind), intent(in) :: &
heat_capacity ! if false, ice and snow have zero heat capacity
#endif
real (kind=dbl_kind), dimension (:), intent(in) :: &
aicen ! concentration of ice

Expand Down Expand Up @@ -1567,11 +1533,7 @@ subroutine zap_snow_temperature(dt, ncat, &
do k = 1, nslyr

! snow enthalpy and max temperature
#ifdef UNDEPRECATE_0LAYER
if (hsn > hs_min .and. heat_capacity) then
#else
if (hsn > hs_min) then
#endif
! zqsn < 0
zqsn = trcrn(nt_qsno+k-1,n)
Tmax = -zqsn*puny*rnslyr / (rhos*cp_ice*vsnon(n))
Expand Down Expand Up @@ -1622,145 +1584,6 @@ subroutine zap_snow_temperature(dt, ncat, &

end subroutine zap_snow_temperature

#ifdef UNDEPRECATE_0LAYER
!=======================================================================
! Checks that the snow and ice energy in the zero layer thermodynamics
! model still agrees with the snow and ice volume.
! If there is an error, the model will abort.
! This subroutine is only called if heat_capacity = .false.
!
! author: Alison McLaren, Met Office
! May 2010: ECH replaced eicen, esnon with trcrn but did not test
! the changes. The loop below runs over n=1,ncat and I added loops
! over k, making the test more stringent.

subroutine zerolayer_check (ncat, nilyr, &
nslyr, aicen, &
vicen, vsnon, &
trcrn)

integer (kind=int_kind), intent(in) :: &
ncat , & ! number of thickness categories
nilyr , & ! number of ice layers
nslyr ! number of snow layers

real (kind=dbl_kind), dimension (:), intent(inout) :: &
aicen , & ! concentration of ice
vicen , & ! volume per unit area of ice (m)
vsnon ! volume per unit area of snow (m)

real (kind=dbl_kind), dimension (:,:), intent(inout) :: &
trcrn ! ice tracers

! local variables

integer (kind=int_kind) :: &
k , & ! vertical index
n ! category index

real (kind=dbl_kind) :: &
max_error ! max error in zero layer energy check
! (so max volume error = puny)

real (kind=dbl_kind), dimension (ncat) :: &
eicen ! energy of melting for each ice layer (J/m^2)

real (kind=dbl_kind), dimension (ncat) :: &
esnon ! energy of melting for each snow layer (J/m^2)

logical (kind=log_kind) :: &
ice_energy_correct , & ! zero layer ice energy check
snow_energy_correct ! zero layer snow energy check

real (kind=dbl_kind) :: &
worka, workb

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

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

max_error = puny*Lfresh*rhos ! max error in zero layer energy check
! (so max volume error = puny)

!----------------------------------------------------------------
! Calculate difference between ice and snow energies and the
! energy values derived from the ice and snow volumes
!----------------------------------------------------------------

ice_energy_correct = .true.
snow_energy_correct = .true.

worka = c0
workb = c0

do n = 1, ncat

eicen(n) = c0
do k = 1, nilyr
eicen(n) = eicen(n) + trcrn(nt_qice+k-1,n) &
* vicen(n) / real(nilyr,kind=dbl_kind)
enddo
worka = eicen(n) + rhoi * Lfresh * vicen(n)
esnon(n) = c0
do k = 1, nslyr
esnon(n) = esnon(n) + trcrn(nt_qsno+k-1,n) &
* vsnon(n) / real(nslyr,kind=dbl_kind)
enddo
workb = esnon(n) + rhos * Lfresh * vsnon(n)

if(abs(worka) > max_error) ice_energy_correct = .false.
if(abs(workb) > max_error) snow_energy_correct = .false.

!----------------------------------------------------------------
! If there is a problem, abort with error message
!----------------------------------------------------------------

if (.not. ice_energy_correct) then

if (abs(worka) > max_error) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//' zerolayer check - wrong ice energy')
write(warnstr,*) subname, 'n:', n
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'eicen =', eicen(n)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'error=', worka
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'vicen =', vicen(n)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'aicen =', aicen(n)
call icepack_warnings_add(warnstr)
endif

endif
if (icepack_warnings_aborted(subname)) return

if (.not. snow_energy_correct) then

if (abs(workb) > max_error) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//' zerolayer check - wrong snow energy')
write(warnstr,*) subname, 'n:', n
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'esnon =', esnon(n)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'error=', workb
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'vsnon =', vsnon(n)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'aicen =', aicen(n)
call icepack_warnings_add(warnstr)
return
endif

endif

enddo ! ncat

end subroutine zerolayer_check
#endif
!=======================================================================
!autodocument_start icepack_init_itd
! Initialize area fraction and thickness boundaries for the itd model
Expand Down
11 changes: 0 additions & 11 deletions columnphysics/icepack_mechred.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ module icepack_mechred
use icepack_parameters, only: puny, Lfresh, rhoi, rhos

use icepack_parameters, only: kstrength, krdg_partic, krdg_redist, mu_rdg
#ifdef UNDEPRECATE_0LAYER
use icepack_parameters, only: heat_capacity, conserv_check
#else
use icepack_parameters, only: conserv_check
#endif
use icepack_tracers, only: tr_pond_topo, tr_aero, tr_iso, tr_brine, ntrcr, nbtrcr
use icepack_tracers, only: nt_qice, nt_qsno, nt_fbri, nt_sice
use icepack_tracers, only: nt_alvl, nt_vlvl, nt_aero, nt_isosno, nt_isoice
Expand Down Expand Up @@ -1829,9 +1825,6 @@ subroutine icepack_step_ridge (dt, ndtd, &
!tr_pond_topo,& ! if .true., use explicit topography-based ponds
!tr_aero ,& ! if .true., use aerosol tracers
!tr_brine !,& ! if .true., brine height differs from ice thickness
#ifdef UNDEPRECATE_0LAYER
!heat_capacity ! if true, ice has nonzero heat capacity
#endif

logical (kind=log_kind), dimension(:), intent(inout) :: &
first_ice ! true until ice forms
Expand Down Expand Up @@ -1922,11 +1915,7 @@ subroutine icepack_step_ridge (dt, ndtd, &
n_aero, &
nbtrcr, nblyr, &
tr_aero, &
#ifdef UNDEPRECATE_0LAYER
tr_pond_topo, heat_capacity, &
#else
tr_pond_topo, &
#endif
first_ice, &
trcr_depend, trcr_base, &
n_trcr_strata, nt_strata, &
Expand Down
Loading

0 comments on commit 4d131da

Please sign in to comment.