53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
|
|
"""
|
|
API for clm's configure
|
|
"""
|
|
|
|
from CIME.XML.standard_module_setup import *
|
|
from CIME.utils import run_cmd_no_fail, expect
|
|
|
|
import glob, shutil
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def buildcpp(case):
|
|
"""
|
|
Invoke clm configure ONLY for clm4_0 - output goes in `caseroot`/Buildconf/camconf
|
|
"""
|
|
|
|
caseroot = case.get_value("CASEROOT")
|
|
cimeroot = case.get_value("CIMEROOT")
|
|
lnd_root = case.get_value("COMP_ROOT_DIR_LND")
|
|
lnd_grid = case.get_value("LND_GRID")
|
|
mask_grid = case.get_value("MASK_GRID")
|
|
clm_usrdat_name = case.get_value("CLM_USRDAT_NAME")
|
|
clm_config_opts = case.get_value("CLM_CONFIG_OPTS")
|
|
compset = case.get_value("COMPSET")
|
|
|
|
if mask_grid == "reg" and lnd_grid != "CLM_USRDAT":
|
|
config_opts = "-sitespf_pt $lnd_grid"
|
|
else:
|
|
config_opts = ""
|
|
|
|
if "1PT" in compset:
|
|
config_opts = " -sitespf_pt reg"
|
|
|
|
clmconf = os.path.join(caseroot, "Buildconf", "clmconf")
|
|
if not os.path.isdir(clmconf):
|
|
os.makedirs(clmconf)
|
|
|
|
cmd = os.path.join(lnd_root,"bld","configure")
|
|
command = "%s -cimeroot %s %s %s -usr_src %s -comp_intf mct " \
|
|
%(cmd, cimeroot, config_opts, clm_config_opts, os.path.join(caseroot,"SourceMods","src.clm"))
|
|
|
|
run_cmd_no_fail(command, from_dir=clmconf)
|
|
|
|
# determine cppdefs - caseroot/clmconf/CESM_cppdefs is created by the call to configure
|
|
with open(os.path.join(clmconf, "CESM_cppdefs"), 'r') as f:
|
|
user_cppdefs = f.readline().rstrip()
|
|
if user_cppdefs:
|
|
case.set_value("CLM_CPPDEFS", user_cppdefs)
|
|
case.flush()
|
|
|
|
return user_cppdefs
|