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

Port SE dycore to CAMDEN #135

Merged
merged 46 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6172d21
Add modifications needed for SE dycore configuration and namelist gen…
nusbaume Oct 19, 2020
47ecaa7
Remove extra public copy of 'iMap' (Github issue #78).
nusbaume Oct 30, 2020
afa9da8
Add 'air_composition_nl' namelist group, which is needed for the SE d…
nusbaume Nov 4, 2020
570e648
Add SE dycore source code, modified to work with new host model infra…
nusbaume Nov 6, 2020
7e6a42d
Update SE dycore code to head of ESCOMP/CAM cam_development branch.
nusbaume Jan 13, 2021
1884f96
Perform miscellaneous code cleanup.
nusbaume Jan 14, 2021
6a85704
Add ability to set CPP definitions. Also fix python and meta file bugs.
nusbaume Jan 20, 2021
e194d66
Add cam_development updates to physics_grid, and implement 'model_gri…
nusbaume Jan 22, 2021
a34d9ac
Make modifications necessary for model to compile with SE dycore.
nusbaume Feb 4, 2021
31f8be0
Remove pmgrid.F90 and replace with vert_coord module.
nusbaume Mar 17, 2021
d87fb55
Allow SE dycore to use run-time configured vertical levels and tracer…
nusbaume Mar 30, 2021
1f820f5
Add stat checks to all 'allocate' statements in SE dycore.
nusbaume Apr 9, 2021
b813ba2
Fix runtime namelist errors for SE dycore.
nusbaume Apr 12, 2021
42ea4f9
Apply code fixes for SE dycore initialization.
nusbaume Apr 19, 2021
9810fde
Remove temporary dyn_init debugging code.
nusbaume Apr 20, 2021
b52e5e9
Add code modifications needed for SE dycore to run to completion.
nusbaume Apr 26, 2021
a64e7c2
Fix bug in physconst, and add extra mark_as_init calls.
nusbaume May 1, 2021
cf8c726
Remove mistakenly added debugging code in registry generator.
nusbaume May 1, 2021
a7e54d8
Fix 'allow_abrev' python version issue, and use 'csne' to set the se_…
nusbaume May 20, 2021
77521d2
Add bug fixes needed to run with PGI and NAG compilers.
nusbaume May 22, 2021
4420c65
Remove FVM_TRACERS CPP def, and perform some code clean-up.
nusbaume Jun 2, 2021
db48d38
Ensure the proper kind for physconst calls, and add extra check_alloc…
nusbaume Jun 3, 2021
11d7eb2
Add final SE-dycore check_allocate calls, move ps to phys_state, and …
nusbaume Jun 15, 2021
f1fa068
Fix issues caused by rebase and perform minor clean-up.
nusbaume Jun 16, 2021
6c16f1f
Fix namelist bugs found using CSLAM.
nusbaume Jun 16, 2021
cc05977
Fix unit tests.
nusbaume Jun 16, 2021
60086d8
Fix issues with null dycore simulation.
nusbaume Jun 16, 2021
62b95d4
Add modifications requested by reviewers.
nusbaume Jun 30, 2021
ae73cc6
Fix unit test failures.
nusbaume Jun 30, 2021
16cffc5
Fix NAG debug error (Github issue #136).
nusbaume Jun 30, 2021
1179877
Add additional code reviewer requests.
nusbaume Jul 16, 2021
7805211
Remove nlev from cam_config, as it is no longer necessary.
nusbaume Jul 16, 2021
619707d
Fix unit tests.
nusbaume Jul 16, 2021
436245f
Make buildnml and buildlib use python3 if called directly or as a sub…
nusbaume Jul 29, 2021
7b96279
Create new 'dynconst' and 'dyn_thermo' modules to handle kind convers…
nusbaume Aug 16, 2021
25cca87
Merge remote-tracking branch 'upstream/development' into se_dycore
nusbaume Aug 17, 2021
c265f43
Fix parse_config_opts doctests.
nusbaume Aug 17, 2021
2c5891f
Replace CPP ifdefs with runtime options DDT object.
nusbaume Aug 18, 2021
1e56860
Address review comments and suggestions.
nusbaume Aug 26, 2021
0f9daf1
Fix pylint errors.
nusbaume Aug 26, 2021
4354b9d
Address second round of review comments and suggestions.
nusbaume Sep 21, 2021
9887dd9
Fix pylint errors.
nusbaume Sep 21, 2021
82bd95d
Fix doctest failure in Python 3.5
nusbaume Sep 21, 2021
a012973
Modify registry to work with null dycore.
nusbaume Sep 21, 2021
61182fb
Address third round of review comments and suggestions.
nusbaume Sep 24, 2021
d66cb95
Address final round of review comments and suggestions.
nusbaume Sep 27, 2021
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
25 changes: 22 additions & 3 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def _build_cam():
os.path.join(atm_root, "src", "control"),
os.path.join(atm_root, "src", "cpl",
case.get_value("COMP_INTERFACE")),
os.path.join(atm_root, "src", "dynamics", dycore),
os.path.join(atm_root, "src", "dynamics", "utils"),
os.path.join(atm_root, "src", "physics", "utils"),
os.path.join(atm_root, "src", "utils")]
Expand All @@ -103,12 +102,28 @@ def _build_cam():
paths.append(path)
# End if
# End for
#If using the CMEPS/NUOPC coupler, then add additional path:

# Add dynamics source code directories:
for direc in config.get_value("dyn_src_dirs"):
dyn_dir = os.path.join(atm_root, "src", "dynamics", direc)
if dyn_dir not in paths:
#Add to list of filepaths if not already present:
paths.append(dyn_dir)

# Add analytical IC source code directories:
paths.append(os.path.join(atm_root, "src", "dynamics", "tests")) #Required due to namelist call.
if dycore != "none":
paths.append(os.path.join(atm_root, "src", "dynamics", "tests",
"initial_conditions"))

# If using the CMEPS/NUOPC coupler, then add additional path:
if case.get_value("COMP_INTERFACE") == "nuopc":
paths.append(os.path.join(__CIMEROOT, "src", "drivers",
"nuopc", "nuopc_cap_share"))
# End if
with open(filepath_src, "w") as filepath:

# Write Filepath text file
with open(filepath_src, "w", encoding='utf-8') as filepath:
filepath.write("\n".join(paths))
filepath.write("\n")
# End with
Expand All @@ -132,6 +147,10 @@ def _build_cam():
.format(gmake, gmake_j, complib, makefile,
get_standard_makefile_args(case))

# Add C Pre-Processor (CPP) definitions, if present:
if config.cpp_defs:
cmd += " USER_CPPDEFS='{}'".format(' '.join(config.cpp_defs))

retcode, out, err = run_cmd(cmd)
_LOGGER.info("%s: \n\n output:\n %s \n\n err:\n\n%s\n", cmd, out, err)
expect(retcode == 0, "Command {} failed with rc={}".format(cmd, retcode))
Expand Down
57 changes: 46 additions & 11 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ _LOGGER = logging.getLogger(__name__)
#HELPER FUNCTIONS
#################

class CamBuildnmlError(ValueError):
"""Class used to handle CAM buildnml errors
(e.g., log user errors without backtrace)"""

##################

# This simplifies the filename mangling for different cases.
def _create_ic_filename(inst_string, i_or_r,
run_refcase, run_refdate, run_reftod):
Expand All @@ -50,13 +56,13 @@ def _create_ic_filename(inst_string, i_or_r,
def nml_attr_set(config):

"""
creates a dictionary of namelist attributes
Creates a dictionary of namelist attributes
from the CAM config object, in order to properly
set namelist defaults.
"""

#Create new namelist attribute dictionary:
cam_nml_attr_dict = dict()
#Create new (empty) namelist attribute dictionary:
cam_nml_attr_dict = {}

if config:
#Loop over all CAM configuration settings in config dictionary:
Expand All @@ -68,7 +74,7 @@ def nml_attr_set(config):
#is also a namelist attribute:
if conf.is_nml_attr:
#If so, then add to attribute dictionary:
cam_nml_attr_dict[conf_name] = conf.value
cam_nml_attr_dict[conf_name] = str(conf.value)
# End if
# End for
# End if
Expand All @@ -92,8 +98,6 @@ def buildnml(case, caseroot, compname):
# End if
srcroot = case.get_value("SRCROOT")
rundir = case.get_value("RUNDIR")
din_loc_root = case.get_value("DIN_LOC_ROOT")
atm_ncpl = case.get_value("ATM_NCPL")
cam_namelist_opts = case.get_value("CAM_NAMELIST_OPTS")
cam_nml_use_case = case.get_value("CAM_NML_USE_CASE")
debug = case.get_value("DEBUG")
Expand All @@ -110,7 +114,7 @@ def buildnml(case, caseroot, compname):

#--------------------------------------------------------------------------
# Call config_CAM to set the configuration options needed to
# generate CAM's namelist
# generate CAM's namelist
#--------------------------------------------------------------------------

# Create CAM configure object:
Expand Down Expand Up @@ -249,21 +253,52 @@ def buildnml(case, caseroot, compname):
# Determine location and name of "user_nl_cam" files:
user_nl_file = os.path.join(caseroot, "user_nl_cam" + inst_string)

# Check that file actually exists. If not then throw an error:
if not os.path.exists(user_nl_file):
emsg = "The file 'user_nl_cam' is missing. Please run 'case.setup' first."
raise CamBuildnmlError(emsg)

# Determine location and name of namelist input file:
namelist_infile = os.path.join(confdir, "namelist_infile")

#-----------------------------------------------------------
# Determine CCPP physics suite chosen by user, and set suite
# name to be a namelist attribute:
#-----------------------------------------------------------

# Find user-chosen CCPP physics suite, and set as an attribute:
config.ccpp_phys_set(cam_nml_dict, user_nl_file)

#--------------------------------
# Create CIME namelist input file:
#--------------------------------
create_namelist_infile(case, user_nl_file, namelist_infile,
"\n".join(infile_lines))

# Convert namelist input file to list:
namelist_infile_list = [namelist_infile]

#-----------------------------
# Initialize namelist defaults:
#-----------------------------
#-------------------------------------------------
# Initialize only "vert_coord_nl" namelist entries
#-------------------------------------------------

# Initalize vert_coord_nl defaults:
nmlgen.init_defaults(namelist_infile_list, cam_nml_dict,
skip_default_for_groups=\
filter(lambda group: group !='vert_coord_nl',
config.nml_groups))

#--------------------------------------------
# Set "nlev" namelist attribute to equal pver
#--------------------------------------------

cam_nml_dict["nlev"] = nmlgen.get_value("pver")

#---------------------------------
# Initialize all namelist defaults:
#---------------------------------

# Initalize namelist defaults in used namelis groups:
# Initalize namelist defaults in used namelist groups:
nmlgen.init_defaults(namelist_infile_list, cam_nml_dict)

#--------------------------
Expand Down
14 changes: 10 additions & 4 deletions cime_config/cam_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,15 @@ def generate_physics_suites(ccpp_scripts_path, build_cache, preproc_defs, host_n
#the host model files list for use by CCPP's capgen:
host_files.append(reg_file.file_path)

# Convert preproc defs to string:
if preproc_defs:
preproc_cache_str = ', '.join(preproc_defs)
else:
preproc_cache_str = 'UNSET'

if os.path.exists(genccpp_dir):
do_gen_ccpp = force or build_cache.ccpp_mismatch(sdfs, scheme_files,
preproc_defs,
preproc_cache_str,
kind_phys)
else:
os.makedirs(genccpp_dir)
Expand All @@ -484,18 +490,18 @@ def generate_physics_suites(ccpp_scripts_path, build_cache, preproc_defs, host_n
_LOGGER.debug(" host files: %s", ", ".join(host_files))
_LOGGER.debug(" scheme files: %s", ', '.join(scheme_files))
_LOGGER.debug(" suite definition files: %s", ', '.join(sdfs))
_LOGGER.debug(" preproc defs: %s", ', '.join(preproc_defs))
_LOGGER.debug(" preproc defs: %s", preproc_cache_str)
_LOGGER.debug(" output directory: '%s'", genccpp_dir)
_LOGGER.debug(" kind_phys: '%s'", kind_phys)

# generate CCPP caps
force_overwrite = False
capgen(host_files, scheme_files, sdfs, cap_output_file,
preproc_defs, gen_hostcap, gen_docfiles, genccpp_dir,
preproc_cache_str, gen_hostcap, gen_docfiles, genccpp_dir,
host_name, kind_phys, force_overwrite, _LOGGER)

# save build details in the build cache
build_cache.update_ccpp(sdfs, scheme_files, preproc_defs, kind_phys)
build_cache.update_ccpp(sdfs, scheme_files, preproc_cache_str, kind_phys)
##XXgoldyXX: v Temporary fix: Copy CCPP Framework source code into
##XXgoldyXX: v generated code directory
request = DatatableReport("utility_files")
Expand Down
Loading