Skip to content

Commit

Permalink
Merge pull request #1988 from ESMCI/jgfouca/add_driver_selection_support
Browse files Browse the repository at this point in the history
Add support for selecting different driver.

Add --driver flag to create_newcase
Add support for V$driver test opt to create_test
Remove places where mct was hardcoded
Add support for driver selection to case.configure, case.create
Lots of XML changes will be needed in the models to truly support
different drivers. This PR just removes the core infrastructure as
blocker for this effort.

Test suite: scripts_regression_tests
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1781

User interface changes?: Yes, --driver added to create_newcase, new _V$driver testopt

Update gh-pages html (Y/N)?: N

Code review: @jedwards4b @mvertens
  • Loading branch information
jgfouca authored Oct 30, 2017
2 parents 33597f4 + 32ab3e5 commit f99c174
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
9 changes: 6 additions & 3 deletions scripts/create_newcase
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ OR
parser.add_argument("-i", "--input-dir",
help="Use a non-default location for input files")

parser.add_argument("--driver",
help="Select a driver. No selection implies mct driver")

args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.srcroot is not None:
Expand Down Expand Up @@ -162,7 +165,7 @@ OR
args.user_mods_dir, args.pesfile, \
args.user_grid, args.gridfile, args.srcroot, args.test, args.multi_driver, \
args.ninst, args.walltime, args.queue, args.output_root, args.script_root, \
run_unsupported, args.answer, args.input_dir
run_unsupported, args.answer, args.input_dir, args.driver

###############################################################################
def _main_func(description):
Expand All @@ -174,7 +177,7 @@ def _main_func(description):
user_mods_dir, pesfile, \
user_grid, gridfile, srcroot, test, multi_driver, ninst, walltime, \
queue, output_root, script_root, run_unsupported, \
answer, input_dir = parse_command_line(sys.argv, cimeroot, description)
answer, input_dir, driver = parse_command_line(sys.argv, cimeroot, description)

if script_root is None:
caseroot = os.path.abspath(casename)
Expand All @@ -199,7 +202,7 @@ def _main_func(description):
multi_driver=multi_driver, ninst=ninst, test=test,
walltime=walltime, queue=queue, output_root=output_root,
run_unsupported=run_unsupported, answer=answer,
input_dir=input_dir)
input_dir=input_dir, driver=driver)

###############################################################################

Expand Down
20 changes: 10 additions & 10 deletions scripts/lib/CIME/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

###############################################################################
def _build_model(build_threaded, exeroot, clm_config_opts, incroot, complist,
lid, caseroot, cimeroot, compiler, buildlist):
lid, caseroot, cimeroot, compiler, buildlist, comp_interface):
###############################################################################
logs = []

Expand Down Expand Up @@ -79,7 +79,7 @@ def _build_model(build_threaded, exeroot, clm_config_opts, incroot, complist,
cime_model = get_model()
file_build = os.path.join(exeroot, "{}.bldlog.{}".format(cime_model, lid))

config_dir = os.path.join(cimeroot, "src", "drivers", "mct", "cime_config")
config_dir = os.path.join(cimeroot, "src", "drivers", comp_interface, "cime_config")
f = open(file_build, "w")
bldroot = os.path.join(exeroot, "cpl", "obj")
if not os.path.isdir(bldroot):
Expand Down Expand Up @@ -206,7 +206,7 @@ def _build_checks(case, build_threaded, comp_interface, use_esmf_lib,
return sharedpath

###############################################################################
def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid, compiler, buildlist):
def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid, compiler, buildlist, comp_interface):
###############################################################################

shared_lib = os.path.join(exeroot, sharedpath, "lib")
Expand All @@ -215,7 +215,7 @@ def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid
if (not os.path.exists(shared_item)):
os.makedirs(shared_item)
mpilib = case.get_value("MPILIB")
libs = ["gptl", "mct", "pio", "csm_share"]
libs = ["gptl", comp_interface, "pio", "csm_share"]
if mpilib == "mpi-serial":
libs.insert(0, mpilib)
logs = []
Expand All @@ -228,7 +228,7 @@ def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid
# csm_share adds its own dir name
full_lib_path = os.path.join(sharedlibroot, sharedpath)
elif lib == "mpi-serial":
full_lib_path = os.path.join(sharedlibroot, sharedpath, "mct", lib)
full_lib_path = os.path.join(sharedlibroot, sharedpath, comp_interface, lib)
else:
full_lib_path = os.path.join(sharedlibroot, sharedpath, lib)
# pio build creates its own directory
Expand Down Expand Up @@ -261,9 +261,9 @@ def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid
if comp_lnd == "clm" and "clm4_0" not in clm_config_opts:
logging.info(" - Building clm4_5/clm5_0 Library ")
esmfdir = "esmf" if case.get_value("USE_ESMF_LIB") else "noesmf"
bldroot = os.path.join(sharedlibroot, sharedpath, case.get_value("COMP_INTERFACE"), esmfdir, "clm","obj" )
libroot = os.path.join(exeroot, sharedpath, case.get_value("COMP_INTERFACE"), esmfdir, "lib")
incroot = os.path.join(exeroot, sharedpath, case.get_value("COMP_INTERFACE"), esmfdir, "include")
bldroot = os.path.join(sharedlibroot, sharedpath, comp_interface, esmfdir, "clm","obj" )
libroot = os.path.join(exeroot, sharedpath, comp_interface, esmfdir, "lib")
incroot = os.path.join(exeroot, sharedpath, comp_interface, esmfdir, "include")
file_build = os.path.join(exeroot, "lnd.bldlog.{}".format( lid))
config_lnd_dir = os.path.dirname(case.get_value("CONFIG_LND_FILE"))

Expand Down Expand Up @@ -513,12 +513,12 @@ def _case_build_impl(caseroot, case, sharedlib_only, model_only, buildlist):

if not model_only:
logs = _build_libraries(case, exeroot, sharedpath, caseroot,
cimeroot, libroot, lid, compiler, buildlist)
cimeroot, libroot, lid, compiler, buildlist, comp_interface)

if not sharedlib_only:
os.environ["INSTALL_SHAREDPATH"] = os.path.join(exeroot, sharedpath) # for MPAS makefile generators
logs.extend(_build_model(build_threaded, exeroot, clm_config_opts, incroot, complist,
lid, caseroot, cimeroot, compiler, buildlist))
lid, caseroot, cimeroot, compiler, buildlist, comp_interface))

if not buildlist:
# in case component build scripts updated the xml files, update the case object
Expand Down
3 changes: 2 additions & 1 deletion scripts/lib/CIME/buildlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ def parse_input(argv):

def build_cime_component_lib(case, compname, libroot, bldroot):
cimeroot = case.get_value("CIMEROOT")
comp_interface = case.get_value("COMP_INTERFACE")
compclass = compname[1:]

with open(os.path.join(bldroot,'Filepath'), 'w') as out:
out.write(os.path.join(case.get_value('CASEROOT'), "SourceMods",
"src.{}\n".format(compname)) + "\n")
if compname.startswith('d'):
out.write(os.path.join(cimeroot, "src", "components", "data_comps", compname, "mct") + "\n")
out.write(os.path.join(cimeroot, "src", "components", "data_comps", compname, comp_interface) + "\n")
out.write(os.path.join(cimeroot, "src", "components", "data_comps", compname) + "\n")
elif compname.startswith('x'):
out.write(os.path.join(cimeroot, "src", "components", "xcpl_comps", "xshare") + "\n")
Expand Down
10 changes: 7 additions & 3 deletions scripts/lib/CIME/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,13 @@ def configure(self, compset_name, grid_name, machine_name=None,
multi_driver=False, ninst=1, test=False,
walltime=None, queue=None, output_root=None,
run_unsupported=False, answer=None,
input_dir=None):
input_dir=None, driver=None):

expect(check_name(compset_name, additional_chars='.'), "Invalid compset name {}".format(compset_name))

if driver:
self.set_lookup_value("COMP_INTERFACE", driver)

#--------------------------------------------
# compset, pesfile, and compset components
#--------------------------------------------
Expand Down Expand Up @@ -1406,7 +1410,7 @@ def create(self, casename, srcroot, compset_name, grid_name,
multi_driver=False, ninst=1, test=False,
walltime=None, queue=None, output_root=None,
run_unsupported=False, answer=None,
input_dir=None):
input_dir=None, driver=None):
try:
# Set values for env_case.xml
self.set_lookup_value("CASE", os.path.basename(casename))
Expand All @@ -1422,7 +1426,7 @@ def create(self, casename, srcroot, compset_name, grid_name,
walltime=walltime, queue=queue,
output_root=output_root,
run_unsupported=run_unsupported, answer=answer,
input_dir=input_dir)
input_dir=input_dir, driver=driver)

self.create_caseroot()

Expand Down
34 changes: 13 additions & 21 deletions scripts/lib/CIME/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,22 @@ def _create_newcase_phase(self, test):
mpilib = case_opt[1:]
create_newcase_cmd += " --mpilib {}".format(mpilib)
logger.debug (" MPILIB set to {}".format(mpilib))
if case_opt.startswith('N'):
elif case_opt.startswith('N'):
expect(ncpl == 1,"Cannot combine _C and _N options")
ninst = case_opt[1:]
create_newcase_cmd += " --ninst {}".format(ninst)
logger.debug (" NINST set to {}".format(ninst))
if case_opt.startswith('C'):
elif case_opt.startswith('C'):
expect(ninst == 1,"Cannot combine _C and _N options")
ncpl = case_opt[1:]
create_newcase_cmd += " --ninst {} --multi-driver" .format(ncpl)
logger.debug (" NCPL set to {}" .format(ncpl))
if case_opt.startswith('P'):
elif case_opt.startswith('P'):
pesize = case_opt[1:]
create_newcase_cmd += " --pecount {}".format(pesize)
elif case_opt.startswith('V'):
driver = case_opt[1:]
create_newcase_cmd += " --driver {}".format(driver)

# create_test mpilib option overrides default but not explicitly set case_opt mpilib
if mpilib is None and self._mpilib is not None:
Expand Down Expand Up @@ -547,24 +550,13 @@ def _xml_phase(self, test):
# envtest.set_test_parameter("PTS_LAT", "36.6")
# envtest.set_test_parameter("PTS_LON", "262.5")

elif opt.startswith('I'):
# Marker to distinguish tests with same name - ignored
continue

elif opt.startswith('M'):
# M option handled by create newcase
continue

elif opt.startswith('P'):
# P option handled by create newcase
continue

elif opt.startswith('N'):
# handled in create_newcase
continue
elif opt.startswith('C'):
# handled in create_newcase
continue
elif (opt.startswith('I') or # Marker to distinguish tests with same name - ignored
opt.startswith('M') or # handled in create_newcase
opt.startswith('P') or # handled in create_newcase
opt.startswith('N') or # handled in create_newcase
opt.startswith('C') or # handled in create_newcase
opt.startswith('V')): # handled in create_newcase
pass
elif opt.startswith('IOP'):
logger.warning("IOP test option not yet implemented")
else:
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/mct/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@

<entry id="COMP_INTERFACE">
<type>char</type>
<valid_values>mct</valid_values>
<valid_values>mct,nuopc</valid_values>
<default_value>mct</default_value>
<group>build_def</group>
<file>env_build.xml</file>
Expand Down

0 comments on commit f99c174

Please sign in to comment.