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

Netcdf History Capability #368

Merged
merged 7 commits into from
Aug 31, 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
11 changes: 10 additions & 1 deletion configuration/driver/icedrv_RunMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ subroutine icedrv_run
use icedrv_forcing, only: get_forcing, get_wave_spec
use icedrv_forcing_bgc, only: faero_default, fiso_default, get_forcing_bgc
use icedrv_flux, only: init_flux_atm_ocn
use icedrv_history, only: history_cdf, history_close

logical (kind=log_kind) :: skl_bgc, z_tracers, tr_aero, tr_zaero, &
wave_spec, tr_fsd, tr_iso
Expand All @@ -61,7 +62,10 @@ subroutine icedrv_run

call calendar(time) ! at the end of the timestep

if (stop_now >= 1) exit timeLoop
if (stop_now >= 1) then
if (history_cdf) call history_close()
exit timeLoop
endif

call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers,&
wave_spec_out=wave_spec)
Expand Down Expand Up @@ -97,6 +101,7 @@ subroutine ice_step
use icedrv_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags
use icedrv_flux, only: init_history_therm, init_history_bgc, &
daidtt, daidtd, dvidtt, dvidtd, dagedtt, dagedtd, init_history_dyn
use icedrv_history, only: history_cdf, history_write
use icedrv_restart, only: dumpfile, final_restart
use icedrv_restart_bgc, only: write_restart_bgc
use icedrv_step, only: prep_radiation, step_therm1, step_therm2, &
Expand Down Expand Up @@ -207,6 +212,10 @@ subroutine ice_step
if (skl_bgc .or. z_tracers) call bgc_diags
if (tr_brine) call hbrine_diags
endif

if (history_cdf) then
call history_write()
endif

if (write_restart == 1) then
call dumpfile ! core variables for restarting
Expand Down
2 changes: 2 additions & 0 deletions configuration/driver/icedrv_calendar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module icedrv_calendar
real (kind=dbl_kind), public :: &
dt , & ! thermodynamics timestep (s)
dt_dyn , & ! dynamics/transport/ridging timestep (s)
time0 , & ! total elapsed time at istep0 for idate0 (s)
time , & ! total elapsed time (s)
time_forc , & ! time of last forcing update (s)
yday , & ! day of the year
Expand Down Expand Up @@ -123,6 +124,7 @@ subroutine init_calendar
!-----------------------------------------------------------------

istep = 0 ! local timestep number
time0=istep0*dt ! start time
time=istep0*dt ! s
yday=c0 ! absolute day number
mday=0 ! day of the month
Expand Down
423 changes: 423 additions & 0 deletions configuration/driver/icedrv_history.F90

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ subroutine input_data
use icedrv_calendar, only: year_init, istep0
use icedrv_calendar, only: dumpfreq, diagfreq, dump_last
use icedrv_calendar, only: npt, dt, ndtd, days_per_year, use_leap_years
use icedrv_history, only: history_cdf
use icedrv_restart_shared, only: restart, restart_dir, restart_file
use icedrv_flux, only: update_ocn_f, l_mpond_fresh, cpl_bgc
use icedrv_flux, only: default_season
Expand Down Expand Up @@ -126,7 +127,7 @@ subroutine input_data
dt, npt, ndtd, dump_last, &
ice_ic, restart, restart_dir, restart_file, &
dumpfreq, diagfreq, diag_file, cpl_bgc, &
conserv_check
conserv_check, history_cdf

namelist /grid_nml/ &
kcatbound
Expand Down Expand Up @@ -234,6 +235,7 @@ subroutine input_data
restart = .false. ! if true, read restart files for initialization
restart_dir = './' ! write to executable dir for default
restart_file = 'iced' ! restart file name prefix
history_cdf = .false. ! history netcdf file flag
ice_ic = 'default' ! initial conditions are specified in the code
! otherwise, the filename for reading restarts
ndtd = 1 ! dynamic time steps per thermodynamic time step
Expand Down Expand Up @@ -500,6 +502,7 @@ subroutine input_data
trim(restart_dir)
write(nu_diag,*) ' restart_file = ', &
trim(restart_file)
write(nu_diag,1010) ' history_cdf = ', history_cdf
write(nu_diag,*) ' ice_ic = ', &
trim(ice_ic)
write(nu_diag,1010) ' conserv_check = ', conserv_check
Expand Down
4 changes: 4 additions & 0 deletions configuration/scripts/icepack.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ cd ${ICE_OBJDIR}

setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DNXGLOB=${ICE_NXGLOB} -DNICELYR=${NICELYR} -DNSNWLYR=${NSNWLYR} -DNICECAT=${NICECAT} -DNFSDCAT=${NFSDCAT} -DTRAGE=${TRAGE} -DTRFY=${TRFY} -DTRLVL=${TRLVL} -DTRPND=${TRPND} -DTRBRI=${TRBRI} -DNTRISO=${NTRISO} -DNTRAERO=${NTRAERO} -DTRZS=${TRZS} -DNBGCLYR=${NBGCLYR} -DTRALG=${TRALG} -DTRBGCZ=${TRBGCZ} -DTRDOC=${TRDOC} -DTRDOC=${TRDOC} -DTRDIC=${TRDIC} -DTRDON=${TRDON} -DTRFED=${TRFED} -DTRFEP=${TRFEP} -DTRZAERO=${TRZAERO} -DTRBGCS=${TRBGCS} "

if (${ICE_IOTYPE} == 'netcdf') then
setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DUSE_NETCDF"
endif

### List of source code directories (in order of importance).
cat >! Filepath << EOF
${ICE_SANDBOX}/configuration/driver
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/icepack_in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
dump_last = .false.
diagfreq = 24
diag_file = 'ice_diag'
history_cdf = .false.
cpl_bgc = .false.
conserv_check = .false.
/
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/options/set_env.ionetcdf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setenv ICE_IOTYPE netcdf
1 change: 1 addition & 0 deletions configuration/scripts/options/set_nml.ionetcdf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
history_cdf = .true.
2 changes: 1 addition & 1 deletion configuration/scripts/setup_run_dirs.csh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if !(-d ${ICE_RUNDIR}) then
echo "mkdir ${ICE_RUNDIR}"
mkdir -p ${ICE_RUNDIR}
endif
#if !(-d ${ICE_HSTDIR}) mkdir -p ${ICE_HSTDIR}
if !(-d ${ICE_HSTDIR}) mkdir -p ${ICE_HSTDIR}
if !(-d ${ICE_RSTDIR}) mkdir -p ${ICE_RSTDIR}

exit 0
2 changes: 2 additions & 0 deletions configuration/scripts/tests/io_suite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
restart col 1x1 debug,ionetcdf
smoke col 1x1 run1year,diag1,ionetcdf
1 change: 1 addition & 0 deletions doc/source/icepack_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ either Celsius or Kelvin units).
"highfreq", ":math:`\bullet` high-frequency atmo coupling", "F"
"hin_old", "ice thickness prior to growth/melt", "m"
"hin_max", "category thickness limits", "m"
"history_cdf", "flag to turn on netcdf history output", "F"
"hmix", "ocean mixed layer depth", "20. m"
"hour", "hour of the year", ""
"hp0", "pond depth at which shortwave transition to bare ice occurs", "0.2 m"
Expand Down
4 changes: 3 additions & 1 deletion doc/source/user_guide/ug_case_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ can be found in :ref:`cicecpps`. The following CPPs are available.
"**General Macros**", ""
"NO_I8", "Converts ``integer*8`` to ``integer*4``."
"NO_R16", "Converts ``real*16`` to ``real*8``."
"USE_NETCDF", "Turns on netcdf capabilities in Icepack. By default and generally, Icepack does not need netcdf."
"",""
"**Application Macros**", ""
"CESMCOUPLED", "Turns on code changes for the CESM coupled application "
Expand Down Expand Up @@ -65,7 +66,7 @@ can be modified as needed.
"ICE_LOGDIR", "string", "log directory", "${ICE_CASEDIR}/logs"
"ICE_RSTPFILE", "string", "unused", "undefined"
"ICE_DRVOPT", "string", "unused", "icepack"
"ICE_IOTYPE", "string", "unused", "none"
"ICE_IOTYPE", "none,netcdf", "IO options", "none"
"ICE_CLEANBUILD", "true,false", "automatically clean before building", "true"
"ICE_CPPDEFS", "string", "user defined preprocessor macros for build", "null"
"ICE_QUIETMODE", "true, false", "reduce build output to the screen", "false"
Expand Down Expand Up @@ -139,6 +140,7 @@ setup_nml
"", "``y``", "write restart every ``dumpfreq_n`` years", ""
"``dump_last``", "true/false", "write restart at end of run", "false"
"``dt``", "seconds", "thermodynamics time step length", "3600."
"``history_cdf``", "logical", "netcdf history output", "``.false.``"
"``ice_ic``", "``default``", "latitude and sst dependent initial condition", "``default``"
"", "``none``", "no ice", ""
"", "'path/file'", "restart file name", ""
Expand Down
30 changes: 27 additions & 3 deletions doc/source/user_guide/ug_implementation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ default in this distribution, this is not a stringent limitation:
Model output
------------

History output from Icepack is not currently supported in the Icepack driver, except
in restart files.
The sea ice model `CICE <https://github.com/CICE-Consortium/CICE>`_ provides extensive
The Icepack model provides diagnostic output files, binary restart files, and a primitive
netcdf history file capability.
The sea ice model `CICE <https://github.com/CICE-Consortium/CICE>`_ provides more extensive
options for model output, including many derived output variables.

Diagnostic files
Expand All @@ -176,6 +176,30 @@ the namelist option ``restart`` must be set to ``.true.`` to use the file.
``dump_last`` namelist can also be set to true to trigger restarts automatically
at then end of runs.

History files
~~~~~~~~~~~~~

Icepack has a primitive netcdf history capability that is turned on with the
``history_cdf`` namelist. When ``history_cdf`` is set to true, history files
are created for each run with a naming convention of **icepack.h.yyyymmdd.nc**
in the run directory history directory. The yyyymmdd is the start date for each run.

When Icepack history files are turned on, data for a set of fixed fields is written
to the history file for each column at every timestep without ability to control
fields, frequencies, or temporal averaging. All output fields are hardwired into
the implementation in **configuration/driver/icedrv_history.F90** file. The netcdf file
does NOT meet NetCDF CF conventions and is provided as an amenity in the standalone
Icepack model. Users are free to modify the output fields or
extend the implementation and are encouraged to share any updates with the Consortium.

The default configuration of Icepack does not require NetCDF. If history files are
written, the USE_NETCDF C preprocessor directive must be set during compilation. This
is done by setting ``ICE_IOTYPE`` to ``netcdf`` in **icepack.settings**. In addition,
the machine env and Macros files must include support for compilation with NetCDF. The
``icepack.setup -s`` option ``ionetcdf`` will set the ICE_IOTYPE to netcdf, which turns on
the USE_NETCDF C preprocessor. ``ionetcdf`` also sets the ``history_cdf`` flag to true.


.. _bgc-hist:

Biogeochemistry History Fields
Expand Down