Skip to content

Commit

Permalink
Change how configure gets compiler/mpilib/debug.
Browse files Browse the repository at this point in the history
These are now passed in via environment variables, or set using the
machine default, rather than using a `--shell-opts` argument.
  • Loading branch information
quantheory committed Aug 25, 2016
1 parent 324339d commit 7a520f5
Showing 1 changed file with 49 additions and 33 deletions.
82 changes: 49 additions & 33 deletions tools/configure
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ The pieces of information that will be written include:
1. Machine-specific build settings (i.e. the "Macros" file).
2. File-specific build settings (i.e. "Depends" files).
3. Environment variable loads (i.e. the env_mach_specific file).
3. Environment variable loads (i.e. the env_mach_specific files).
The .env_mach_specific.sh and .env_mach_specific.csh files are specific to a
given compiler, MPI library, and DEBUG setting. By default, these will be the
machine's default compiler, the machine's default MPI library, and FALSE,
respectively. These can be changed by setting the environment variables
COMPILER, MPILIB, and DEBUG, respectively.
"""
parser = argparse.ArgumentParser(description=description)
CIME.utils.setup_standard_logging_options(parser)
Expand All @@ -51,30 +57,23 @@ The pieces of information that will be written include:
parser.add_argument("--output-dir", default=os.getcwd(),
help="The directory to write files to. If not "
"specified, defaults to the current working directory.")
parser.add_argument("--shell-opts",
help="Specification of the build configuration to "
"generate env_mach_specific shell scripts for. This "
"should be of the form COMPILER,MPILIB,DEBUG. "
"For example, 'intel,mpich2,true' is a valid setting "
"for this option, as long as ICC and MPICH2 are "
"available on this machine. If this option is not "
"specified, only the XML file is generated (mainly for "
"documentation/testing), with no shell scripts.")

args = parser.parse_args()
CIME.utils.handle_standard_logging_options(args)

opts = {}
if args.machines_dir is not None:
machines_file = os.path.join(args.machines_dir, "config_machines.xml")
opts['machobj'] = Machines(infile=machines_file, machine=args.machine)
machobj = Machines(infile=machines_file, machine=args.machine)
else:
if os.environ.get('CIME_MODEL') is not None:
opts['machobj'] = Machines(machine=args.machine)
machobj = Machines(machine=args.machine)
else:
expect(False, "Either --mach-dir or the CIME_MODEL environment "
"variable must be specified!")

opts['machobj'] = machobj

if args.macros_format is None:
opts['macros_format'] = []
else:
Expand All @@ -85,23 +84,38 @@ The pieces of information that will be written include:

opts['output_dir'] = args.output_dir

if args.shell_opts is not None:
compiler, mpilib, debug = tuple(args.shell_opts.split(","))
expect(opts['machobj'].is_valid_compiler(compiler),
"Invalid compiler vender passed in --shell-opts: %s" % compiler)
opts['compiler'] = compiler
expect(opts['machobj'].is_valid_MPIlib(mpilib),
"Invalid MPI library name passed in --shell-opts: %s" % mpilib)
opts['mpilib'] = mpilib
debug_normed = debug.lower()
if debug_normed == "true":
opts['debug'] = True
elif debug_normed == "false":
opts['debug'] = False
else:
expect(False,
"Invalid DEBUG value passed in --shell-opts "
"(must be true or false): %s" % debug)
# Set compiler.
if "COMPILER" in os.environ:
compiler = os.environ["COMPILER"]
else:
compiler = machobj.get_default_compiler()
os.environ["COMPILER"] = compiler
expect(opts['machobj'].is_valid_compiler(compiler),
"Invalid compiler vendor given in COMPILER environment variable: %s"
% compiler)
opts['compiler'] = compiler

# Set MPI library.
if "MPILIB" in os.environ:
mpilib = os.environ["MPILIB"]
else:
mpilib = machobj.get_default_MPIlib()
os.environ["MPILIB"] = mpilib
expect(opts['machobj'].is_valid_MPIlib(mpilib),
"Invalid MPI library name given in MPILIB environment variable: %s" %
mpilib)
opts['mpilib'] = mpilib

# Set DEBUG flag.
if "DEBUG" in os.environ:
expect(os.environ["DEBUG"].lower() in ('true', 'false'),
"Invalid DEBUG environment variable value (must be 'TRUE' or "
"'FALSE'): %s" % os.environ["DEBUG"])
debug = os.environ["DEBUG"].lower() == "true"
else:
debug = False
os.environ["DEBUG"] = "FALSE"
opts['debug'] = debug

return opts

Expand Down Expand Up @@ -133,13 +147,15 @@ def _main():
shutil.copy(compiler_depends, output_dir)

# env_mach_specific generation.
ems_path = os.path.join(output_dir, "env_mach_specific.xml")
if os.path.exists(ems_path):
os.remove(ems_path)
ems_file = EnvMachSpecific(output_dir)
ems_file.populate(machobj)
ems_file.write()
if 'compiler' in opts:
for shell in ('sh', 'csh'):
ems_file.make_env_mach_specific_file(opts['compiler'], opts['debug'],
opts['mpilib'], shell)
for shell in ('sh', 'csh'):
ems_file.make_env_mach_specific_file(opts['compiler'], opts['debug'],
opts['mpilib'], shell)


if __name__ == "__main__":
Expand Down

0 comments on commit 7a520f5

Please sign in to comment.