-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit to use cmeps as a standalone component
- Loading branch information
1 parent
34580e4
commit 4aad25c
Showing
76 changed files
with
35,848 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
build model executable | ||
""" | ||
|
||
import sys, os | ||
|
||
_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","cime") | ||
sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) | ||
|
||
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 expect, run_cmd | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
############################################################################### | ||
def _main_func(): | ||
############################################################################### | ||
|
||
caseroot, _, _ = parse_input(sys.argv) | ||
|
||
logger.info("Building a single executable version of target coupled model") | ||
|
||
with Case(caseroot) as case: | ||
casetools = case.get_value("CASETOOLS") | ||
cimeroot = case.get_value("CIMEROOT") | ||
exeroot = case.get_value("EXEROOT") | ||
gmake = case.get_value("GMAKE") | ||
gmake_j = case.get_value("GMAKE_J") | ||
model = case.get_value("MODEL") | ||
num_esp = case.get_value("NUM_COMP_INST_ESP") | ||
ocn_model = case.get_value("COMP_OCN") | ||
atm_model = case.get_value("COMP_ATM") | ||
comp_cpl = case.get_value("COMP_ROOT_DIR_CPL") | ||
gmake_args = get_standard_makefile_args(case) | ||
|
||
if ocn_model == 'mom' or atm_model == "fv3gfs": | ||
gmake_args += "USE_FMS=TRUE" | ||
|
||
expect((num_esp is None) or (int(num_esp) == 1), "ESP component restricted to one instance") | ||
|
||
with open('Filepath', 'w') as out: | ||
out.write(os.path.join(caseroot, "SourceMods", "src.drv") + "\n") | ||
out.write(os.path.join(comp_cpl, "src", "drivers", "cime") + "\n") | ||
out.write(os.path.join(comp_cpl, "src", "exch_flds") + "\n") | ||
out.write(os.path.join(comp_cpl, "src", "mediator") + "\n") | ||
|
||
# build model executable | ||
|
||
makefile = os.path.join(casetools, "Makefile") | ||
exename = os.path.join(exeroot, model + ".exe") | ||
# always relink | ||
if os.path.isfile(exename): | ||
os.remove(exename) | ||
|
||
cmd = "{} exec_se -j {} EXEC_SE={} MODEL=driver {} -f {} "\ | ||
.format(gmake, gmake_j, exename, gmake_args, makefile) | ||
|
||
rc, out, err = run_cmd(cmd) | ||
expect(rc==0,"Command {} failed rc={}\nout={}\nerr={}".format(cmd,rc,out,err)) | ||
logger.info(out) | ||
|
||
############################################################################### | ||
|
||
if __name__ == "__main__": | ||
_main_func() |
Oops, something went wrong.