Skip to content

Commit

Permalink
Update CMEPS (#58)
Browse files Browse the repository at this point in the history
* updates CMEPS with latests changes from ESCOMP, including

- xgrid capablility (cesm only)
- refactored accumulation field bundles 
- cleaned up med.F90 for mesh creation 
- refactored mediatory history functionality
  • Loading branch information
DeniseWorthen authored Oct 29, 2021
1 parent 7d7c066 commit 5beead0
Show file tree
Hide file tree
Showing 64 changed files with 10,005 additions and 5,128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
CXX: mpicxx
CPPFLAGS: "-I/usr/include -I/usr/local/include"
# Versions of all dependencies can be updated here
ESMF_VERSION: ESMF_8_1_0_beta_snapshot_47
ESMF_VERSION: ESMF_8_2_0_beta_snapshot_14
PNETCDF_VERSION: pnetcdf-1.12.2
NETCDF_FORTRAN_VERSION: v4.5.2
# PIO version is awkward
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ install:
- pip install pylint

python:
- '2.7'
- '3.6'
- '3.7'
- '3.8'
- '3.9'

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion cime_config/buildexe
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _main_func():
if not os.path.isdir(bld_root):
os.makedirs(bld_root)

with open(os.path.join(bld_root,'Filepath'), 'w') as out:
with open(os.path.join(bld_root,'Filepath'), 'w', encoding="utf-8") as out:
cmeps_dir = os.path.join(os.path.dirname(__file__), os.pardir)
# SourceMods dir needs to be first listed
out.write(os.path.join(caseroot, "SourceMods", "src.drv") + "\n")
Expand Down
55 changes: 35 additions & 20 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,27 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
config['bfbflag'] = 'on' if case.get_value('BFBFLAG') else 'off'
config['continue_run'] = '.true.' if case.get_value('CONTINUE_RUN') else '.false.'
config['flux_epbal'] = 'ocn' if case.get_value('CPL_EPBAL') == 'ocn' else 'off'
config['atm_grid'] = case.get_value('ATM_GRID')
config['mask_grid'] = case.get_value('MASK_GRID')
config['rest_option'] = case.get_value('REST_OPTION')

atm_grid = case.get_value('ATM_GRID')
lnd_grid = case.get_value('LND_GRID')
ice_grid = case.get_value('ICE_GRID')
ocn_grid = case.get_value('OCN_GRID')
rof_grid = case.get_value('ROF_GRID')
wav_grid = case.get_value('WAV_GRID')
#pylint: disable=unused-variable
glc_grid = case.get_value('GLC_GRID')

config['atm_grid'] = atm_grid
config['lnd_grid'] = lnd_grid
config['ice_grid'] = ice_grid
config['ocn_grid'] = ocn_grid
config['samegrid_atm_lnd'] = 'true' if atm_grid == lnd_grid else 'false'
config['samegrid_atm_ice'] = 'true' if atm_grid == ice_grid else 'false'
config['samegrid_atm_ocn'] = 'true' if atm_grid == ocn_grid else 'false'
config['samegrid_atm_wav'] = 'true' if atm_grid == wav_grid else 'false'
config['samegrid_lnd_rof'] = 'true' if lnd_grid == rof_grid else 'false'

# determine if need to set atm_domainfile
scol_lon = float(case.get_value('PTS_LON'))
Expand Down Expand Up @@ -84,11 +103,6 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
#----------------------------------------------------
nmlgen.init_defaults(infile, config)

if case.get_value('MEDIATOR_READ_RESTART'):
nmlgen.set_value('mediator_read_restart', value='.true.')
else:
nmlgen.set_value('mediator_read_restart', value='.false.')

#--------------------------------
# Overwrite: set brnch_retain_casename
#--------------------------------
Expand Down Expand Up @@ -273,7 +287,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
# the driver restart pointer will look like a mediator is present even if it is not
nmlgen.set_value("drv_restart_pointer", value="rpointer.cpl")

logger.info("Writing nuopc_runseq for components {}".format(valid_comps))
logger.info("Writing nuopc_runconfig for components {}".format(valid_comps))
nuopc_config_file = os.path.join(confdir, "nuopc.runconfig")
nmlgen.write_nuopc_config_file(nuopc_config_file, data_list_path=data_list_path)

Expand All @@ -282,7 +296,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
#--------------------------------

# Read nuopc.runconfig
with open(nuopc_config_file, 'r') as f:
with open(nuopc_config_file, 'r', encoding="utf-8") as f:
lines_cpl = f.readlines()

# Look for only active components except CPL
Expand All @@ -294,7 +308,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
comp_config_file = os.path.join(caseroot,"Buildconf","{}conf".format(case.get_value("COMP_{}".format(comp))),
"{}.configure".format(case.get_value("COMP_{}".format(comp))))
if os.path.isfile(comp_config_file):
with open(comp_config_file, 'r') as f:
with open(comp_config_file, 'r', encoding="utf-8") as f:
lines_comp = f.readlines()

if lines_comp:
Expand All @@ -312,7 +326,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
lines_cpl_new.append(line_comp)

# Write to a file
with open(nuopc_config_file, 'w') as f:
with open(nuopc_config_file, 'w', encoding="utf-8") as f:
for line in lines_cpl_new:
f.write(line)

Expand Down Expand Up @@ -344,7 +358,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
dicts = {}
for infile in infiles:
dict_ = {}
with open(infile) as myfile:
with open(infile, "r", encoding="utf-8") as myfile:
for line in myfile:
if "=" in line and '!' not in line:
name, var = line.partition("=")[::2]
Expand Down Expand Up @@ -386,7 +400,7 @@ def _create_runseq(case, coupling_times, valid_comps):
if len(valid_comps) == 1:

# Create run sequence with no mediator
outfile = open(os.path.join(caseroot, "CaseDocs", "nuopc.runseq"), "w")
outfile = open(os.path.join(caseroot, "CaseDocs", "nuopc.runseq"), "w", encoding="utf-8")
dtime = coupling_times[valid_comps[0].lower() + '_cpl_dt']
outfile.write ("runSeq:: \n")
outfile.write ("@" + str(dtime) + " \n")
Expand Down Expand Up @@ -469,11 +483,12 @@ def _create_component_modelio_namelists(confdir, case, files):
for entry in entries:
nmlgen.add_default(entry)

if model == "cpl":
modelio_file = "med_modelio.nml" + inst_string
else:
modelio_file = model + "_modelio.nml" + inst_string
nmlgen.write_nuopc_modelio_file(os.path.join(confdir, modelio_file))
if inst_index == 1:
if model == "cpl":
modelio_file = "med_modelio.nml"
else:
modelio_file = model + "_modelio.nml"
nmlgen.write_nuopc_modelio_file(os.path.join(confdir, modelio_file))

# Output the following to nuopc.runconfig
moddiro = case.get_value('RUNDIR')
Expand All @@ -482,7 +497,7 @@ def _create_component_modelio_namelists(confdir, case, files):
else:
logfile = model + inst_string + ".log." + str(lid)

with open(nuopc_config_file, 'a') as outfile:
with open(nuopc_config_file, 'a', encoding="utf-8") as outfile:
if model == 'cpl':
name = "MED"
else:
Expand Down Expand Up @@ -516,11 +531,11 @@ def buildnml(case, caseroot, component):
if component != "drv":
raise AttributeError

# Do a check here of ESMF VERSION, requires 8.1.0 or newer (8.2.0 or newer for esmf_aware_threading)
# Do a check here of ESMF VERSION, requires 8.1.0 or newer (8.2.0 or newer for esmf_aware_threading)
esmf_aware_threading = case.get_value("ESMF_AWARE_THREADING")
esmfmkfile = os.getenv("ESMFMKFILE")
expect(esmfmkfile and os.path.isfile(esmfmkfile),"ESMFMKFILE not found {}".format(esmfmkfile))
with open(esmfmkfile, 'r') as f:
with open(esmfmkfile, 'r', encoding="utf-8") as f:
major = None
minor = None
for line in f.readlines():
Expand Down
103 changes: 30 additions & 73 deletions cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -435,27 +435,6 @@
</values>
</entry>

<entry id="BARRIER_N">
<type>char</type>
<default_value>1</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
<desc>
Sets periodic model barriers with BARRIER_OPTION and BARRIER_DATE for synchronization
</desc>
</entry>

<entry id="BARRIER_DATE">
<type>char</type>
<default_value>-999</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
<desc>
Alternative date in yyyymmdd format
sets periodic model barriers with BARRIER_OPTION and BARRIER_N for synchronization
</desc>
</entry>

<entry id="ESP_RUN_ON_PAUSE">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand Down Expand Up @@ -841,6 +820,21 @@
machines.</desc>
</entry>

<entry id="CLM_USE_PETSC">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_component_clm</group>
<file>env_build.xml</file>
<desc>TRUE implies CLM is built with support for the PETSc
library. The Variably Saturated Flow Model (VSFM) solver in CLM
uses the PETSc library. In order to use the VSFM solver, CLM
must be built with PETSc support and linking to PETSc must occur
when building the ACME executable. This occurs if this variable
is set to TRUE. Note that is only available on a limited set of
machines/compilers.</desc>
</entry>

<entry id="USE_MOAB">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand Down Expand Up @@ -2294,10 +2288,6 @@
<desc>standard full pathname of the cprnc executable</desc>
</entry>

<!-- ===================================================================== -->
<!-- component coupling options and frequencies -->
<!-- ===================================================================== -->

<entry id="CPL_I2O_PER_CAT">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand All @@ -2307,38 +2297,6 @@
<desc>determine if per ice thickness category fields are passed from ice to ocean - DO NOT EDIT (set by POP build-namelist)</desc>
</entry>

<!-- ===================================================================== -->
<!-- history frequencies -->
<!-- ===================================================================== -->

<entry id="HIST_OPTION">
<type>char</type>
<valid_values>none,never,nsteps,nstep,nseconds,nsecond,nminutes,nminute,nhours,nhour,ndays,nday,nmonths,nmonth,nyears,nyear,end</valid_values>
<default_value>never</default_value>
<group>run_drv_history</group>
<file>env_run.xml</file>
<desc>Sets driver snapshot history file frequency (like REST_OPTION)</desc>
</entry>

<entry id="HIST_N">
<type>integer</type>
<valid_values></valid_values>
<default_value>-999</default_value>
<group>run_drv_history</group>
<file>env_run.xml</file>
<desc>Sets driver snapshot history file frequency (like REST_N)
</desc>
</entry>

<entry id="HIST_DATE">
<type>integer</type>
<valid_values></valid_values>
<default_value>-999</default_value>
<group>run_drv_history</group>
<file>env_run.xml</file>
<desc>yyyymmdd format, sets coupler snapshot history date (like REST_DATE)</desc>
</entry>

<entry id="INFO_DBUG">
<type>integer</type>
<valid_values>0,1,2,3,4,5,6,7,8,9</valid_values>
Expand All @@ -2348,22 +2306,6 @@
<desc>level of debug output, 0=minimum, 1=normal, 2=more, 3=too much</desc>
</entry>

<entry id="CLM_USE_PETSC">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_component_clm</group>
<file>env_build.xml</file>
<desc>TRUE implies CLM is built with support for the PETSc
library. The Variably Saturated Flow Model (VSFM) solver in CLM
uses the PETSc library. In order to use the VSFM solver, CLM
must be built with PETSc support and linking to PETSc must occur
when building the ACME executable. This occurs if this variable
is set to TRUE. Note that is only available on a limited set of
machines/compilers.</desc>
</entry>


<!-- Prerun/postrun custom script options -->

<entry id="PRERUN_SCRIPT">
Expand Down Expand Up @@ -2541,6 +2483,21 @@
<desc>add aoflux calculation to runseq</desc>
</entry>

<!-- ===================================================================== -->
<!-- TODO: the following should be deleted. They are still used by -->
<!-- the component testing but are not doing anything in cmeps -->
<!-- ===================================================================== -->

<entry id="BFBFLAG">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_flags</group>
<file>env_run.xml</file>
<desc>turns on coupler bit-for-bit reproducibility with varying pe counts</desc>
</entry>


<help>
=========================================
Notes:
Expand Down
Loading

0 comments on commit 5beead0

Please sign in to comment.