Skip to content

Commit

Permalink
ice_history: allow per-stream suffix for history filenames (CICE-Cons…
Browse files Browse the repository at this point in the history
…ortium#912)

* Add capability for h extension

* Update documentation for hist_str

* Change hist_str to hist_suffix

* Change in default namelist

* Update doc/source/cice_index.rst

Co-authored-by: Philippe Blain <levraiphilippeblain@gmail.com>

* One more hist_str

---------

Co-authored-by: Philippe Blain <levraiphilippeblain@gmail.com>
  • Loading branch information
dabail10 and phil-blain authored Nov 28, 2023
1 parent 21fab16 commit b14cedf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cicecore/cicedyn/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module ice_history_shared
character (len=char_len), public :: &
history_format

character (len=char_len), public :: &
hist_suffix(max_nstrm) ! appended to 'h' in filename when not 'x'

!---------------------------------------------------------------
! Instructions for adding a field: (search for 'example')
! Here or in ice_history_[process].F90:
Expand Down Expand Up @@ -763,9 +766,7 @@ subroutine construct_filename(ncfile,suffix,ns)
endif

cstream = ''
!echmod ! this was implemented for CESM but it breaks post-processing software
!echmod ! of other groups (including RASM which uses CESMCOUPLED)
!echmod if (ns > 1) write(cstream,'(i1.1)') ns-1
if (hist_suffix(ns) /= 'x') cstream = hist_suffix(ns)

if (hist_avg(ns)) then ! write averaged data
if (histfreq(ns) == '1' .and. histfreq_n(ns) == 1) then ! timestep
Expand Down
6 changes: 5 additions & 1 deletion cicecore/cicedyn/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ subroutine input_data
use ice_restart_shared, only: &
restart, restart_ext, restart_coszen, restart_dir, restart_file, pointer_file, &
runid, runtype, use_restart_time, restart_format, lcdf64
use ice_history_shared, only: hist_avg, history_dir, history_file, &
use ice_history_shared, only: hist_avg, history_dir, history_file, hist_suffix, &
incond_dir, incond_file, version_name, &
history_precision, history_format, hist_time_axis
use ice_flux, only: update_ocn_f, cpl_frazil, l_mpond_fresh
Expand Down Expand Up @@ -188,6 +188,7 @@ subroutine input_data
hist_time_axis, &
print_global, print_points, latpnt, lonpnt, &
debug_forcing, histfreq, histfreq_n, hist_avg, &
hist_suffix, &
history_dir, history_file, history_precision, cpl_bgc, &
histfreq_base, dumpfreq_base, timer_stats, memory_stats, &
conserv_check, debug_model, debug_model_step, &
Expand Down Expand Up @@ -324,6 +325,7 @@ subroutine input_data
histfreq_n(:) = 1 ! output frequency
histfreq_base(:) = 'zero' ! output frequency reference date
hist_avg(:) = .true. ! if true, write time-averages (not snapshots)
hist_suffix(:) = 'x' ! appended to 'history_file' in filename when not 'x'
history_format = 'default' ! history file format
hist_time_axis = 'end' ! History file time axis averaging interval position

Expand Down Expand Up @@ -911,6 +913,7 @@ subroutine input_data
call broadcast_scalar(histfreq_base(n), master_task)
call broadcast_scalar(dumpfreq(n), master_task)
call broadcast_scalar(dumpfreq_base(n), master_task)
call broadcast_scalar(hist_suffix(n), master_task)
enddo
call broadcast_array(hist_avg, master_task)
call broadcast_array(histfreq_n, master_task)
Expand Down Expand Up @@ -2355,6 +2358,7 @@ subroutine input_data
write(nu_diag,1023) ' histfreq_n = ', histfreq_n(:)
write(nu_diag,1033) ' histfreq_base = ', histfreq_base(:)
write(nu_diag,*) ' hist_avg = ', hist_avg(:)
write(nu_diag,1033) ' hist_suffix = ', hist_suffix(:)
write(nu_diag,1031) ' history_dir = ', trim(history_dir)
write(nu_diag,1031) ' history_file = ', trim(history_file)
write(nu_diag,1021) ' history_precision= ', history_precision
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/ice_in
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
histfreq_n = 1 , 1 , 1 , 1 , 1
histfreq_base = 'zero','zero','zero','zero','zero'
hist_avg = .true.,.true.,.true.,.true.,.true.
hist_suffix = 'x','x','x','x','x'
history_dir = './history/'
history_file = 'iceh'
history_precision = 4
Expand Down
1 change: 1 addition & 0 deletions doc/source/cice_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ section :ref:`tabnamelist`.
"history_format", "history file format", ""
"history_precision", "history output precision: 4 or 8 byte", "4"
"hist_time_axis", "history file time axis interval location: begin, middle, end", "end"
"hist_suffix", "suffix to `history_file` in filename. x means no suffix", "x,x,x,x,x"
"hm", "land/boundary mask, thickness (T-cell)", ""
"hmix", "ocean mixed layer depth", "20. m"
"hour", "hour of the year", ""
Expand Down
1 change: 1 addition & 0 deletions doc/source/user_guide/ug_case_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ setup_nml
"``history_format``", "``default``", "read/write history files in default format", "``default``"
"", "``pio_pnetcdf``", "read/write restart files with pnetcdf in pio", ""
"``history_precision``", "integer", "history file precision: 4 or 8 byte", "4"
"``hist_suffix``", "character array", "appended to history_file when not x", "``x,x,x,x,x``"
"``hist_time_axis``","character","history file time axis interval location: begin, middle, end","end"
"``ice_ic``", "``default``", "equal to internal", "``default``"
"", "``internal``", "initial conditions set based on ice\_data\_type,conc,dist inputs", ""
Expand Down
9 changes: 6 additions & 3 deletions doc/source/user_guide/ug_implementation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,11 @@ io package. The namelist variable ``history_format`` further refines the
format approach or style for some io packages.

Model output data can be written as instantaneous or average data as specified
by the ``hist_avg`` namelist array and is customizable by stream. The data is
written at the period(s) given by ``histfreq`` and
by the ``hist_avg`` namelist array and is customizable by stream. Characters
can be added to the ``history_filename`` to distinguish the streams. This can be changed
by modifying ``hist_suffix`` to something other than "x".

The data written at the period(s) given by ``histfreq`` and
``histfreq_n`` relative to a reference date specified by ``histfreq_base``.
The files are written to binary or netCDF files prepended by ``history_file``
in **ice_in**. These settings for history files are set in the
Expand Down Expand Up @@ -1199,7 +1202,7 @@ is a character string corresponding to ``histfreq`` or ‘x’ for none.
files, no matter what the frequency is.) If there are no namelist flags
with a given ``histfreq`` value, or if an element of ``histfreq_n`` is 0, then
no file will be written at that frequency. The output period can be
discerned from the filenames. Each history stream will be either instantaneous
discerned from the filenames or the ``hist_suffix`` can be used. Each history stream will be either instantaneous
or averaged as specified by the corresponding entry in the ``hist_avg`` namelist array, and the frequency
will be relative to a reference date specified by the corresponding entry in ``histfreq_base``.
More information about how the frequency is
Expand Down

0 comments on commit b14cedf

Please sign in to comment.