Skip to content

Commit e69640a

Browse files
authored
Instantaneous CAM-SIMA history infrastructure (#274)
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:
2 parents 1281928 + 69ac862 commit e69640a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+7090
-635
lines changed

.gitmodules

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
url = https://github.com/NCAR/ccpp-framework
44
fxtag = 2024-07-19-dev
55
fxrequired = AlwaysRequired
6-
fxDONOTUSEurl = https://github.com/NCAR/ccpp-framework
6+
fxDONOTUSEurl = https://github.com/NCAR/ccpp-framework
7+
[submodule "history"]
8+
path = src/history/buffers
9+
url = https://github.com/ESMCI/history_output
10+
fxtag = history01_00
11+
fxrequired = AlwaysRequired
12+
fxDONOTUSEurl = https://github.com/ESMCI/history_output
713
[submodule "mpas"]
814
path = src/dynamics/mpas/dycore
915
url = https://github.com/MPAS-Dev/MPAS-Model.git
@@ -13,8 +19,8 @@
1319
fxDONOTUSEurl = https://github.com/MPAS-Dev/MPAS-Model.git
1420
[submodule "ncar-physics"]
1521
path = src/physics/ncar_ccpp
16-
url = https://github.com/ESCOMP/atmospheric_physics
17-
fxtag = 67bb908e
22+
url = https://github.com/ESCOMP/atmospheric_physics
23+
fxtag = e95c172d7a5a0ebf054f420b08416228e211baa3
1824
fxrequired = AlwaysRequired
1925
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
2026
[submodule "ccs_config"]

cime_config/atm_in_paramgen.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,8 @@ def append_user_nl_file(self, user_nl_file):
14471447
#Notify loop to check the next line for a comma:
14481448
is_continue_line = False
14491449
#End if
1450-
1451-
else:
1450+
elif ('hist_' not in line_s[0]):
1451+
#Raise parsing error; ignore hist lines to be processed by hist_config.py
14521452
emsg = "Cannot parse the following line in '{}' :\n'{}'"
14531453
raise AtmInParamGenError(emsg.format(user_nl_file, line))
14541454
#End if ("=" sign check)

cime_config/buildlib

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def _build_cam():
9797
case.get_value("COMP_INTERFACE")),
9898
os.path.join(atm_root, "src", "dynamics", "utils"),
9999
os.path.join(atm_root, "src", "physics", "utils"),
100+
os.path.join(atm_root, "src", "history"),
101+
os.path.join(atm_root, "src", "history", "buffers", "src"),
102+
os.path.join(atm_root, "src", "history", "buffers", "src", "hash"),
103+
os.path.join(atm_root, "src", "history", "buffers", "src", "util"),
100104
os.path.join(atm_root, "src", "utils")]
101105
for path in phys_dirs:
102106
if path not in paths:

cime_config/buildnml

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CAM namelist creator
55
"""
66
import sys
77
import os
8+
import re
89
import shutil
910
import logging
1011
import glob
@@ -31,6 +32,8 @@ sys.path.append(_CIME_CONFIG_PATH)
3132

3233
# Import CAM's configure structure:
3334
from cam_config import ConfigCAM
35+
# HistoryConfig allows translation from user_nl_cam into Fortran namelists
36+
from hist_config import HistoryConfig
3437

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

5660
##################
@@ -297,7 +301,8 @@ def buildnml(case, caseroot, compname):
297301
# End if
298302

299303
# Determine location and name of "user_nl_cam" files:
300-
user_nl_file = os.path.join(caseroot, "user_nl_cam" + inst_string)
304+
user_nl_fname = "user_nl_cam" + inst_string
305+
user_nl_file = os.path.join(caseroot, user_nl_fname)
301306

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

370+
# Add history namelists to atm_in
371+
hist_configs = HistoryConfig(filename=user_nl_file, logger=_LOGGER)
372+
with open(namelist_file, 'a', encoding='utf-8') as nl_file:
373+
hist_configs.output_class_namelist(nl_file)
374+
for key in sorted(hist_configs.keys()):
375+
hist_configs[key].output_config_namelist(nl_file, logger=_LOGGER)
376+
# end for
377+
# end with
378+
379+
365380
###############################################################################
366381
def _main_func():
367382

0 commit comments

Comments
 (0)