-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backed out changes to buildlib and buildcpp
- Loading branch information
Showing
4 changed files
with
224 additions
and
75 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
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
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,104 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
build blom library | ||
""" | ||
import os, shutil, sys, glob, imp | ||
|
||
_CIMEROOT = os.environ.get("CIMEROOT") | ||
if _CIMEROOT is None: | ||
raise SystemExit("ERROR: must set CIMEROOT environment variable") | ||
sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) | ||
|
||
from standard_script_setup import * | ||
|
||
from CIME.case import Case | ||
from CIME.utils import run_cmd, expect | ||
from CIME.buildlib import parse_input | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
############################################################################### | ||
def _main_func(): | ||
############################################################################### | ||
|
||
caseroot, libroot, bldroot = parse_input(sys.argv) | ||
|
||
with Case(caseroot, read_only=False) as case: | ||
|
||
comp_root_dir_ocn = case.get_value("COMP_ROOT_DIR_OCN") | ||
|
||
# call buildcpp to set the cppdefs | ||
cmd = os.path.join(os.path.join(comp_root_dir_ocn, "cime_config", "buildcpp")) | ||
logger.info(" ...calling blom buildcpp to set build time options") | ||
try: | ||
mod = imp.load_source("buildcpp", cmd) | ||
blom_cppdefs = mod.buildcpp(case) | ||
except: | ||
raise | ||
|
||
with Case(caseroot) as case: | ||
|
||
casetools = case.get_value("CASETOOLS") | ||
complib = os.path.join(libroot, "libocn.a") | ||
gmake_j = case.get_value("GMAKE_J") | ||
gmake = case.get_value("GMAKE") | ||
makefile = os.path.join(casetools, "Makefile") | ||
|
||
# create Filepath file | ||
|
||
filepath_file = os.path.join(bldroot, "Filepath") | ||
|
||
if not os.path.isfile(filepath_file): | ||
|
||
objroot = case.get_value("OBJROOT") | ||
comp_root_dir_ocn = case.get_value("COMP_ROOT_DIR_OCN") | ||
turbclo = case.get_value("BLOM_TURBULENT_CLOSURE") | ||
tracers = case.get_value("BLOM_TRACER_MODULES") | ||
driver = case.get_value("COMP_INTERFACE") | ||
|
||
paths = [os.path.join(caseroot, "SourceMods", "src.blom"), | ||
os.path.join(objroot, "ocn", "src"), | ||
os.path.join(comp_root_dir_ocn, "ben02"), | ||
os.path.join(comp_root_dir_ocn, "cesm"), | ||
os.path.join(comp_root_dir_ocn, "fuk95"), | ||
os.path.join(comp_root_dir_ocn, "channel"), | ||
os.path.join(comp_root_dir_ocn, "single_column"), | ||
os.path.join(comp_root_dir_ocn, "pkgs", "CVMix-src", "src", "shared"), | ||
os.path.join(comp_root_dir_ocn, "pkgs", "M4AGO-sinking-scheme", "src"), | ||
os.path.join(comp_root_dir_ocn, "phy")] | ||
|
||
if turbclo != 0 and tracers != 0: | ||
paths.append(os.path.join(comp_root_dir_ocn, "trc")) | ||
|
||
if tracers != 0: | ||
for module in tracers.split(): | ||
if module == "iage": | ||
paths.append(os.path.join(comp_root_dir_ocn, "idlage")) | ||
elif module == "ecosys": | ||
paths.append(os.path.join(comp_root_dir_ocn, "hamocc")) | ||
else: | ||
expect(False, "tracer module {} is not recognized".format(module)) | ||
|
||
expect(driver != "nuopc", "NUOPC driver not supported") | ||
if driver == "mct": | ||
paths.append(os.path.join(comp_root_dir_ocn, "drivers", "mct")) | ||
|
||
with open(filepath_file, "w") as filepath: | ||
filepath.write("\n".join(paths)) | ||
filepath.write("\n") | ||
|
||
# build the library | ||
|
||
cmd = "{} complib -j {} MODEL=blom COMPLIB={} -f {} USER_CPPDEFS=\"{}\"" \ | ||
.format(gmake, gmake_j, complib, makefile, blom_cppdefs) | ||
|
||
rc, out, err = run_cmd(cmd, from_dir=bldroot) | ||
expect(rc == 0, "Command %s failed rc=%d\nout=%s\nerr=%s" % (cmd, rc, out, err)) | ||
|
||
logger.info("Command %s completed with output %s\nerr %s", cmd, out, err) | ||
|
||
############################################################################### | ||
|
||
if __name__ == "__main__": | ||
_main_func() |
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,107 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
build blom library | ||
""" | ||
import os, shutil, sys, glob, imp | ||
|
||
_CIMEROOT = os.environ.get("CIMEROOT") | ||
if _CIMEROOT is None: | ||
raise SystemExit("ERROR: must set CIMEROOT environment variable") | ||
sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) | ||
|
||
from standard_script_setup import * | ||
|
||
from CIME.case import Case | ||
from CIME.utils import run_cmd, expect | ||
from CIME.buildlib import parse_input | ||
from CIME.build import get_standard_makefile_args | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
############################################################################### | ||
def _main_func(): | ||
############################################################################### | ||
|
||
caseroot, libroot, bldroot = parse_input(sys.argv) | ||
|
||
with Case(caseroot, read_only=False) as case: | ||
|
||
comp_root_dir_ocn = case.get_value("COMP_ROOT_DIR_OCN") | ||
|
||
# call buildcpp to set the cppdefs | ||
cmd = os.path.join(os.path.join(comp_root_dir_ocn, "cime_config", "buildcpp")) | ||
logger.info(" ...calling blom buildcpp to set build time options") | ||
try: | ||
mod = imp.load_source("buildcpp", cmd) | ||
blom_cppdefs = mod.buildcpp(case) | ||
except: | ||
raise | ||
|
||
with Case(caseroot) as case: | ||
|
||
casetools = case.get_value("CASETOOLS") | ||
complib = os.path.join(libroot, "libocn.a") | ||
gmake_j = case.get_value("GMAKE_J") | ||
gmake = case.get_value("GMAKE") | ||
makefile = os.path.join(casetools, "Makefile") | ||
|
||
# create Filepath file | ||
|
||
filepath_file = os.path.join(bldroot, "Filepath") | ||
|
||
if not os.path.isfile(filepath_file): | ||
|
||
objroot = case.get_value("OBJROOT") | ||
comp_root_dir_ocn = case.get_value("COMP_ROOT_DIR_OCN") | ||
turbclo = case.get_value("BLOM_TURBULENT_CLOSURE") | ||
tracers = case.get_value("BLOM_TRACER_MODULES") | ||
driver = case.get_value("COMP_INTERFACE") | ||
|
||
paths = [os.path.join(caseroot, "SourceMods", "src.blom"), | ||
os.path.join(objroot, "ocn", "src"), | ||
os.path.join(comp_root_dir_ocn, "ben02"), | ||
os.path.join(comp_root_dir_ocn, "cesm"), | ||
os.path.join(comp_root_dir_ocn, "fuk95"), | ||
os.path.join(comp_root_dir_ocn, "channel"), | ||
os.path.join(comp_root_dir_ocn, "single_column"), | ||
os.path.join(comp_root_dir_ocn, "pkgs", "CVMix-src", "src", "shared"), | ||
os.path.join(comp_root_dir_ocn, "phy"), | ||
os.path.join(comp_root_dir_ocn, "trc"), | ||
os.path.join(comp_root_dir_ocn, "idlage")] | ||
|
||
if tracers != 0: | ||
for module in tracers.split(): | ||
if module == "iage": | ||
continue | ||
elif module == "ecosys": | ||
paths.append(os.path.join(comp_root_dir_ocn, "hamocc")) | ||
paths.append(os.path.join(comp_root_dir_ocn, "pkgs", "M4AGO-sinking-scheme", "src")) | ||
else: | ||
expect(False, "tracer module {} is not recognized".format(module)) | ||
|
||
if driver == "mct": | ||
paths.append(os.path.join(comp_root_dir_ocn, "drivers", "mct")) | ||
elif driver == "nuopc": | ||
paths.append(os.path.join(comp_root_dir_ocn, "drivers", "nuopc")) | ||
else: | ||
expect(False, "Driver {} is not supported".format(driver)) | ||
|
||
with open(filepath_file, "w") as filepath: | ||
filepath.write("\n".join(paths)) | ||
filepath.write("\n") | ||
|
||
# build the library | ||
|
||
cmd = "{} complib -j {} MODEL=blom COMPLIB={} -f {} USER_CPPDEFS=\"{}\" {} " \ | ||
.format(gmake, gmake_j, complib, makefile, blom_cppdefs, get_standard_makefile_args(case)) | ||
|
||
rc, out, err = run_cmd(cmd, from_dir=bldroot) | ||
expect(rc == 0, "Command %s failed rc=%d\nout=%s\nerr=%s" % (cmd, rc, out, err)) | ||
|
||
logger.info("Command %s completed with output %s\nerr %s", cmd, out, err) | ||
|
||
############################################################################### | ||
|
||
if __name__ == "__main__": | ||
_main_func() |