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

Deprecate CESM ponds (tr_pond_cesm) #733

Merged
merged 3 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 14 additions & 1 deletion cicecore/cicedynB/analysis/ice_history_pond.F90
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,13 @@ subroutine accum_hist_pond (iblk)

integer (kind=int_kind) :: &
nt_apnd, nt_hpnd, nt_alvl, nt_ipnd

#ifdef UNDEPRECATE_CESMPONDS
logical (kind=log_kind) :: &
tr_pond_cesm, tr_pond_lvl, tr_pond_topo
#else
logical (kind=log_kind) :: &
tr_pond_lvl, tr_pond_topo
#endif

real (kind=dbl_kind) :: &
puny
Expand All @@ -285,15 +289,21 @@ subroutine accum_hist_pond (iblk)
!---------------------------------------------------------------

call icepack_query_parameters(puny_out=puny)
#ifdef UNDEPRECATE_CESMPONDS
call icepack_query_tracer_flags(tr_pond_cesm_out=tr_pond_cesm, &
tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo)
#else
call icepack_query_tracer_flags(tr_pond_lvl_out=tr_pond_lvl, &
tr_pond_topo_out=tr_pond_topo)
#endif
call icepack_query_tracer_indices(nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, &
nt_alvl_out=nt_alvl, nt_ipnd_out=nt_ipnd)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

if (allocated(a2D)) then
#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) then
if (f_apond(1:1)/= 'x') &
call accum_hist_field(n_apond, iblk, &
Expand All @@ -311,6 +321,9 @@ subroutine accum_hist_pond (iblk)
* trcr(:,:,nt_hpnd,iblk), a2D)

elseif (tr_pond_lvl) then
#else
if (tr_pond_lvl) then
#endif
if (f_apond(1:1)/= 'x') &
call accum_hist_field(n_apond, iblk, &
trcr(:,:,nt_alvl,iblk) * trcr(:,:,nt_apnd,iblk), a2D)
Expand Down
15 changes: 15 additions & 0 deletions cicecore/cicedynB/dynamics/ice_transport_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1533,17 +1533,27 @@ subroutine state_to_work (nx_block, ny_block, &
integer (kind=int_kind) :: &
nt_alvl, nt_apnd, nt_fbri

#ifdef UNDEPRECATE_CESMPONDS
logical (kind=log_kind) :: &
tr_pond_cesm, tr_pond_lvl, tr_pond_topo
#else
logical (kind=log_kind) :: &
tr_pond_lvl, tr_pond_topo
#endif

integer (kind=int_kind) :: &
i, j, n, it, & ! counting indices
narrays ! counter for number of state variable arrays

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

#ifdef UNDEPRECATE_CESMPONDS
call icepack_query_tracer_flags(tr_pond_cesm_out=tr_pond_cesm, &
tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo)
#else
call icepack_query_tracer_flags(tr_pond_lvl_out=tr_pond_lvl, &
tr_pond_topo_out=tr_pond_topo)
#endif
call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_apnd_out=nt_apnd, &
nt_fbri_out=nt_fbri)
call icepack_warnings_flush(nu_diag)
Expand Down Expand Up @@ -1602,8 +1612,13 @@ subroutine state_to_work (nx_block, ny_block, &
* trcrn(i,j,it ,n)
enddo
enddo
#ifdef UNDEPRECATE_CESMPONDS
elseif (trcr_depend(it) == 2+nt_apnd .and. &
tr_pond_cesm .or. tr_pond_topo) then
#else
Copy link
Contributor

Choose a reason for hiding this comment

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

This is interesting. I wonder whether the .and. or the .or. took precedence in the logic for this elseif statement.
i.e.
(trcr_depend(it)==2+nt_apnd .and. tr_pond_cesm) .or. tr_pond_topo
or
trcr_depend(it)==2+nt_apnd .and. (tr_pond_cesm .or. tr_pond_topo)
?
The latter is correct, but what was the code actually doing?

Copy link
Member

Choose a reason for hiding this comment

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

According to https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/expressions-and-assignment-statements/expressions/summary-of-operator-precedence.html the .and. would have precedence on the .or. so the code would do the first thing you listed:

(trcr_depend(it)==2+nt_apnd .and. tr_pond_cesm) .or. tr_pond_topo

i.e. the wrong thing if I understand correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. This line is in the state_to_work routine, which is only used for upwind advection. Tracers may not work properly with upwind advection -- see #267 and #542. This faulty logic could be part of the reason why, but it probably doesn't fix the entire issue, which is that many tracers are not implemented at all for upwind.

elseif (trcr_depend(it) == 2+nt_apnd .and. &
tr_pond_topo) then
#endif
do j = 1, ny_block
do i = 1, nx_block
works(i,j,narrays+it) = aicen(i,j ,n) &
Expand Down
60 changes: 60 additions & 0 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ subroutine input_data
npt, dt, ndtd, days_per_year, use_leap_years, &
write_ic, dump_last, npt_unit
use ice_arrays_column, only: oceanmixed_ice
#ifdef UNDEPRECATE_CESMPONDS
use ice_restart_column, only: restart_age, restart_FY, restart_lvl, &
restart_pond_cesm, restart_pond_lvl, restart_pond_topo, restart_aero, &
restart_fsd, restart_iso, restart_snow
#else
use ice_restart_column, only: restart_age, restart_FY, restart_lvl, &
restart_pond_lvl, restart_pond_topo, restart_aero, &
restart_fsd, restart_iso, restart_snow
#endif
use ice_restart_shared, only: &
restart, restart_ext, restart_coszen, restart_dir, restart_file, pointer_file, &
runid, runtype, use_restart_time, restart_format, lcdf64
Expand Down Expand Up @@ -157,10 +163,18 @@ subroutine input_data

logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond
logical (kind=log_kind) :: tr_iso, tr_aero, tr_fsd, tr_snow
#ifdef UNDEPRECATE_CESMPONDS
logical (kind=log_kind) :: tr_pond_cesm, tr_pond_lvl, tr_pond_topo
#else
logical (kind=log_kind) :: tr_pond_lvl, tr_pond_topo
#endif
integer (kind=int_kind) :: numin, numax ! unit number limits

#ifdef UNDEPRECATE_CESMPONDS
integer (kind=int_kind) :: rpcesm, rplvl, rptopo
#else
integer (kind=int_kind) :: rplvl, rptopo
#endif
real (kind=dbl_kind) :: Cf, ksno, puny
character (len=char_len) :: abort_list
character (len=64) :: tmpstr
Expand Down Expand Up @@ -201,7 +215,9 @@ subroutine input_data
tr_iage, restart_age, &
tr_FY, restart_FY, &
tr_lvl, restart_lvl, &
#ifdef UNDEPRECATE_CESMPONDS
tr_pond_cesm, restart_pond_cesm, &
#endif
tr_pond_lvl, restart_pond_lvl, &
tr_pond_topo, restart_pond_topo, &
tr_snow, restart_snow, &
Expand Down Expand Up @@ -526,8 +542,10 @@ subroutine input_data
restart_FY = .false. ! ice age restart
tr_lvl = .false. ! level ice
restart_lvl = .false. ! level ice restart
#ifdef UNDEPRECATE_CESMPONDS
tr_pond_cesm = .false. ! CESM melt ponds
restart_pond_cesm = .false. ! melt ponds restart
#endif
tr_pond_lvl = .false. ! level-ice melt ponds
restart_pond_lvl = .false. ! melt ponds restart
tr_pond_topo = .false. ! explicit melt ponds (topographic)
Expand Down Expand Up @@ -993,8 +1011,10 @@ subroutine input_data
call broadcast_scalar(restart_FY, master_task)
call broadcast_scalar(tr_lvl, master_task)
call broadcast_scalar(restart_lvl, master_task)
#ifdef UNDEPRECATE_CESMPONDS
call broadcast_scalar(tr_pond_cesm, master_task)
call broadcast_scalar(restart_pond_cesm, master_task)
#endif
call broadcast_scalar(tr_pond_lvl, master_task)
call broadcast_scalar(restart_pond_lvl, master_task)
call broadcast_scalar(tr_pond_topo, master_task)
Expand Down Expand Up @@ -1087,7 +1107,9 @@ subroutine input_data
restart_age = .false.
restart_fy = .false.
restart_lvl = .false.
#ifdef UNDEPRECATE_CESMPONDS
restart_pond_cesm = .false.
#endif
restart_pond_lvl = .false.
restart_pond_topo = .false.
restart_snow = .false.
Expand Down Expand Up @@ -1204,17 +1226,29 @@ subroutine input_data
endif
endif

#ifdef UNDEPRECATE_CESMPONDS
rpcesm = 0
#endif
rplvl = 0
rptopo = 0
#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) rpcesm = 1
#endif
if (tr_pond_lvl ) rplvl = 1
if (tr_pond_topo) rptopo = 1

tr_pond = .false. ! explicit melt ponds
#ifdef UNDEPRECATE_CESMPONDS
if (rpcesm + rplvl + rptopo > 0) tr_pond = .true.
#else
if (rplvl + rptopo > 0) tr_pond = .true.
#endif

#ifdef UNDEPRECATE_CESMPONDS
if (rpcesm + rplvl + rptopo > 1) then
#else
if (rplvl + rptopo > 1) then
#endif
if (my_task == master_task) then
write(nu_diag,*) subname//' ERROR: Must use only one melt pond scheme'
endif
Expand Down Expand Up @@ -1438,10 +1472,12 @@ subroutine input_data
abort_list = trim(abort_list)//":16"
endif

#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) then
if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=T and frzpnd=cesm'
abort_list = trim(abort_list)//":17"
endif
#endif

if (.not. tr_lvl) then
if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=T and tr_lvl=F'
Expand Down Expand Up @@ -2043,10 +2079,14 @@ subroutine input_data
write(nu_diag,*) ' '
write(nu_diag,*) ' Melt ponds'
write(nu_diag,*) '--------------------------------'
#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) then
write(nu_diag,1010) ' tr_pond_cesm = ', tr_pond_cesm,' : CESM pond formulation'
write(nu_diag,1002) ' pndaspect = ', pndaspect,' : ratio of pond depth to area fraction'
elseif (tr_pond_lvl) then
#else
if (tr_pond_lvl) then
#endif
write(nu_diag,1010) ' tr_pond_lvl = ', tr_pond_lvl,' : level-ice pond formulation'
write(nu_diag,1002) ' pndaspect = ', pndaspect,' : ratio of pond depth to area fraction'
write(nu_diag,1000) ' dpscale = ', dpscale,' : time scale for flushing in permeable ice'
Expand Down Expand Up @@ -2159,7 +2199,9 @@ subroutine input_data
if (tr_lvl) write(nu_diag,1010) ' tr_lvl = ', tr_lvl,' : ridging related tracers'
if (tr_pond_lvl) write(nu_diag,1010) ' tr_pond_lvl = ', tr_pond_lvl,' : level-ice pond formulation'
if (tr_pond_topo) write(nu_diag,1010) ' tr_pond_topo = ', tr_pond_topo,' : topo pond formulation'
#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) write(nu_diag,1010) ' tr_pond_cesm = ', tr_pond_cesm,' : CESM pond formulation'
#endif
if (tr_snow) write(nu_diag,1010) ' tr_snow = ', tr_snow,' : advanced snow physics'
if (tr_iage) write(nu_diag,1010) ' tr_iage = ', tr_iage,' : chronological ice age'
if (tr_FY) write(nu_diag,1010) ' tr_FY = ', tr_FY,' : first-year ice area'
Expand Down Expand Up @@ -2284,7 +2326,9 @@ subroutine input_data
write(nu_diag,1011) ' restart_age = ', restart_age
write(nu_diag,1011) ' restart_FY = ', restart_FY
write(nu_diag,1011) ' restart_lvl = ', restart_lvl
#ifdef UNDEPRECATE_CESMPONDS
write(nu_diag,1011) ' restart_pond_cesm= ', restart_pond_cesm
#endif
write(nu_diag,1011) ' restart_pond_lvl = ', restart_pond_lvl
write(nu_diag,1011) ' restart_pond_topo= ', restart_pond_topo
write(nu_diag,1011) ' restart_snow = ', restart_snow
Expand Down Expand Up @@ -2383,7 +2427,11 @@ subroutine input_data
call icepack_init_tracer_flags(tr_iage_in=tr_iage, tr_FY_in=tr_FY, &
tr_lvl_in=tr_lvl, tr_iso_in=tr_iso, tr_aero_in=tr_aero, &
tr_fsd_in=tr_fsd, tr_snow_in=tr_snow, tr_pond_in=tr_pond, &
#ifdef UNDEPRECATE_CESMPONDS
tr_pond_cesm_in=tr_pond_cesm, tr_pond_lvl_in=tr_pond_lvl, tr_pond_topo_in=tr_pond_topo)
#else
tr_pond_lvl_in=tr_pond_lvl, tr_pond_topo_in=tr_pond_topo)
#endif
call icepack_init_tracer_sizes(ncat_in=ncat, nilyr_in=nilyr, nslyr_in=nslyr, nblyr_in=nblyr, &
nfsd_in=nfsd, n_algae_in=n_algae, n_iso_in=n_iso, n_aero_in=n_aero, &
n_DOC_in=n_DOC, n_DON_in=n_DON, &
Expand Down Expand Up @@ -2445,7 +2493,11 @@ subroutine init_state

integer (kind=int_kind) :: ntrcr
logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero
#ifdef UNDEPRECATE_CESMPONDS
logical (kind=log_kind) :: tr_pond_cesm, tr_pond_lvl, tr_pond_topo
#else
logical (kind=log_kind) :: tr_pond_lvl, tr_pond_topo
#endif
logical (kind=log_kind) :: tr_snow, tr_fsd
integer (kind=int_kind) :: nt_Tsfc, nt_sice, nt_qice, nt_qsno, nt_iage, nt_FY
integer (kind=int_kind) :: nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd
Expand All @@ -2463,7 +2515,11 @@ subroutine init_state
call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, &
tr_lvl_out=tr_lvl, tr_iso_out=tr_iso, tr_aero_out=tr_aero, &
#ifdef UNDEPRECATE_CESMPONDS
tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo, &
#else
tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo, &
#endif
tr_snow_out=tr_snow, tr_fsd_out=tr_fsd)
call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc, nt_sice_out=nt_sice, &
nt_qice_out=nt_qice, nt_qsno_out=nt_qsno, nt_iage_out=nt_iage, nt_fy_out=nt_fy, &
Expand Down Expand Up @@ -2533,10 +2589,12 @@ subroutine init_state
if (tr_FY) trcr_depend(nt_FY) = 0 ! area-weighted first-year ice area
if (tr_lvl) trcr_depend(nt_alvl) = 0 ! level ice area
if (tr_lvl) trcr_depend(nt_vlvl) = 1 ! level ice volume
#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) then
trcr_depend(nt_apnd) = 0 ! melt pond area
trcr_depend(nt_hpnd) = 2+nt_apnd ! melt pond depth
endif
#endif
if (tr_pond_lvl) then
trcr_depend(nt_apnd) = 2+nt_alvl ! melt pond area
trcr_depend(nt_hpnd) = 2+nt_apnd ! melt pond depth
Expand Down Expand Up @@ -2598,10 +2656,12 @@ subroutine init_state
nt_strata (it,2) = 0
enddo

#ifdef UNDEPRECATE_CESMPONDS
if (tr_pond_cesm) then
n_trcr_strata(nt_hpnd) = 1 ! melt pond depth
nt_strata (nt_hpnd,1) = nt_apnd ! on melt pond area
endif
#endif
if (tr_pond_lvl) then
n_trcr_strata(nt_apnd) = 1 ! melt pond area
nt_strata (nt_apnd,1) = nt_alvl ! on level ice area
Expand Down
8 changes: 8 additions & 0 deletions cicecore/cicedynB/general/ice_step_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ subroutine step_therm1 (dt, iblk)
nt_isosno, nt_isoice, nt_rsnw, nt_smice, nt_smliq

logical (kind=log_kind) :: &
#ifdef UNDEPRECATE_CESMPONDS
tr_iage, tr_FY, tr_iso, tr_aero, tr_pond, tr_pond_cesm, &
#else
tr_iage, tr_FY, tr_iso, tr_aero, tr_pond, &
#endif
tr_pond_lvl, tr_pond_topo, calc_Tsfc, highfreq, tr_snow

real (kind=dbl_kind) :: &
Expand Down Expand Up @@ -265,7 +269,11 @@ subroutine step_therm1 (dt, iblk)
call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
call icepack_query_tracer_flags( &
tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_iso_out=tr_iso, &
#ifdef UNDEPRECATE_CESMPONDS
tr_aero_out=tr_aero, tr_pond_out=tr_pond, tr_pond_cesm_out=tr_pond_cesm, &
#else
tr_aero_out=tr_aero, tr_pond_out=tr_pond, &
#endif
tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo, &
tr_snow_out=tr_snow)
call icepack_query_tracer_indices( &
Expand Down
Loading