Skip to content

Commit

Permalink
Instantaneous CAM-SIMA history infrastructure (#274)
Browse files Browse the repository at this point in the history
Tag name (required for release branches):
Originator(s): peverwhee, gold2718

Summary (include the keyword ['closes', 'fixes', 'resolves'] and issue
number):
- Implement instantaneous history output in CAM-SIMA using the new
modular history code (addresses #29)
- Update the standard name `inverse_exner_function_wrt_surface_pressure`
to `reciprocal_of_dimensionless_exner_function_wrt_surface_air_pressure`

Describe any changes made to build system:
A cime_config/hist_config.py: New namelist parsing for history
configurations
M   cime_config/buildlib: Add new history directories
M   cime_config/buildnml: Incorporate hist_config.py
M   cime_config/atm_in_paramgen: Incorporate hist_config.py

Describe any changes made to the namelist: Can now use CAM-SIMA history
namelist - see https://escomp.github.io/CAM-SIMA-docs/usage/history/

List any changes to the defaults for the input datasets (e.g. boundary
datasets): none

List all files eliminated and why:
D   src/control/filenames.F90
-renamed to src/utils/cam_filenames.F90

List all files added and what they do:
A   src/control/cam_physics_control.F90
-split cam_control_mod to avoid circular dependency
A   src/utils/cam_filenames.F90
-renamed from control/filenames.F90
A   src/history/cam_hist_file.F90
A   src/history/cam_history.F90
A   src/history/cam_history_support.F90
-core CAM-SIMA history infrastructure
A   test/unit/test_hist_config.py
-test hist_config.py (namelist parsing)

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
development...<your_branch_name>`)
M   src/control/cam_comp.F90
-add calls to new history infrastructure
M   src/control/cam_control_mod.F90
-split to into cam_control_mod and cam_physics_control
M   src/control/runtime_opts.F90
-add call to history namelist reader
M   src/control/cam_initfiles.F90
-update use statement
M   src/cpl/nuopc/atm_comp_nuopc.F90
-add rstwr and nlend to cam_timestep_final calls, add do_history_write
logical
M   src/data/registry.xml
M   src/dynamics/se/dyn_comp.F90
M   src/dynamics/mpas/dyn_comp.F90
-update exner and vertically_integrated_* standard names
M   src/dynamics/utils/hycoef.F90
-enable history coordinates
M   src/utils/cam_abortutils.F90
-fix bug in cam_register_open_file
M   src/utils/cam_field_read.F90
-code cleanup
M   src/utils/cam_grid_support.F90
-update to enable split history files
M   src/utils/cam_pio_utils.F90
-only register created and opened files if we're writing to them
M   src/utils/cam_time_coord.F90
M   src/utils/time_manager.F90
-update use statement
M   src/utils/string_utils.F90
-add functions date2yyyymmdd and sec2hms
M   test/run_unit_tests.sh
-add new hist_config test

If there are new failures (compare to the
`test/existing-test-failures.txt` file),
have them OK'd by the gatekeeper, note them here, and add them to the
file.
If there are baseline differences, include the test and the reason for
the
diff. What is the nature of the change? Roundoff?

derecho/intel/aux_sima:

derecho/gnu/aux_sima:

If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:
  • Loading branch information
peverwhee authored Oct 25, 2024
2 parents 1281928 + 69ac862 commit e69640a
Show file tree
Hide file tree
Showing 43 changed files with 7,090 additions and 635 deletions.
12 changes: 9 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
url = https://github.com/NCAR/ccpp-framework
fxtag = 2024-07-19-dev
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/NCAR/ccpp-framework
fxDONOTUSEurl = https://github.com/NCAR/ccpp-framework
[submodule "history"]
path = src/history/buffers
url = https://github.com/ESMCI/history_output
fxtag = history01_00
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESMCI/history_output
[submodule "mpas"]
path = src/dynamics/mpas/dycore
url = https://github.com/MPAS-Dev/MPAS-Model.git
Expand All @@ -13,8 +19,8 @@
fxDONOTUSEurl = https://github.com/MPAS-Dev/MPAS-Model.git
[submodule "ncar-physics"]
path = src/physics/ncar_ccpp
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = 67bb908e
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = e95c172d7a5a0ebf054f420b08416228e211baa3
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
[submodule "ccs_config"]
Expand Down
4 changes: 2 additions & 2 deletions cime_config/atm_in_paramgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,8 +1447,8 @@ def append_user_nl_file(self, user_nl_file):
#Notify loop to check the next line for a comma:
is_continue_line = False
#End if

else:
elif ('hist_' not in line_s[0]):
#Raise parsing error; ignore hist lines to be processed by hist_config.py
emsg = "Cannot parse the following line in '{}' :\n'{}'"
raise AtmInParamGenError(emsg.format(user_nl_file, line))
#End if ("=" sign check)
Expand Down
4 changes: 4 additions & 0 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def _build_cam():
case.get_value("COMP_INTERFACE")),
os.path.join(atm_root, "src", "dynamics", "utils"),
os.path.join(atm_root, "src", "physics", "utils"),
os.path.join(atm_root, "src", "history"),
os.path.join(atm_root, "src", "history", "buffers", "src"),
os.path.join(atm_root, "src", "history", "buffers", "src", "hash"),
os.path.join(atm_root, "src", "history", "buffers", "src", "util"),
os.path.join(atm_root, "src", "utils")]
for path in phys_dirs:
if path not in paths:
Expand Down
17 changes: 16 additions & 1 deletion cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CAM namelist creator
"""
import sys
import os
import re
import shutil
import logging
import glob
Expand All @@ -31,6 +32,8 @@ sys.path.append(_CIME_CONFIG_PATH)

# Import CAM's configure structure:
from cam_config import ConfigCAM
# HistoryConfig allows translation from user_nl_cam into Fortran namelists
from hist_config import HistoryConfig

#Import CAM's ParamGen class:
from atm_in_paramgen import AtmInParamGen
Expand All @@ -51,6 +54,7 @@ class CamBuildnmlError(ValueError):
# This simplifies the filename mangling for different cases.
def _create_ic_filename(inst_string, i_or_r,
run_refcase, run_refdate, run_reftod):
"""Simplify the filename mangling for different cases."""
return f"{run_refcase}.cam{inst_string}.{i_or_r}.{run_refdate}-{run_reftod}.nc"

##################
Expand Down Expand Up @@ -297,7 +301,8 @@ def buildnml(case, caseroot, compname):
# End if

# Determine location and name of "user_nl_cam" files:
user_nl_file = os.path.join(caseroot, "user_nl_cam" + inst_string)
user_nl_fname = "user_nl_cam" + inst_string
user_nl_file = os.path.join(caseroot, user_nl_fname)

# Check that file actually exists. If not then throw an error:
if not os.path.exists(user_nl_file):
Expand Down Expand Up @@ -362,6 +367,16 @@ def buildnml(case, caseroot, compname):
# Create CAM namelist using CIME's nmlgen routine:
pg_atm.write(namelist_file)

# Add history namelists to atm_in
hist_configs = HistoryConfig(filename=user_nl_file, logger=_LOGGER)
with open(namelist_file, 'a', encoding='utf-8') as nl_file:
hist_configs.output_class_namelist(nl_file)
for key in sorted(hist_configs.keys()):
hist_configs[key].output_config_namelist(nl_file, logger=_LOGGER)
# end for
# end with


###############################################################################
def _main_func():

Expand Down
Loading

0 comments on commit e69640a

Please sign in to comment.