Skip to content

Commit

Permalink
Merge pull request #49 from ekluzek/slim_in_dev_cime
Browse files Browse the repository at this point in the history
Starting point of SLIM in the cesm2_3 development version of CESM
  • Loading branch information
ekluzek committed Jun 14, 2023
2 parents 781cbc3 + 44ad0ce commit 47fe4ce
Show file tree
Hide file tree
Showing 203 changed files with 7,583 additions and 63,541 deletions.
11 changes: 7 additions & 4 deletions .config_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
<type>char</type>
<default_value>unset</default_value>
<values>
<value component="slim" >$SRCROOT</value>
<value component="dlnd" >$CIMEROOT/src/components/data_comps/dlnd</value>
<value component="slnd" >$CIMEROOT/src/components/stub_comps/slnd</value>
<value component="xlnd" >$CIMEROOT/src/components/xcpl_comps/xlnd</value>
<value component="slim" >$SRCROOT</value>
<value component="dlnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/data_comps_mct/dlnd</value>
<value component="dlnd" comp_interface="nuopc">$SRCROOT/components/cdeps/dlnd</value>
<value component="slnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/stub_comps_mct/slnd</value>
<value component="xlnd" comp_interface="mct" >$SRCROOT/components/cpl7/components/xcpl_comps_mct/xlnd</value>
<value component="slnd" comp_interface="nuopc">$CIMEROOT/src/components/stub_comps_nuopc/slnd</value>
<value component="xlnd" comp_interface="nuopc">$CIMEROOT/src/components/xcpl_comps_nuopc/xlnd</value>
</values>
<group>case_comps</group>
<file>env_case.xml</file>
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
manage_externals.log
cime/
components/
ccs_config/
libraries/
share/

# ignore svn directories
**/.svn/**
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ We recommend that you first open an issue (https://github.com/escomp/ctsm/issues
discuss the changes or additions that you propose. You should also contact some of the responsible
individuals for SLIM and run by the changes with them.

Erik Kluzek -- Software Engineering ([email protected])
Marysa Legue -- Originator ([email protected])
Isla Simpson -- Principal Investigator ([email protected])
Erik Kluzek -- Software Engineering ([email protected])
Marysa Lague -- Originator ([email protected])
Isla Simpson -- Principal Investigator ([email protected])

Use the help from the wiki below to setup a fork and personal branch in GitHub to put your developments
on and keep up to date with the master branch of SLIM. Once the changes are sufficiently advanced you
can form a Pull Request on GitHub. Either from your fork on GitHub, or from the main ESCOMP GitHub page
for SLIM (be sure to hit the "compare across forks" link at the top of the page when you first create
the pull request).

https://github.com/ESCOMP/SLIM/pulls
https://github.com/ESCOMP/SimpleLand/pulls

This allows you to show your proposed changes and start getting feedback on them (even if they aren't finished).
This also allows your changes to be planned for and slated for a time to come into SLIM master. In most
Expand All @@ -23,7 +23,7 @@ additional testing and bring the changes to SLIM master.

#### SLIM Wiki:

https://github.com/ESCOMP/SLIM/wiki
https://github.com/ESCOMP/SimpleLand/wiki

#### Code of Conduct:

Expand Down
75 changes: 66 additions & 9 deletions Externals.cfg
Original file line number Diff line number Diff line change
@@ -1,32 +1,89 @@
[slm]
local_path = .
protocol = externals_only
externals = Externals_SLIM.cfg
required = True

[cam]
tag = cam_cesm2_1_rel_53
tag = cam6_3_071
protocol = git
repo_url = https://github.com/ESCOMP/CAM
local_path = components/cam
externals = Externals_CAM.cfg
required = True

[cice]
tag = cice5_cesm2_1_1_20190321
[cice6]
tag = cesm_cice6_2_0_22
protocol = git
repo_url = https://github.com/ESCOMP/CESM_CICE5
repo_url = https://github.com/ESCOMP/CESM_CICE
local_path = components/cice
externals = Externals.cfg
required = True

[cice5]
tag = cice5_20220204
protocol = git
repo_url = https://github.com/ESCOMP/CESM_CICE5
local_path = components/cice5
required = True

[ccs_config]
tag = ccs_config_cesm0.0.38
protocol = git
repo_url = https://github.com/ESMCI/ccs_config_cesm.git
local_path = ccs_config
required = True

[cdeps]
tag = cdeps0.12.65
protocol = git
repo_url = https://github.com/ESCOMP/CDEPS
local_path = components/cdeps
externals = Externals_CDEPS.cfg
required = True

[cmeps]
tag = cmeps0.13.71
protocol = git
repo_url = https://github.com/ESCOMP/CMEPS
local_path = components/cmeps
required = True

[cpl7]
tag = cpl7.0.14
protocol = git
repo_url = https://github.com/ESCOMP/CESM_CPL7andDataComps
local_path = components/cpl7
required = True

[share]
tag = share1.0.13
protocol = git
repo_url = https://github.com/ESCOMP/CESM_share
local_path = share
required = True

[mct]
tag = MCT_2.11.0
protocol = git
repo_url = https://github.com/MCSclimate/MCT
local_path = libraries/mct
required = True

[parallelio]
tag = pio2_5_7
protocol = git
repo_url = https://github.com/NCAR/ParallelIO
local_path = libraries/parallelio
required = True

[cime]
local_path = cime
protocol = git
#repo_url = https://github.com/ESMCI/cime
repo_url = https://github.com/ekluzek/cime
hash = 25ba7866ec4835b148aac9f83242d0bc6257da5e
#branch = add_slim_comp
#tag = cime6.0.71
hash = 9bbadb3b173c57f00ff8666790a474951e28391d
required = True

[externals_description]
schema_version = 1.0.0

schema_version = 1.0.01
3 changes: 0 additions & 3 deletions Externals_SLIM.cfg

This file was deleted.

36 changes: 33 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,45 @@ Important files in main directories:
=============================================================================================

Externals.cfg --------------- File for management of the main high level externals
Externals_SLIM.cfg ---------- File for management of the SLIM specific externals (if any)

=============================================================================================
QUICKSTART: using the CPL7 scripts:
Important main subdirectories
=============================================================================================

src --------------- SLIM Source code.
tools ------------- SLIM Offline tools to prepare input datasets and process output.
cime_config ------- Configuration files of cime for compsets and SLIM settings
manage_externals -- Script to manage the external source directories
py_env_create ----- Script to setup the python environment for SLIM python tools using conda
python ------------ Some python modules
components -------- Other active sub-components needed for SLIM to run (CAM and CICE)
libraries --------- CESM libraries: MCT (Model Coupling Toolkit) and PIO
share ------------- CESM shared code

cime/scripts --------------- cesm/cime driver scripts

=============================================================================================
SLIM XML variables:
=============================================================================================

SLIM_SCENARIO: Scenario to use, usually set by the compset
SLIM_START_TYPE: The start type to use, usually set by the RUN_TYPE

=============================================================================================
SLIM important namelist items:
=============================================================================================

mml_surdat -- Dataset of surface characteristics to use (usually set by the compset/grid)
finidat ----- Initial conditions to startup with
hist_nhtfrq - History file frequency of output

=============================================================================================
QUICKSTART: using the CPL7 scripts:
=============================================================================================

cd cime/scripts
./create_newcase # get help on how to run create_newcase
./create_newcase --case testI --res f19_g17 --compset I2000SlimRsGs --mach cheyenne
./create_newcase --case testI --res f19_f19_mg17 --compset I2000SlimRsGs
# create new "I" case for cheyenne_intel at 1.9x2.5_gx1v7 res
# "I2000SlimRsGs" case is SLIM active, datm8, and inactive ice/ocn/glc/rof
cd testI
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Simple Land Model for CESM


For instructions on how to run SLIM on it's own or coupled to CESM on Cheyenne, see the Wiki.
For instructions on how to run SLIM on it's own or coupled to CESM on Cheyenne, see the Wiki, and the README file at the top of the
SLIM checkout.

To cite, please use:

Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
================
SimpleLandModel
================

SLIM the Simple Land Interface Model coupled to CESM2
4 changes: 2 additions & 2 deletions README.testing
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# The test list "aux_slim" is run as a test suite with the "create_test" script under cime/scripts
# as follows.
# NOTE: There are also tests for prealpha, prebeta for use with CESM testing
# And slim_sci to run a few standard tests for SLIM science
#
# Tests on cheyenne

Expand All @@ -24,6 +26,4 @@ nohup ./create_test --compare <baseline_comp> --generate <baseline_generate> mac
nohup ./create_test --compare <baseline_comp> --generate <baseline_generate> machine izumi -r cases \
--xml-category aux_slim --xml-machine izumi --xml-compiler gnu &
nohup ./create_test --compare <baseline_comp> --generate <baseline_generate> machine izumi -r cases \
--xml-category aux_slim --xml-machine izumi --xml-compiler pgi &
nohup ./create_test --compare <baseline_comp> --generate <baseline_generate> machine izumi -r cases \
--xml-category aux_slim --xml-machine izumi --xml-compiler intel &
51 changes: 31 additions & 20 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,88 @@
"""
build slim ibrary
"""
import sys, os, time, filecmp, shutil, imp
import sys, os, time, filecmp

_CIMEROOT = os.environ.get("CIMEROOT")
if _CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")

_LIBDIR = os.path.join(_CIMEROOT, "scripts", "Tools")
_LIBDIR = os.path.join(_CIMEROOT, "CIME", "Tools")
sys.path.append(_LIBDIR)

from standard_script_setup import *
from CIME.buildlib import parse_input
from CIME.build import get_standard_makefile_args
from CIME.case import Case
from CIME.utils import run_cmd, expect

logger = logging.getLogger(__name__)

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

caseroot, libroot, bldroot = parse_input(sys.argv)

with Case(caseroot) as case:

casetools = case.get_value("CASETOOLS")
makefile = os.path.join(casetools, "Makefile")
lnd_root = case.get_value("COMP_ROOT_DIR_LND")
gmake_j = case.get_value("GMAKE_J")
gmake = case.get_value("GMAKE")
mach = case.get_value("MACH")
gmake_opts = get_standard_makefile_args(case)
driver = case.get_value("COMP_INTERFACE").lower()
nthrds = case.get_value("LND_NTHRDS")

if ( nthrds > 1 ):
expect(False, "LND_NTHRDS must be 1 as threading isn't implemented (see issue #14)" )
if nthrds > 1:
expect(
False,
"LND_NTHRDS must be 1 as threading isn't implemented (see issue #14)",
)

#-------------------------------------------------------
# -------------------------------------------------------
# create Filepath file
#-------------------------------------------------------
compname = case.get_value("COMP_LND")
filepath_file = os.path.join(bldroot,"Filepath")
if not os.path.isfile(filepath_file):
caseroot = case.get_value("CASEROOT")
paths = [os.path.join(caseroot,"SourceMods","src.slim"),
expect( (compname == "slim"), "Unexpected COMP_LND name: %s" % (compname))
paths = [os.path.join(caseroot,"SourceMods","src."+compname),
os.path.join(lnd_root,"src","cpl",driver),
os.path.join(lnd_root,"src","main"),
os.path.join(lnd_root,"src","init_interp"),
os.path.join(lnd_root,"src","utils"),
os.path.join(lnd_root,"src","cpl")]

# Paths needed to build the current system, but won't be long term
paths.append( os.path.join(lnd_root,"src","biogeophys") )
paths.append( os.path.join(lnd_root,"src","biogeochem") )
paths.append( os.path.join(lnd_root,"src","soilbiogeochem") )
paths.append(os.path.join(lnd_root, "src", "biogeophys"))
paths.append(os.path.join(lnd_root, "src", "biogeochem"))
paths.append(os.path.join(lnd_root, "src", "soilbiogeochem"))

with open(filepath_file, "w") as filepath:
filepath.write("\n".join(paths))
filepath.write("\n")
#-------------------------------------------------------

# -------------------------------------------------------
# create the library in libroot
#-------------------------------------------------------
# -------------------------------------------------------

complib = os.path.join(libroot,"liblnd.a")
complib = os.path.join(libroot, "liblnd.a")
makefile = os.path.join(casetools, "Makefile")
macfile = os.path.join(caseroot, "Macros.%s" % mach)

cmd = "%s complib -j %d MODEL=slim COMPLIB=%s -f %s MACFILE=%s " \
% (gmake, gmake_j, complib, makefile, macfile )
cmd = "{} complib -j {} COMP_NAME={} COMPLIB={} -f {} {}" \
.format(gmake, gmake_j, compname, complib, makefile, gmake_opts )

rc, out, err = run_cmd(cmd)
logger.info("%s: \n\n output:\n %s \n\n err:\n\n%s\n"%(cmd,out,err))
logger.info("%s: \n\n output:\n %s \n\n err:\n\n%s\n" % (cmd, out, err))
expect(rc == 0, "Command %s failed with rc=%s" % (cmd, rc))


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

if __name__ == "__main__":
logger.warning( "WARNING: buildlib is being called as a program rather than a subroutine as " +
"it is expected to be in the CESM context" )
_main_func()

11 changes: 8 additions & 3 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ SLIM namelist creator executable
"""
import sys, os

_SLIM_PYTHON = os.path.normpath( os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'python') )
_SLIM_PYTHON = os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, "python")
)
sys.path.insert(1, _SLIM_PYTHON)

from slim import add_cime_to_path
Expand All @@ -22,9 +24,12 @@ def _main_func():

caseroot = parse_input(sys.argv)
level = logging.WARNING
setup_logging( level )
setup_logging(level)
with Case(caseroot) as case:
buildnml(case, caseroot, "slim")
compname = case.get_value("COMP_LND")
logger.warning( "WARNING: buildnml is being called as program rather than a subroutine " +
"as it is expected to be in the CESM context" )
buildnml(case, caseroot, compname)


if __name__ == "__main__":
Expand Down
6 changes: 5 additions & 1 deletion cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<entry id="SLIM_SCENARIO">
<type>char</type>
<default_value>global_uniform</default_value>
<valid_values>global_uniform,realistic_from_1850,realistic_from_2000</valid_values>
<valid_values>global_uniform,realistic_from_1850,realistic_from_2000,user_defined</valid_values>
<values>
<value compset="2000.*" >realistic_from_2000</value>
<value compset="1850.*_" >realistic_from_1850</value>
Expand All @@ -40,6 +40,10 @@
<desc>SLIM namelist use_case scenario.
Determines the use-case scenario that will be used in the SLIM buildnml utility.
This is normally set by the component set.
'global_uniform' is for surface conditions are globally constant
'realistic_from_1850' are surface conditions taken from a 1850 control simulation with CTSM
'realistic_from_2000' are surface conditions taken from a 2000 control simulation with CTSM
'user_defined' means the user will provide their own surface condition file (mml_surdat)
</desc>
</entry>

Expand Down
Loading

0 comments on commit 47fe4ce

Please sign in to comment.