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

Fix history and restart frequency, new features to scripts #610

Merged
merged 11 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
69 changes: 34 additions & 35 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module ice_init
ice_ic ! method of ice cover initialization
! 'default' => latitude and sst dependent
! 'none' => no ice
! note: restart = .true. overwrites
! filename => read file

public :: input_data, init_state, set_state_var

Expand Down Expand Up @@ -453,7 +453,7 @@ subroutine input_data
#ifndef CESMCOUPLED
runid = 'unknown' ! run ID used in CESM and for machine 'bering'
runtype = 'initial' ! run type: 'initial', 'continue'
restart = .false. ! if true, read restart files for initialization
restart = .false. ! if true, read ice state from restart file
use_restart_time = .true. ! if true, use time info written in file
#endif

Expand Down Expand Up @@ -845,42 +845,40 @@ subroutine input_data
write(nu_diag,*) ' '
endif

if (trim(runtype) == 'continue' .and. .not.restart) then
if (my_task == master_task) &
write(nu_diag,*) subname//' WARNING: runtype=continue, setting restart=.true.'
if (trim(runtype) == 'continue') then
if (my_task == master_task) then
write(nu_diag,*) subname//' NOTE: runtype=continue, setting restart=.true.'
if (.not. use_restart_time) &
write(nu_diag,*) subname//' NOTE: runtype=continue, setting use_restart_time=.true.'
endif
restart = .true.
endif

if (trim(runtype) /= 'continue' .and. restart .and. &
(ice_ic == 'none' .or. ice_ic == 'default')) then
if (my_task == master_task) &
write(nu_diag,*) subname//' WARNING: runtype ne continue and ice_ic=none|default, setting restart=.false.'
restart = .false.
endif

if (trim(runtype) /= 'continue' .and. (ice_ic == 'none' .or. ice_ic == 'default')) then
if (my_task == master_task) &
write(nu_diag,*) subname//' WARNING: ice_ic = none or default, setting restart flags to .false.'
restart = .false.
restart_iso = .false.
restart_aero = .false.
restart_fsd = .false.
restart_age = .false.
restart_fy = .false.
restart_lvl = .false.
restart_pond_cesm = .false.
restart_pond_lvl = .false.
restart_pond_topo = .false.
use_restart_time = .true.
elseif (trim(runtype) == 'initial') then
if (ice_ic == 'none' .or. ice_ic == 'default') then
if (my_task == master_task) then
write(nu_diag,*) subname//' NOTE: ice_ic = none or default, setting restart flags to .false.'
if (.not. use_restart_time) &
write(nu_diag,*) subname//' NOTE: ice_ic = none or default, setting use_restart_time=.false.'
endif
use_restart_time = .false.
restart = .false.
restart_iso = .false.
restart_aero = .false.
restart_fsd = .false.
restart_age = .false.
restart_fy = .false.
restart_lvl = .false.
restart_pond_cesm = .false.
restart_pond_lvl = .false.
restart_pond_topo = .false.
! tcraig, OK to leave as true, needed for boxrestore case
! restart_ext = .false.
endif

if (trim(runtype) == 'initial' .and. .not.(restart) .and. &
ice_ic /= 'none' .and. ice_ic /= 'default') then
! restart_ext = .false.
else
restart = .true.
endif
else
if (my_task == master_task) then
write(nu_diag,*) subname//' ERROR: runtype, restart, ice_ic are inconsistent:'
write(nu_diag,*) subname//' ERROR: runtype=',trim(runtype), ' restart=',restart, ' ice_ic=',trim(ice_ic)
write(nu_diag,*) subname//' ERROR: Please review user guide'
write(nu_diag,*) subname//' ERROR: runtype unknown = ',trim(runtype)
endif
abort_list = trim(abort_list)//":1"
endif
Expand Down Expand Up @@ -1698,6 +1696,7 @@ subroutine input_data
write(nu_diag,1021) ' dumpfreq_n = ', dumpfreq_n
write(nu_diag,1031) ' dumpfreq_base = ', trim(dumpfreq_base)
write(nu_diag,1011) ' dump_last = ', dump_last
write(nu_diag,1031) ' NOTE: restart namelist is ignored, now set internally'
write(nu_diag,1011) ' restart = ', restart
write(nu_diag,1031) ' restart_dir = ', trim(restart_dir)
write(nu_diag,1011) ' restart_ext = ', restart_ext
Expand Down
90 changes: 43 additions & 47 deletions cicecore/shared/ice_calendar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module ice_calendar

! private functions
private :: set_calendar ! sets model calendar type (noleap, etc)
private :: compute_relative_elapsed ! compute relative elapsed years, months, days, hours

! PUBLIC

Expand Down Expand Up @@ -136,7 +137,7 @@ module ice_calendar
hour ! hour of the day

integer (kind=int_kind), parameter :: &
myear_max = 200000 ! maximum year, limited by integer overflow in elapsed_horus
myear_max = 200000 ! maximum year, limited by integer overflow in elapsed_hours

! 360-day year data
integer (kind=int_kind) :: &
Expand Down Expand Up @@ -352,10 +353,10 @@ subroutine calendar()
integer (kind=int_kind) :: &
ns , & ! loop index
yearp,monthp,dayp,hourp , & ! previous year, month, day, hour
elapsed_years , & ! since beginning of time
elapsed_months , & ! since beginning of time
elapsed_days , & ! since beginning of time
elapsed_hours ! since beginning of time
elapsed_years , & ! relative elapsed years
elapsed_months , & ! relative elapsed months
elapsed_days , & ! relative elapsed days
elapsed_hours ! relative elapsed hours
character(len=*),parameter :: subname='(calendar)'

yearp=myear
Expand Down Expand Up @@ -396,27 +397,7 @@ subroutine calendar()

! History writing flags

if (histfreq_base == 'zero') then
elapsed_years = myear
elapsed_months = elapsed_years * months_per_year + mmonth - 1
elapsed_days = compute_days_between(0,1,1,myear,mmonth,mday)
elapsed_hours = elapsed_days * hours_per_day + hour
elseif (histfreq_base == 'init') then
elapsed_years = myear - year_init
elapsed_months = elapsed_years * months_per_year + (mmonth - month_init)
elapsed_days = compute_days_between(year_init,month_init,day_init,myear,mmonth,mday)
elapsed_hours = elapsed_days * hours_per_day + hour
else
write(nu_diag,*) trim(subname),' ERROR histfreq_base not recognized, ',trim(histfreq_base)
call abort_ice(subname//'ERROR: histfreq_base value invalid')
endif

! if (my_task == master_task) then
! write(nu_diag,*) subname,' helap_y',elapsed_years
! write(nu_diag,*) subname,' helap_m',elapsed_months
! write(nu_diag,*) subname,' helap_d',elapsed_days
! write(nu_diag,*) subname,' helap_h',elapsed_hours
! endif
call compute_relative_elapsed(histfreq_base, elapsed_years, elapsed_months, elapsed_days, elapsed_hours)

do ns = 1, nstreams

Expand Down Expand Up @@ -452,27 +433,7 @@ subroutine calendar()

! Restart writing flag

if (dumpfreq_base == 'zero') then
elapsed_years = myear
elapsed_months = elapsed_years * months_per_year + mmonth - 1
elapsed_days = compute_days_between(0,1,1,myear,mmonth,mday)
elapsed_hours = elapsed_days * hours_per_day + hour
elseif (dumpfreq_base == 'init') then
elapsed_years = myear - year_init
elapsed_months = elapsed_years * months_per_year + (mmonth - month_init)
elapsed_days = compute_days_between(year_init,month_init,day_init,myear,mmonth,mday)
elapsed_hours = elapsed_days * hours_per_day + hour
else
write(nu_diag,*) trim(subname),' ERROR dumpfreq_base not recognized, ',trim(dumpfreq_base)
call abort_ice(subname//'ERROR: dumpfreq_base value invalid')
endif

! if (my_task == master_task) then
! write(nu_diag,*) subname,' delap_y',elapsed_years
! write(nu_diag,*) subname,' delap_m',elapsed_months
! write(nu_diag,*) subname,' delap_d',elapsed_days
! write(nu_diag,*) subname,' delap_h',elapsed_hours
! endif
call compute_relative_elapsed(dumpfreq_base, elapsed_years, elapsed_months, elapsed_days, elapsed_hours)

select case (dumpfreq)
case ("y", "Y")
Expand Down Expand Up @@ -987,6 +948,41 @@ subroutine calendar_time2date(atimesecs,ayear,amon,aday,asec,year_ref,mon_ref,da

end subroutine calendar_time2date

!=======================================================================
! Compute relative elapsed years, months, days, hours from base time

subroutine compute_relative_elapsed(base, ey, em, ed, eh)

character(len=*), intent(in) :: base
integer(kind=int_kind), intent(out) :: &
ey, em, ed, eh ! relative elapsed year, month, day, hour

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

if (base == 'zero') then
ey = myear
em = ey * months_per_year + mmonth - 1
ed = compute_days_between(0,1,1,myear,mmonth,mday)
eh = ed * hours_per_day + hour
elseif (base == 'init') then
ey = myear - year_init
em = ey * months_per_year + (mmonth - month_init)
ed = compute_days_between(year_init,month_init,day_init,myear,mmonth,mday)
eh = ed * hours_per_day + hour
else
write(nu_diag,*) trim(subname),' ERROR base not recognized, ',trim(base)
call abort_ice(subname//'ERROR: base value invalid')
endif

! if (my_task == master_task) then
! write(nu_diag,*) subname,' ey',ey
! write(nu_diag,*) subname,' em',em
! write(nu_diag,*) subname,' ed',ed
! write(nu_diag,*) subname,' eh',eh
! endif

end subroutine compute_relative_elapsed

!=======================================================================

end module ice_calendar
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/ice_in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ndtd = 1
runtype = 'initial'
ice_ic = './restart/iced_gx3_v5.nc'
restart = .true.
restart_ext = .false.
use_restart_time = .true.
restart_format = 'default'
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.alt01
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
nilyr = 1
use_leap_years = .false.
ice_ic = 'default'
restart = .false.
distribution_type = 'roundrobin'
distribution_wght = 'block'
tr_iage = .false.
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.alt02
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ncat = 1
kcatbound = -1
ice_ic = 'default'
restart = .false.
distribution_type = 'sectrobin'
tr_iage = .true.
tr_FY = .true.
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.alt03
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ncat = 6
kcatbound = 2
ice_ic = 'default'
restart = .false.
distribution_type = 'sectcart'
conserv_check = .true.
tr_iage = .false.
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.alt04
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ice_ic = 'default'
restart = .false.
bfbflag = 'reprosum'
distribution_type = 'rake'
processor_shape = 'slenderX2'
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.alt05
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ice_ic = 'default'
restart = .false.
tr_iage = .false.
tr_FY = .false.
tr_lvl = .false.
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/options/set_nml.alt06
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ ncat = 7
kcatbound = 3
nslyr = 3
ice_ic = 'default'
restart = .false.

1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.box2001
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ days_per_year = 360
use_leap_years = .false.
npt = 240
ice_ic = 'default'
restart = .false.
restart_ext = .true.
histfreq = 'd','x','x','x','x'
grid_type = 'rectangular'
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.boxadv
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
nilyr = 1
ice_ic = 'default'
restart = .false.
restart_ext = .false.
kcatbound = 2
ew_boundary_type = 'cyclic'
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.boxnodyn
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
nilyr = 1
ice_ic = 'default'
restart = .false.
days_per_year = 360
use_leap_years = .false.
npt = 72
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.boxrestore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
nilyr = 1
ice_ic = 'default'
restart = .false.
restart_ext = .true.
use_leap_years = .false.
ndtd = 2
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.boxslotcyl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
nilyr = 1
ice_ic = 'default'
restart = .false.
restart_ext = .false.
dt = 3600.0
npt = 288
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/options/set_nml.gx1prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use_leap_years = .true.
npt_unit = 'y'
npt = 1
dumpfreq = 'm'
dumpfreq_base = 'zero'
fyear_init = 2005
ycycle = 5
ocn_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/gx1/CESM/MONTHLY/'
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.icdefault
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ice_ic = 'default'
restart = .false.
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.icnone
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ice_ic = 'none'
restart = .false.
1 change: 0 additions & 1 deletion configuration/scripts/options/set_nml.zsal
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ tfrz_option = 'linear_salt'
tr_brine = .true.
solve_zsal = .true.
ice_ic = 'default'
restart = .false.

2 changes: 0 additions & 2 deletions configuration/scripts/options/test_nml.restart2
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ npt_unit = 'd'
dumpfreq = 'd'
dumpfreq_n = 5
runtype = 'continue'
restart = .true.
use_restart_time = .true.
7 changes: 3 additions & 4 deletions doc/source/cice_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ Index of primary variables and parameters
==========================================

This index defines many of the symbols used frequently in the CICE model
code. Values appearing in this list are fixed or recommended; most
namelist parameters are indicated ( :math:`E_\circ`) with their default
values. For other namelist options, see Section :ref:`tabnamelist`. All
code. Namelist variables are partly included here but also documented
elsewhere, see Section :ref:`tabnamelist`. All
quantities in the code are expressed in MKS units (temperatures may take
either Celsius or Kelvin units).

Expand Down Expand Up @@ -536,7 +535,7 @@ either Celsius or Kelvin units).
"real_kind", "definition of single precision real", "selected_real_kind(6)"
"refindx", "refractive index of sea ice", "1.310"
"revp", "real(revised_evp)", ""
"restart", "if true, initialize using restart file instead of defaults", "T"
"restart", "if true, initialize ice state from file", "T"
"restart_age", "if true, read age restart file", ""
"restart_bgc", "if true, read bgc restart file", ""
"restart_dir", "path to restart/dump files", ""
Expand Down
Loading