Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to advanced snow physics implementation #449

Merged
merged 5 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions columnphysics/icepack_flux.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
module icepack_flux

use icepack_kinds
use icepack_parameters, only: c1, emissivity
use icepack_parameters, only: c1, emissivity, snwgrain
use icepack_warnings, only: warnstr, icepack_warnings_add
use icepack_warnings, only: icepack_warnings_setabort, icepack_warnings_aborted
use icepack_tracers, only: tr_iso, tr_snow
use icepack_tracers, only: tr_iso

implicit none
private
Expand Down Expand Up @@ -217,7 +217,7 @@ subroutine merge_fluxes (aicen, &
meltt = meltt + melttn * aicen
meltb = meltb + meltbn * aicen
melts = melts + meltsn * aicen
if (tr_snow) then
if (snwgrain) then
meltsliq = meltsliq + meltsliqn * aicen
endif
if (present(dsnow)) then
Expand Down
14 changes: 9 additions & 5 deletions columnphysics/icepack_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ module icepack_itd
use icepack_kinds
use icepack_parameters, only: c0, c1, c2, c3, c15, c25, c100, p1, p01, p001, p5, puny
use icepack_parameters, only: Lfresh, rhos, ice_ref_salinity, hs_min, cp_ice, Tocnfrz, rhoi
use icepack_parameters, only: rhosi, sk_l, hs_ssl, min_salin, rsnw_fall
use icepack_parameters, only: rhosi, sk_l, hs_ssl, min_salin, rsnw_fall, rhosnew
use icepack_tracers, only: nt_Tsfc, nt_qice, nt_qsno, nt_aero, nt_isosno, nt_isoice
use icepack_tracers, only: nt_apnd, nt_hpnd, nt_fbri, tr_brine, nt_bgc_S, bio_index
use icepack_tracers, only: n_iso, tr_iso, tr_snow, nt_smice, nt_rsnw, nt_rhos, nt_sice
use icepack_tracers, only: n_iso, tr_iso, nt_smice, nt_rsnw, nt_rhos, nt_sice
use icepack_tracers, only: icepack_compute_tracers
use icepack_parameters, only: solve_zsal, skl_bgc, z_tracers
use icepack_parameters, only: kcatbound, kitd, saltflux_option
use icepack_parameters, only: kcatbound, kitd, saltflux_option, snwgrain, snwredist
use icepack_therm_shared, only: Tmin, hi_min
use icepack_warnings, only: warnstr, icepack_warnings_add
use icepack_warnings, only: icepack_warnings_setabort, icepack_warnings_aborted
Expand Down Expand Up @@ -1227,9 +1227,13 @@ subroutine zap_small_areas (dt, ntrcr, &
enddo
endif
if (tr_brine) trcrn(nt_fbri,n) = c1
if (tr_snow) then
if (trim(snwredist) == 'ITDrdg') then
do k = 1, nslyr
trcrn(nt_rhos +k-1,n) = rhosnew
enddo
endif
if (snwgrain) then
do k = 1, nslyr
trcrn(nt_rhos +k-1,n) = rhos
trcrn(nt_smice+k-1,n) = rhos
trcrn(nt_rsnw +k-1,n) = rsnw_fall
enddo
Expand Down
8 changes: 4 additions & 4 deletions columnphysics/icepack_therm_itd.F90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eclare108213 : For the snwredist options, it seems we're only supporting ITDrdg and none. Are bulk, 30percent and ITDsd defunct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're supporting ITDrdg, bulk and none. The old 30percent is available - it's set using 'bulk' with a (new) namelist parameter that can be any percentage. ITDsd is defunct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I'll have to look into how the bulk option would work in mpas-seaice. Does 'bulk' use the effective snow density?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think bulk works the same way as 30percent did before, just generalized the percentage. So it only rearranges the snow without changing the density. And yes the density tracer is still available in that case - it should remain constant, although I haven't looked at that yet after this latest round of changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that the way it's implemented, we are requiring the density tracer for the bulk option. Otherwise it will fail. And it doesn't do anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't fail in Icepack (or CICE). Can MPAS-SI not implement it that way? With it, analysis scripts looking for it (for comparison with ITDrdg) won't fail, and its values can be verified to be constant.
Have you tried running this icepack version in your E3SM tests? I think it's coded so that if the driver doesn't have the tracer, icepack will still handle it gracefully. But I'm not sure about that. If it doesn't work, then I can change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested (recently) snwredist = bulk and snow effective density off, but I will. But tracers are passed to icepack in the tracer array which in mpas is only made up of active tracers. The index for nonactive tracers is set to 0. So in something like

do k = nt_rhos, nt_rhos+nslyr-1
trcrn(k,n) = max(trcrn(k,n)-rhosmin, c0)

I suspect F90 won't like that nt_rhos = 0, and the rest of the code will overwrite something valuable.

I could be wrong. I've almost got your changes implemented. I'll try running with different options.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module icepack_therm_itd
use icepack_parameters, only: p001, p1, p333, p5, p666, puny, bignum
use icepack_parameters, only: rhos, rhoi, Lfresh, ice_ref_salinity
use icepack_parameters, only: phi_init, dsin0_frazil, hs_ssl, salt_loss
use icepack_parameters, only: rhosi, conserv_check, rhosmin
use icepack_parameters, only: rhosi, conserv_check, rhosmin, snwredist
use icepack_parameters, only: kitd, ktherm
use icepack_parameters, only: z_tracers, solve_zsal, hfrazilmin
use icepack_parameters, only: saltflux_option
Expand All @@ -35,7 +35,7 @@ module icepack_therm_itd
use icepack_tracers, only: nt_apnd, nt_hpnd, nt_aero, nt_isosno, nt_isoice
use icepack_tracers, only: nt_Tsfc, nt_iage, nt_FY, nt_fsd, nt_rhos, nt_sice
use icepack_tracers, only: nt_alvl, nt_vlvl
use icepack_tracers, only: tr_pond_lvl, tr_pond_topo, tr_snow
use icepack_tracers, only: tr_pond_lvl, tr_pond_topo
use icepack_tracers, only: tr_iage, tr_FY, tr_lvl, tr_aero, tr_iso, tr_brine, tr_fsd
use icepack_tracers, only: n_aero, n_iso
use icepack_tracers, only: bio_index
Expand Down Expand Up @@ -569,7 +569,7 @@ subroutine linear_itd (ncat, hin_max, &
enddo
enddo
! maintain rhos_cmp positive definiteness
if (tr_snow) then
if (snwredist /= 'none') then
do n = 1, ncat
do k = nt_rhos, nt_rhos+nslyr-1
trcrn(k,n) = max(trcrn(k,n)-rhosmin, c0)
Expand All @@ -596,7 +596,7 @@ subroutine linear_itd (ncat, hin_max, &
enddo
enddo
! maintain rhos_cmp positive definiteness
if (tr_snow) then
if (snwredist /= 'none') then
do n = 1, ncat
do k = nt_rhos, nt_rhos+nslyr-1
trcrn(k,n) = trcrn(k,n) + rhosmin
Expand Down
2 changes: 1 addition & 1 deletion columnphysics/icepack_therm_mushy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3307,7 +3307,7 @@ subroutine flood_ice(hsn, hin, &
! density of newly formed snow-ice
rho_snowice = phi_snowice * rho_ocn + (c1 - phi_snowice) * rhoi
endif ! freeboard_density > c0
! endif ! tr_snow
! endif ! snwgrain

if (freeboard_density > c0) then ! ice is flooded

Expand Down
51 changes: 28 additions & 23 deletions columnphysics/icepack_therm_vertical.F90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes 141, 267 and 268 would be a problem with other ktherm options and the snow grain tracer active. Since the internal assignments of massice and massliq are wrapped in a ktherm == 2 statement, they would be sent as zeros to thickness_changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first look didn't catch this. Probably the simplest fix is to just pull the assignment statements out of the ktherm == 2 if-else and move to after both the temperature_changes routines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to support advanced snow physics on BL99 thermo? We could abort if that combination is attempted. Or we could initialize massice and massliq according to the BL99 assumptions (use rhos for massice and 0 for massliq?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just moving it out of the if statement is easiest. It has it's own if snwgrain ... wrapper. I'm certainly not in favor of supporting a massive number of config combinations, but the snow stuff doesn't really care about mushy or BL99. That's not to say I've tested it with BL99...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean line 333ff?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I agree that should be changed.

Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ subroutine thermo_vertical (nilyr, nslyr, &
zSin , & ! internal ice layer salinities
rsnw , & ! snow grain radius (10^-6 m)
smice , & ! ice mass tracer in snow (kg/m^3)
smliq , & ! liquid water mass tracer in snow (kg/m^3)
smliq ! liquid water mass tracer in snow (kg/m^3)

real (kind=dbl_kind), dimension (:), intent(out) :: &
massice , & ! ice mass in snow (kg/m^2)
massliq ! liquid water mass in snow (kg/m^2)

Expand Down Expand Up @@ -262,6 +264,8 @@ subroutine thermo_vertical (nilyr, nslyr, &
zTsn(:) = c0
zTin(:) = c0
meltsliq= c0
massice(:) = c0
massliq(:) = c0

if (calc_Tsfc) then
fsensn = c0
Expand Down Expand Up @@ -325,7 +329,7 @@ subroutine thermo_vertical (nilyr, nslyr, &
smice, smliq)
if (icepack_warnings_aborted(subname)) return

! reinitialize mass in case of snow-ice formation
! mass of ice and liquid water in snow
if (snwgrain) then
massice(:) = smice(:) * hslyr
massliq(:) = smliq(:) * hslyr
Expand Down Expand Up @@ -2357,8 +2361,9 @@ subroutine icepack_step_therm1(dt, ncat, nilyr, nslyr, &
n ! category index

real (kind=dbl_kind) :: &
rnslyr , & ! 1 / nslyr
worka, workb ! temporary variables
worka , & ! temporary variables
workb , &
workc

! 2D coupler variables (computed for each category, then aggregated)
real (kind=dbl_kind) :: &
Expand Down Expand Up @@ -2465,6 +2470,10 @@ subroutine icepack_step_therm1(dt, ncat, nilyr, nslyr, &
l_meltsliq = c0
l_meltsliqn = c0

! solid and liquid components of snow mass
massicen(:,:) = c0
massliqn(:,:) = c0

!-----------------------------------------------------------------
! Initialize rate of snow loss to leads
!-----------------------------------------------------------------
Expand All @@ -2489,21 +2498,21 @@ subroutine icepack_step_therm1(dt, ncat, nilyr, nslyr, &
fsnow = fsnow*(c1-worka)
endif ! snwredist

!echmod - remove all of this code - non-BFB because of values carried in tracer arrays when the snow physics options are not active
!-----------------------------------------------------------------
! solid and liquid components of snow mass
!-----------------------------------------------------------------

massicen(:,:) = c0
massliqn(:,:) = c0
if (snwgrain) then
rnslyr = c1 / real(nslyr, dbl_kind)
do n = 1, ncat
do k = 1, nslyr
massicen(k,n) = smicen(k,n) * vsnon(n) * rnslyr ! kg/m^2
massliqn(k,n) = smliqn(k,n) * vsnon(n) * rnslyr
enddo
enddo
endif
! massicen(:,:) = c0
! massliqn(:,:) = c0
! if (snwgrain) then
! rnslyr = c1 / real(nslyr, dbl_kind)
! do n = 1, ncat
! do k = 1, nslyr
! massicen(k,n) = smicen(k,n) * vsnon(n) * rnslyr ! kg/m^2
! massliqn(k,n) = smliqn(k,n) * vsnon(n) * rnslyr
! enddo
! enddo
! endif

!-----------------------------------------------------------------
! Update the neutral drag coefficients to account for form drag
Expand Down Expand Up @@ -2904,14 +2913,10 @@ subroutine icepack_step_therm1(dt, ncat, nilyr, nslyr, &
if (snwgrain) then
do n = 1, ncat
if (vsnon(n) > puny) then
workc = real(nslyr, dbl_kind) * aicen(n) / vsnon(n)
do k = 1, nslyr
smicen(k,n) = massicen(k,n) / (vsnon(n) * rnslyr)
smliqn(k,n) = massliqn(k,n) / (vsnon(n) * rnslyr)
worka = smicen(k,n) + smliqn(k,n)
if (worka > puny) then
smicen(k,n) = rhos * smicen(k,n) / worka
smliqn(k,n) = rhos * smliqn(k,n) / worka
endif
smicen(k,n) = massicen(k,n) * workc
smliqn(k,n) = massliqn(k,n) * workc
enddo
else ! reset to default values
do k = 1, nslyr
Expand Down
31 changes: 23 additions & 8 deletions columnphysics/icepack_tracers.F90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eclare108213 : line 1294 in icepack_tracers.F90 should also be changed to rhosnew.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else part of this statement in icepack_snow.F90 is a problem. rhos_cmpn can't be used at all if snow effective density is false otherwise it will overwrite ice area.
Lines 318 to 320
else
rhos_cmpn(:,:) = rhos
endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the first part of the if statement
if (trim(snwredist) /= 'none') then
should be changed to
if(snwredist(1:3) = 'ITD') then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Will it work to just remove the else part? This is part of the reason for defining the all of the tracers when tr_snow=T.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, deleting L318 and 319 works

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module icepack_tracers

use icepack_kinds
use icepack_parameters, only: c0, c1, puny, Tocnfrz, rhos, rsnw_fall
use icepack_parameters, only: snwredist, snwgrain
use icepack_warnings, only: warnstr, icepack_warnings_add
use icepack_warnings, only: icepack_warnings_setabort, icepack_warnings_aborted

Expand Down Expand Up @@ -105,7 +106,7 @@ module icepack_tracers
tr_pond = .false., & ! if .true., use melt pond tracer
tr_pond_lvl = .false., & ! if .true., use level-ice pond tracer
tr_pond_topo = .false., & ! if .true., use explicit topography-based ponds
tr_snow = .false., & ! if .true., use snow metamorphosis tracers
tr_snow = .false., & ! if .true., use snow redistribution or metamorphosis tracers
tr_iso = .false., & ! if .true., use isotope tracers
tr_aero = .false., & ! if .true., use aerosol tracers
tr_brine = .false., & ! if .true., brine height differs from ice thickness
Expand Down Expand Up @@ -219,7 +220,7 @@ subroutine icepack_init_tracer_flags(&
tr_pond_in , & ! if .true., use melt pond tracer
tr_pond_lvl_in , & ! if .true., use level-ice pond tracer
tr_pond_topo_in , & ! if .true., use explicit topography-based ponds
tr_snow_in , & ! if .true., use snow metamorphosis tracers
tr_snow_in , & ! if .true., use snow redistribution or metamorphosis tracers
tr_fsd_in , & ! if .true., use floe size distribution tracers
tr_iso_in , & ! if .true., use isotope tracers
tr_aero_in , & ! if .true., use aerosol tracers
Expand Down Expand Up @@ -286,7 +287,7 @@ subroutine icepack_query_tracer_flags(&
tr_pond_out , & ! if .true., use melt pond tracer
tr_pond_lvl_out , & ! if .true., use level-ice pond tracer
tr_pond_topo_out , & ! if .true., use explicit topography-based ponds
tr_snow_out , & ! if .true., use snow metamorphosis tracers
tr_snow_out , & ! if .true., use snow redistribution or metamorphosis tracers
tr_fsd_out , & ! if .true., use floe size distribution
tr_iso_out , & ! if .true., use isotope tracers
tr_aero_out , & ! if .true., use aerosol tracers
Expand Down Expand Up @@ -1288,11 +1289,25 @@ subroutine icepack_compute_tracers (ntrcr, trcr_depend, &
enddo

if (vicen <= c0 .and. tr_brine) trcrn(nt_fbri) = c1
if (vsnon <= c0 .and. tr_snow) then
trcrn(nt_rsnw :nt_rsnw +nslyr-1) = rsnw_fall
trcrn(nt_smice:nt_smice+nslyr-1) = rhos
trcrn(nt_rhos :nt_rhos +nslyr-1) = rhos
endif
if (vsnon <= c0) then
!echmod not BFB
! if (trim(snwredist) == 'ITDrdg') then
if (trim(snwredist) /= 'none') then
trcrn(nt_rhos :nt_rhos +nslyr-1) = rhos
endif
if (snwgrain) then
trcrn(nt_rsnw :nt_rsnw +nslyr-1) = rsnw_fall
trcrn(nt_smice:nt_smice+nslyr-1) = rhos
endif
!echmod temporary
!BFB if (tr_snow) then
!BFB if (trim(snwredist) /= 'none' .or. snwgrain) then
!not BFB if (trim(snwredist) == 'ITDrdg' .or. (snwgrain)) then
! trcrn(nt_rhos :nt_rhos +nslyr-1) = rhos
! trcrn(nt_rsnw :nt_rsnw +nslyr-1) = rsnw_fall
! trcrn(nt_smice:nt_smice+nslyr-1) = rhos
! endif
endif ! vsnon <= 0

end subroutine icepack_compute_tracers

Expand Down
7 changes: 6 additions & 1 deletion configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,16 @@ subroutine input_data
shortwave = 'dEdd'
endif

if (tr_snow .and. trim(shortwave) /= 'dEdd') then
if (snwgrain .and. trim(shortwave) /= 'dEdd') then
write (nu_diag,*) 'WARNING: snow grain radius activated but'
write (nu_diag,*) 'WARNING: dEdd shortwave is not.'
endif

if (snwredist(1:4) /= 'none' .and. trim(shortwave) /= 'dEdd') then
write (nu_diag,*) 'WARNING: snow redistribution activated but'
write (nu_diag,*) 'WARNING: dEdd shortwave is not.'
endif

rfracmin = min(max(rfracmin,c0),c1)
rfracmax = min(max(rfracmax,c0),c1)

Expand Down
6 changes: 4 additions & 2 deletions configuration/scripts/icepack.batch.csh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ cat >> ${jobfile} << EOFB
###SBATCH --mail-user [email protected]
EOFB

else if (${ICE_MACHINE} =~ badger*) then
else if (${ICE_MACHINE} =~ chicoma*) then
cat >> ${jobfile} << EOFB
#SBATCH -J ${ICE_CASENAME}
#SBATCH -t ${ICE_RUNLENGTH}
Expand All @@ -152,7 +152,9 @@ cat >> ${jobfile} << EOFB
#SBATCH -o slurm%j.out
###SBATCH --mail-type END,FAIL
###SBATCH [email protected]
#SBATCH --qos=standby
#SBATCH --qos=debug
##SBATCH --qos=standard
##SBATCH --qos=standby
EOFB

else if (${ICE_MACHINE} =~ discover*) then
Expand Down
49 changes: 0 additions & 49 deletions configuration/scripts/machines/Macros.badger_intel

This file was deleted.

Loading
Loading