forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildlib
executable file
·77 lines (61 loc) · 2.99 KB
/
buildlib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
"""
build clm library
"""
import sys, os
_CIMEROOT = os.environ.get("CIMEROOT")
if _CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
_LIBDIR = os.path.join(_CIMEROOT, "scripts", "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")
lnd_root = case.get_value("COMP_ROOT_DIR_LND")
gmake_j = case.get_value("GMAKE_J")
gmake = case.get_value("GMAKE")
#-------------------------------------------------------
# create Filepath file
#-------------------------------------------------------
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.clm"),
os.path.join(lnd_root,"src","main"),
os.path.join(lnd_root,"src","biogeophys"),
os.path.join(lnd_root,"src","biogeochem"),
os.path.join(lnd_root,"src","soilbiogeochem"),
os.path.join(lnd_root,"src","dyn_subgrid"),
os.path.join(lnd_root,"src","init_interp"),
os.path.join(lnd_root,"src","fates"),
os.path.join(lnd_root,"src","fates","main"),
os.path.join(lnd_root,"src","fates","biogeophys"),
os.path.join(lnd_root,"src","fates","biogeochem"),
os.path.join(lnd_root,"src","fates","fire"),
os.path.join(lnd_root,"src","utils"),
os.path.join(lnd_root,"src","cpl")]
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,"libclm.a")
makefile = os.path.join(casetools, "Makefile")
cmd = "{} complib -j {} MODEL=clm COMPLIB={} -f {} {}" \
.format(gmake, gmake_j, complib, makefile, get_standard_makefile_args(case))
rc, out, err = run_cmd(cmd)
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__":
_main_func()