forked from ESCOMP/WW3-CESM
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
474a179
commit c291051
Showing
1 changed file
with
67 additions
and
31 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 |
---|---|---|
@@ -1,31 +1,67 @@ | ||
#! /usr/bin/env perl | ||
use strict; | ||
|
||
if ($#ARGV == -1) { | ||
die " ERROR ww3 buildlib: must specify a caseroot input argument"; | ||
} | ||
my ($CASEROOT) = @ARGV; | ||
chdir "${CASEROOT}"; | ||
|
||
my $CASEROOT = `./xmlquery CASEROOT --value`; | ||
my $CASETOOLS = `./xmlquery CASETOOLS --value`; | ||
my $SRCROOT = `./xmlquery SRCROOT --value`; | ||
my $MACH = `./xmlquery MACH --value`; | ||
my $OBJROOT = `./xmlquery OBJROOT --value`; | ||
my $LIBROOT = `./xmlquery LIBROOT --value`; | ||
my $GMAKE_J = `./xmlquery GMAKE_J --value`; | ||
my $GMAKE = `./xmlquery GMAKE --value`; | ||
|
||
chdir "$OBJROOT/wav/obj"; | ||
|
||
open(file,">Filepath") or die "Could not open file Filepath to write"; | ||
print file "${CASEROOT}/SourceMods/src.ww3\n"; | ||
print file "${SRCROOT}/components/ww3/src/source\n"; | ||
print file "${SRCROOT}/components/ww3/src/cpl_share\n"; | ||
print file "${SRCROOT}/components/ww3/src/cpl_mct\n"; | ||
close(file); | ||
|
||
my $sysmod = "$GMAKE complib -j $GMAKE_J MODEL=ww3 COMPLIB=$LIBROOT/libwav.a -f $CASETOOLS/Makefile MACFILE=$CASEROOT/Macros.$MACH"; | ||
system($sysmod) == 0 or die "ERROR: $sysmod failed: $?\n"; | ||
|
||
exit(0); | ||
#!/usr/bin/env python | ||
|
||
""" | ||
build ww3 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") | ||
wav_root = case.get_value("COMP_ROOT_DIR_WAV") | ||
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.ww3"), | ||
os.path.join(wav_root,"src","source"), | ||
os.path.join(wav_root,"src","cpl_share"), | ||
os.path.join(wav_root,"src","cpl_mct")] | ||
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,"libwav.a") | ||
makefile = os.path.join(casetools, "Makefile") | ||
|
||
cmd = "{} complib -j {} MODEL=ww3 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() |