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

Move conserv_check to namelist, update test suite to improve coverage #450

Merged
merged 8 commits into from
May 27, 2020
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
36 changes: 18 additions & 18 deletions cicecore/cicedynB/analysis/ice_history_fsd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,6 @@ subroutine init_hist_fsd_2D
call abort_ice(subname//'ERROR: reading icefields_fsd_nml')
endif

if (.not. tr_fsd) then
f_afsd = 'x'
f_afsdn = 'x'
f_dafsd_newi = 'x'
f_dafsd_latg = 'x'
f_dafsd_latm = 'x'
f_dafsd_wave = 'x'
f_dafsd_weld = 'x'
f_wave_sig_ht = 'x'
f_fsdrad = 'x'
f_fsdperim = 'x'
endif
if ((.not. tr_fsd) .or. (.not. wave_spec)) then
f_aice_ww = 'x'
f_diam_ww = 'x'
f_hice_ww = 'x'
endif

call broadcast_scalar (f_afsd, master_task)
call broadcast_scalar (f_afsdn, master_task)
call broadcast_scalar (f_dafsd_newi, master_task)
Expand Down Expand Up @@ -184,6 +166,24 @@ subroutine init_hist_fsd_2D

enddo ! nstreams

else ! tr_fsd

f_afsd = 'x'
f_afsdn = 'x'
f_dafsd_newi = 'x'
f_dafsd_latg = 'x'
f_dafsd_latm = 'x'
f_dafsd_wave = 'x'
f_dafsd_weld = 'x'
f_wave_sig_ht = 'x'
f_fsdrad = 'x'
f_fsdperim = 'x'
if (.not. wave_spec) then
f_aice_ww = 'x'
f_diam_ww = 'x'
f_hice_ww = 'x'
endif

endif ! tr_fsd

end subroutine init_hist_fsd_2D
Expand Down
7 changes: 6 additions & 1 deletion cicecore/cicedynB/dynamics/ice_dyn_evp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ subroutine evp (dt)

type (block) :: &
this_block ! block information for current block

logical (kind=log_kind), save :: first_time = .true.

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

Expand Down Expand Up @@ -349,7 +351,10 @@ subroutine evp (dt)
endif
call ice_timer_start(timer_evp_2d)
if (kevp_kernel > 0) then
! if (my_task == 0) write(nu_diag,*) subname,' Entering kevp_kernel version ',kevp_kernel
if (first_time .and. my_task == 0) then
write(nu_diag,'(2a,i6)') subname,' Entering kevp_kernel version ',kevp_kernel
first_time = .false.
endif
if (trim(grid_type) == 'tripole') then
call abort_ice(trim(subname)//' &
& Kernel not tested on tripole grid. Set kevp_kernel=0')
Expand Down
52 changes: 29 additions & 23 deletions cicecore/cicedynB/dynamics/ice_transport_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ module ice_transport_driver
logical (kind=log_kind), dimension (:), allocatable, public :: &
has_dependents ! true if a tracer has dependent tracers

logical (kind=log_kind), public :: &
conserv_check ! if true, check conservation

integer (kind=int_kind), parameter :: &
integral_order = 3 ! polynomial order of quadrature integrals
! linear=1, quadratic=2, cubic=3
Expand Down Expand Up @@ -290,7 +293,6 @@ subroutine transport_remap (dt)
! variables related to optional bug checks

logical (kind=log_kind), parameter :: &
l_conservation_check = .false. ,&! if true, check conservation
l_monotonicity_check = .false. ! if true, check monotonicity

real (kind=dbl_kind), dimension(0:ncat) :: &
Expand All @@ -310,6 +312,8 @@ subroutine transport_remap (dt)
real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: &
work1

character(len=char_len_long) :: fieldid

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

call ice_timer_start(timer_advect) ! advection
Expand Down Expand Up @@ -398,7 +402,7 @@ subroutine transport_remap (dt)
!---! Optional conservation and monotonicity checks.
!---!-------------------------------------------------------------------

if (l_conservation_check) then
if (conserv_check) then

!-------------------------------------------------------------------
! Compute initial values of globally conserved quantities.
Expand Down Expand Up @@ -436,7 +440,7 @@ subroutine transport_remap (dt)
enddo ! nt
enddo ! n

endif ! l_conservation_check
endif ! conserv_check

if (l_monotonicity_check) then

Expand Down Expand Up @@ -565,7 +569,7 @@ subroutine transport_remap (dt)
! Check global conservation of area and area*tracers. (Optional)
!-------------------------------------------------------------------

if (l_conservation_check) then
if (conserv_check) then

do n = 0, ncat
asum_final(n) = global_sum(aim(:,:,n,:), distrb_info, &
Expand Down Expand Up @@ -600,7 +604,8 @@ subroutine transport_remap (dt)
enddo ! n

if (my_task == master_task) then
call global_conservation (l_stop, &
fieldid = subname//':000'
call global_conservation (l_stop, fieldid, &
asum_init(0), asum_final(0))

if (l_stop) then
Expand All @@ -610,9 +615,10 @@ subroutine transport_remap (dt)
call abort_ice(subname//'ERROR: conservation error1')
endif

do n = 1, ncat
do n = 1, ncat
write(fieldid,'(a,i3.3)') subname,n
call global_conservation &
(l_stop, &
(l_stop, fieldid, &
asum_init(n), asum_final(n), &
atsum_init(:,n), atsum_final(:,n))

Expand All @@ -626,7 +632,7 @@ subroutine transport_remap (dt)

endif ! my_task = master_task

endif ! l_conservation_check
endif ! conserv_check

!-------------------------------------------------------------------
! Check tracer monotonicity. (Optional)
Expand Down Expand Up @@ -1077,10 +1083,13 @@ end subroutine tracers_to_state
!
! author William H. Lipscomb, LANL

subroutine global_conservation (l_stop, &
subroutine global_conservation (l_stop, fieldid, &
asum_init, asum_final, &
atsum_init, atsum_final)

character(len=*), intent(in) :: &
fieldid ! field information string

real (kind=dbl_kind), intent(in) :: &
asum_init ,&! initial global ice area
asum_final ! final global ice area
Expand Down Expand Up @@ -1113,11 +1122,11 @@ subroutine global_conservation (l_stop, &
if (abs(diff/asum_init) > puny) then
l_stop = .true.
write (nu_diag,*)
write (nu_diag,*) 'Ice area conserv error'
write (nu_diag,*) 'Initial global area =', asum_init
write (nu_diag,*) 'Final global area =', asum_final
write (nu_diag,*) 'Fractional error =', abs(diff)/asum_init
write (nu_diag,*) 'asum_final-asum_init =', diff
write (nu_diag,*) subname,'Ice area conserv error ', trim(fieldid)
write (nu_diag,*) subname,' Initial global area =', asum_init
write (nu_diag,*) subname,' Final global area =', asum_final
write (nu_diag,*) subname,' Fractional error =', abs(diff)/asum_init
write (nu_diag,*) subname,' asum_final-asum_init =', diff
endif
endif

Expand All @@ -1128,15 +1137,12 @@ subroutine global_conservation (l_stop, &
if (abs(diff/atsum_init(nt)) > puny) then
l_stop = .true.
write (nu_diag,*)
write (nu_diag,*) 'area*tracer conserv error'
write (nu_diag,*) 'tracer index =', nt
write (nu_diag,*) 'Initial global area*tracer =', &
atsum_init(nt)
write (nu_diag,*) 'Final global area*tracer =', &
atsum_final(nt)
write (nu_diag,*) 'Fractional error =', &
abs(diff)/atsum_init(nt)
write (nu_diag,*) 'atsum_final-atsum_init =', diff
write (nu_diag,*) subname,'Ice area*tracer conserv error ', trim(fieldid),nt
write (nu_diag,*) subname,' Tracer index =', nt
write (nu_diag,*) subname,' Initial global area*tracer =', atsum_init(nt)
write (nu_diag,*) subname,' Final global area*tracer =', atsum_final(nt)
write (nu_diag,*) subname,' Fractional error =', abs(diff)/atsum_init(nt)
write (nu_diag,*) subname,' atsum_final-atsum_init =', diff
endif
endif
enddo
Expand Down
8 changes: 6 additions & 2 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ subroutine input_data
basalstress, k1, k2, alphab, threshold_hw, &
Ktens, e_ratio, coriolis, &
kridge, ktransport, brlx, arlx
use ice_transport_driver, only: advection
use ice_transport_driver, only: advection, conserv_check
use ice_restoring, only: restore_ice
#ifdef CESMCOUPLED
use shr_file_mod, only: shr_file_setIO
Expand Down Expand Up @@ -154,6 +154,7 @@ subroutine input_data
print_global, print_points, latpnt, lonpnt, &
dbug, histfreq, histfreq_n, hist_avg, &
history_dir, history_file, history_precision, cpl_bgc, &
conserv_check, &
write_ic, incond_dir, incond_file, version_name

namelist /grid_nml/ &
Expand Down Expand Up @@ -309,6 +310,7 @@ subroutine input_data
Ktens = 0.0_dbl_kind ! T=Ktens*P (tensile strength: see Konig and Holland, 2010)
e_ratio = 2.0_dbl_kind ! EVP ellipse aspect ratio
advection = 'remap' ! incremental remapping transport scheme
conserv_check = .false.! tracer conservation check
shortwave = 'ccsm3' ! 'ccsm3' or 'dEdd' (delta-Eddington)
albedo_type = 'ccsm3' ! 'ccsm3' or 'constant'
ktherm = 1 ! -1 = OFF, 0 = 0-layer, 1 = BL99, 2 = mushy thermo
Expand Down Expand Up @@ -591,6 +593,7 @@ subroutine input_data
call broadcast_scalar(Ktens, master_task)
call broadcast_scalar(e_ratio, master_task)
call broadcast_scalar(advection, master_task)
call broadcast_scalar(conserv_check, master_task)
call broadcast_scalar(shortwave, master_task)
call broadcast_scalar(albedo_type, master_task)
call broadcast_scalar(ktherm, master_task)
Expand Down Expand Up @@ -1098,6 +1101,7 @@ subroutine input_data
write(nu_diag,1030) ' shortwave = ', &
trim(shortwave)
write(nu_diag,1000) ' ksno = ', ksno
write(nu_diag,1010) ' conserv_check = ', conserv_check
if (cpl_bgc) then
write(nu_diag,1000) ' BGC coupling is switched ON'
else
Expand Down Expand Up @@ -1311,7 +1315,7 @@ subroutine input_data
ktherm_in=ktherm, calc_Tsfc_in=calc_Tsfc, conduct_in=conduct, &
a_rapid_mode_in=a_rapid_mode, Rac_rapid_mode_in=Rac_rapid_mode, &
aspect_rapid_mode_in=aspect_rapid_mode, dSdt_slow_mode_in=dSdt_slow_mode, &
phi_c_slow_mode_in=phi_c_slow_mode, phi_i_mushy_in=phi_i_mushy, &
phi_c_slow_mode_in=phi_c_slow_mode, phi_i_mushy_in=phi_i_mushy, conserv_check_in=conserv_check, &
wave_spec_type_in = wave_spec_type, &
wave_spec_in=wave_spec, nfreq_in=nfreq, &
tfrz_option_in=tfrz_option, kalg_in=kalg, fbot_xfer_type_in=fbot_xfer_type)
Expand Down
10 changes: 6 additions & 4 deletions cicecore/cicedynB/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ subroutine init_domain_distribution(KMTG,ULATG)
file=__FILE__, line=__LINE__)

if (trim(ns_boundary_type) == 'closed') then
call abort_ice(subname//'ERROR: ns_boundary_type = closed not supported')
allocate(nocn(nblocks_tot))
nocn = 0
do n=1,nblocks_tot
Expand Down Expand Up @@ -373,13 +374,14 @@ subroutine init_domain_distribution(KMTG,ULATG)
enddo
endif
if (nocn(n) > 0) then
print*, 'ice: Not enough land cells along ns edge'
call abort_ice(subname//'ERROR: Not enough land cells along ns edge')
write(nu_diag,*) subname,'ns closed, Not enough land cells along ns edge'
call abort_ice(subname//'ERROR: Not enough land cells along ns edge for ns closed')
endif
enddo
deallocate(nocn)
endif
if (trim(ew_boundary_type) == 'closed') then
call abort_ice(subname//'ERROR: ew_boundary_type = closed not supported')
allocate(nocn(nblocks_tot))
nocn = 0
do n=1,nblocks_tot
Expand Down Expand Up @@ -411,8 +413,8 @@ subroutine init_domain_distribution(KMTG,ULATG)
enddo
endif
if (nocn(n) > 0) then
print*, 'ice: Not enough land cells along ew edge'
call abort_ice(subname//'ERROR: Not enough land cells along ew edge')
write(nu_diag,*) subname,'ew closed, Not enough land cells along ew edge'
call abort_ice(subname//'ERROR: Not enough land cells along ew edge for ew closed')
endif
enddo
deallocate(nocn)
Expand Down
1 change: 0 additions & 1 deletion cicecore/drivers/mct/cesm1/ice_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ subroutine ice_import( x2i )
logical (kind=log_kind) :: tr_aero, tr_iage, tr_FY, tr_pond
logical (kind=log_kind) :: tr_lvl, tr_zaero, tr_bgc_Nit
real (kind=dbl_kind) :: tffresh
logical (kind=log_kind) :: first_call = .true.
character(len=*), parameter :: subname = '(ice_import)'
!-----------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions configuration/scripts/cice.run.setup.csh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ cd \${ICE_RUNDIR}
setenv OMP_NUM_THREADS ${nthrds}
cp -f \${ICE_CASEDIR}/ice_in \${ICE_RUNDIR}
cp -f \${ICE_CASEDIR}/env.${ICE_MACHCOMP} \${ICE_RUNDIR}
cp -f \${ICE_CASEDIR}/cice.settings \${ICE_RUNDIR}
apcraig marked this conversation as resolved.
Show resolved Hide resolved
set diagtype = \`grep -i diag_type \${ICE_CASEDIR}/ice_in | grep -i stdout | wc -l\`
set diagfile = \`grep -i diag_file \${ICE_CASEDIR}/ice_in | sed -e "s/.* = '\(.*\)'/\1/"\`
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/ice_in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
diag_file = 'ice_diag.d'
print_global = .true.
print_points = .true.
conserv_check = .false.
latpnt(1) = 90.
lonpnt(1) = 0.
latpnt(2) = -65.
Expand Down
7 changes: 6 additions & 1 deletion configuration/scripts/options/set_nml.alt03
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
ncat = 6
kcatbound = 2
ice_ic = 'default'
restart = .false.
distribution_type = 'sectcart'
conserv_check = .true.
tr_iage = .false.
tr_FY = .false.
tr_lvl = .false.
tr_pond_cesm = .false.
tr_pond_topo = .true.
tr_pond_lvl = .false.
tr_aero = .false.
tr_aero = .true.
calc_Tsfc = .false.
kdyn = 2
ktherm = 1
tfrz_option = 'linear_salt'
revised_evp = .false.
Ktens = 0.
e_ratio = 2.
Expand Down
3 changes: 2 additions & 1 deletion configuration/scripts/options/set_nml.alt04
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ tr_lvl = .true.
tr_pond_cesm = .false.
tr_pond_topo = .false.
tr_pond_lvl = .true.
tr_aero = .false.
tr_aero = .true.
kitd = 0
ktherm = 1
conduct = 'MU71'
kdyn = 1
kevp_kernel = 102
fbot_xfer_type = 'Cdn_ocn'
shortwave = 'dEdd'
formdrag = .true.
Expand Down
2 changes: 1 addition & 1 deletion doc/source/cice_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ either Celsius or Kelvin units).
"coldsnow", "value for constant albedo parameterization", "0.81"
"conduct", ":math:`\bullet` conductivity parameterization", ""
"congel", "basal ice growth", "m"
"conserv_check", "if true, check conservation", ""
"cosw", "cosine of the turning angle in water", "1."
"coszen", "cosine of the zenith angle", ""
"Cp", "proportionality constant for potential energy", "kg/m\ :math:`^2`/s\ :math:`^2`"
Expand Down Expand Up @@ -342,7 +343,6 @@ either Celsius or Kelvin units).
"ktherm", ":math:`\bullet` thermodynamic formulation (0 = zero-layer, 1 = :cite:`Bitz99`, 2 = mushy)", ""
"**L**", "", ""
"l_brine", "flag for brine pocket effects", ""
"l_conservation_check", "if true, check conservation when ridging", ""
"l_fixed_area", "flag for prescribing remapping fluxes", ""
"l_mpond_fresh", ":math:`\bullet` if true, retain (topo) pond water until ponds drain", ""
"latpnt", ":math:`\bullet` desired latitude of diagnostic points", "degrees N"
Expand Down
3 changes: 2 additions & 1 deletion doc/source/user_guide/ug_case_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ to support the CICE model.
"ICE_QUEUE", "string", "batch queue name", "set by cice.setup or by default"
"ICE_THREADED", "true, false", "force threading in compile, will always compile threaded if ICE_NTHRDS :math:`> 1`", "false"
"ICE_BLDDEBUG", "true, false", "turn on compile debug flags", "false"

"ICE_CODECOV", "true,false", "turn on code coverage flags", "false"


.. _tabnamelist:
Expand Down Expand Up @@ -124,6 +124,7 @@ Table of namelist options
"\*","``diag_type``", "``stdout``", "write diagnostic output to stdout", ""
"","", "``file``", "write diagnostic output to file", ""
"","``diag_file``", "filename", "diagnostic output file (script may reset)", ""
"","``conserv_check``", "true/false", "check conservation", "``.false.``"
"","``print_global``", "true/false", "print diagnostic data, global sums", "``.false.``"
"","``print_points``", "true/false", "print diagnostic data for two grid points", "``.false.``"
"","``latpnt``", "real", "latitude of (2) diagnostic points", ""
Expand Down
Loading