forked from CMCC-Foundation/cime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildlib.mpi-serial
executable file
·104 lines (77 loc) · 3.21 KB
/
buildlib.mpi-serial
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
import os, sys, logging, argparse
from standard_script_setup import *
from CIME import utils
from CIME.config import Config
from CIME.utils import copyifnewer, run_bld_cmd_ensure_logging
from CIME.case import Case
from CIME.build import get_standard_makefile_args
import glob
logger = logging.getLogger(__name__)
def parse_command_line(args, description):
###############################################################################
parser = argparse.ArgumentParser(
usage="""\n{0} [--debug]
OR
{0} --verbose
OR
{0} --help
\033[1mEXAMPLES:\033[0m
\033[1;32m# Run \033[0m
> {0}
""".format(
os.path.basename(args[0])
),
description=description,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
utils.setup_standard_logging_options(parser)
parser.add_argument("buildroot", help="build path root")
parser.add_argument("installpath", help="install path ")
parser.add_argument(
"caseroot", nargs="?", default=os.getcwd(), help="Case directory to build"
)
args = utils.parse_args_and_handle_standard_logging_options(args, parser)
return args.buildroot, args.installpath, args.caseroot
def buildlib(bldroot, installpath, case):
###############################################################################
caseroot = case.get_value("CASEROOT")
srcroot = case.get_value("SRCROOT")
customize_path = os.path.join(srcroot, "cime_config", "customize")
config = Config.load(customize_path)
mct_path = config.mct_path.format(srcroot=srcroot)
for _file in glob.iglob(os.path.join(mct_path, "mpi-serial", "*.h")):
copyifnewer(_file, os.path.join(bldroot, os.path.basename(_file)))
gmake_opts = "-f {} ".format(os.path.join(caseroot, "Tools", "Makefile"))
gmake_opts += " -C {} ".format(bldroot)
gmake_opts += " {} ".format(get_standard_makefile_args(case, shared_lib=True))
gmake_opts += "COMP_NAME=mpi-serial {}".format(
os.path.join(bldroot, "Makefile.conf")
)
gmake_cmd = case.get_value("GMAKE")
# This runs the mpi-serial configure command
cmd = "{} {}".format(gmake_cmd, gmake_opts)
run_bld_cmd_ensure_logging(cmd, logger)
# Now we run the mpi-serial make command
gmake_opts = "-f {} ".format(os.path.join(mct_path, "mpi-serial", "Makefile"))
gmake_opts += " -C {} ".format(bldroot)
gmake_opts += " -j {} ".format(case.get_value("GMAKE_J"))
gmake_opts += " SRCDIR={} ".format(os.path.join(mct_path))
cmd = "{} {}".format(gmake_cmd, gmake_opts)
run_bld_cmd_ensure_logging(cmd, logger)
copyifnewer(
os.path.join(bldroot, "libmpi-serial.a"),
os.path.join(installpath, "lib", "libmpi-serial.a"),
)
for _file in ("mpi.h", "mpif.h", "mpi.mod", "MPI.mod"):
if os.path.isfile(os.path.join(bldroot, _file)):
copyifnewer(
os.path.join(bldroot, _file),
os.path.join(installpath, "include", _file),
)
def _main(argv, documentation):
bldroot, installpath, caseroot = parse_command_line(argv, documentation)
with Case(caseroot) as case:
buildlib(bldroot, installpath, case)
if __name__ == "__main__":
_main(sys.argv, __doc__)