From 7a520f599f24e879fed20d1b2b74f08e3c6bf20f Mon Sep 17 00:00:00 2001 From: Sean Patrick Santos Date: Wed, 24 Aug 2016 11:26:08 -0600 Subject: [PATCH] Change how `configure` gets compiler/mpilib/debug. These are now passed in via environment variables, or set using the machine default, rather than using a `--shell-opts` argument. --- tools/configure | 82 +++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/tools/configure b/tools/configure index 083e6c7009f6..db4926f37585 100755 --- a/tools/configure +++ b/tools/configure @@ -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) @@ -51,15 +57,6 @@ 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) @@ -67,14 +64,16 @@ The pieces of information that will be written include: 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: @@ -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 @@ -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__":