Skip to content

Commit

Permalink
Merge pull request #1268 from jedwards4b/configure_update
Browse files Browse the repository at this point in the history
add mpilib and compiler options to configure, update Readme.configure
Add mpilib and compiler command line options to configure

Test suite: hand tested on hobart building map_field tool
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1981

User interface changes?:

Code review: @mnlevy1981
  • Loading branch information
jedwards4b authored Mar 24, 2017
2 parents 9759e15 + 8c74859 commit 4e125ee
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 30 deletions.
74 changes: 49 additions & 25 deletions tools/Readme.configure
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@
SYNOPSIS
configure [options]
OPTIONS
User supplied values are denoted in angle brackets (<>). Any value that contains
white-space must be quoted. Long option names may be supplied with either single
or double leading dashes. A consequence of this is that single letter options may
NOT be bundled.
usage: configure [-h] [-d] [-v] [-s] [--machine MACHINE]
[--machines-dir MACHINES_DIR]
[--macros-format {Makefile,CMake}] [--output-dir OUTPUT_DIR]
[--compiler COMPILER] [--mpilib MPILIB]

-cimeroot Specify the toplevel cime directory.
default: use CIMEROOT environment variable
-mach <name> Specify a machine (required).
-compiler <name> Specify a compiler for the target machine (optional)
default: default compiler for the target machine
-mpilib <name> Specify an mpi library for the target machine (optional)
default: mpi-serial (most of the tools are serial apps)
-mach_dir <path> Specify the locations of the Machines directory (optional).
This script writes CIME build information to a directory. 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 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.

-output_dir <path> default: current working directory
-output_format <value> Output format can be make or cmake.
default: make
-help [or -h] Print usage to STDOUT (optional).
-loglevel
optional arguments:
-h, --help show this help message and exit
-d, --debug Print debug information (very verbose) to file /home/j
edwards/cesm2_0_alpha/cime/tools/mapping/map_field/src
/configure.log
-v, --verbose Add additional context (time and file) to log messages
-s, --silent Print only warnings and error messages
--machine MACHINE The machine to create build information for.
--machines-dir MACHINES_DIR
The machines directory to take build information from.
Overrides the CIME_MODEL environment variable, and
must be specified if that variable is not set.
--macros-format {Makefile,CMake}
The format of Macros file to generate. If 'Makefile'
is passed in, a file called 'Macros.make' is
generated. If 'CMake' is passed in, a file called
'Macros.cmake' is generated. This option can be
specified multiple times to generate multiple files.
If not used at all, Macros generation is skipped. Note
that Depends files are currently always in Makefile
format, regardless of this option.
--output-dir OUTPUT_DIR
The directory to write files to. If not specified,
defaults to the current working directory.
--compiler COMPILER, -compiler COMPILER
Specify a compiler. To see list of supported compilers
for each machine, use the utility manage_case in this
directory
--mpilib MPILIB, -mpilib MPILIB
Specify the mpilib. To see list of supported mpilibs
for each machine, use the utility manage_case in this
directory. The default is the first listing in MPILIBS
in config_machines.xml
--clean Remove old Macros and env files before attempting to
create new ones

EXAMPLES

./configure -mach bluefire -compiler ibm -cimeroot /path/to/cime


This tool is used to create Macros files to build CESM tools on supported machines.
It will create a Macros file in make or cmake format along with the module support
for the specified or default compiler. It will also create two files
.env_mach_specific.csh
.env_mach_specific.sh

Before you try to run make you should source the file above appropriate for your shell
this will set the proper environment for supported systems which use modules.
this will set the proper environment for supported systems which use modules.
39 changes: 35 additions & 4 deletions tools/configure
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ def parse_command_line(args):
help="The directory to write files to. If not "
"specified, defaults to the current working directory.")

parser.add_argument("--compiler", "-compiler",
help="Specify a compiler. "
"To see list of supported compilers for each machine, use the utility manage_case in this directory")

parser.add_argument("--mpilib", "-mpilib",
help="Specify the mpilib. "
"To see list of supported mpilibs for each machine, use the utility manage_case in this directory. "
"The default is the first listing in MPILIBS in config_machines.xml")

parser.add_argument("--clean", action="store_true",
help="Remove old Macros and env files before attempting to create new ones")

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

Expand Down Expand Up @@ -83,7 +96,9 @@ def parse_command_line(args):
opts['output_dir'] = args.output_dir

# Set compiler.
if "COMPILER" in os.environ:
if args.compiler is not None:
compiler = args.compiler
elif "COMPILER" in os.environ:
compiler = os.environ["COMPILER"]
else:
compiler = machobj.get_default_compiler()
Expand All @@ -94,11 +109,14 @@ def parse_command_line(args):
opts['compiler'] = compiler
opts['os'] = machobj.get_value('OS')
# Set MPI library.
if "MPILIB" in os.environ:
if args.mpilib is not None:
mpilib = args.mpilib
elif "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)
Expand All @@ -115,12 +133,25 @@ def parse_command_line(args):
os.environ["DEBUG"] = "FALSE"
opts['debug'] = debug


if args.clean:
files = ["Macros.make", "Macros.cmake", "env_mach_specific.xml", ".env_mach_specific.sh",
".env_mach_specific.csh", "Depends.%s"%compiler, "Depends.%s"%args.machine,
"Depends.%s.%s"%(args.machine,compiler)]
for file_ in files:
if os.path.isfile(file_):
logger.warn("Removing file %s"%file_)
os.remove(file_)
if argcnt == 2:
opts['clean_only'] = True

return opts

def _main():
opts = parse_command_line(sys.argv)
configure(opts['machobj'], opts['output_dir'], opts['macros_format'],
opts['compiler'], opts['mpilib'], opts['debug'], opts['os'])
if "clean_only" not in opts or not opts["clean_only"]:
configure(opts['machobj'], opts['output_dir'], opts['macros_format'],
opts['compiler'], opts['mpilib'], opts['debug'], opts['os'])

if __name__ == "__main__":
_main()
3 changes: 2 additions & 1 deletion tools/mapping/map_field/src/map_field.F90
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ subroutine write_file(fid, fout, units, n, ni, nj, &
if (rcode == 0) then
call check_ret(nf_put_att_text(fid,NF_GLOBAL,'hostname' ,len_trim(host),host))
else
write(6,*) 'WARNING: could not determine hostname, so that information will not be stored in netCDF attribute. To avoid this warning in the future, set environment variable HOST or HOSTNAME.'
write(6,*) 'WARNING: could not determine hostname, so that information will not be &
&stored in netCDF attribute. To avoid this warning in the future, set environment variable HOST or HOSTNAME.'
end if
end if

Expand Down

0 comments on commit 4e125ee

Please sign in to comment.