Skip to content

Commit

Permalink
Merge pull request ESMCI#1844 from ESMCI/jgfouca/get_pfunit_working_o…
Browse files Browse the repository at this point in the history
…n_melvin

Get PFUnit working on melvin.
Fix up serial settings in melvin.
Need to explicitly declare PFUNIT_PATH in cmake calls in run_tests.py
Need to load env before making env XML files, some compiler vars pull from environment
Need to not crash when CMAKE_Fortran_COMPILER_ID is empty
Test suite: scripts_regression_tests.py N_TestUnitTest
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes ESMCI#1297

User interface changes?: N

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

Code review: @billsacks @jedwards4b (confirmed N_TestUnitTest still works on cheyenne)
  • Loading branch information
jedwards4b authored Aug 30, 2017
2 parents 0b8afd9 + 35077ea commit 751fd7a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions config/acme/machines/config_compilers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ for mct, etc.
<CONFIG_ARGS> --host=Linux </CONFIG_ARGS>
<NETCDF_PATH>$(NETCDFROOT)</NETCDF_PATH>
<PNETCDF_PATH>$(PNETCDFROOT)</PNETCDF_PATH>
<PFUNIT_PATH MPILIB="mpi-serial" compile_threaded="false">/sems-data-store/ACME/pfunit/pfunit-3.2.8</PFUNIT_PATH>
<ADD_SLIBS> $(shell $(NETCDF_PATH)/bin/nf-config --flibs) -lblas -llapack</ADD_SLIBS>
<CXX_LIBS>-lstdc++ -lmpi_cxx</CXX_LIBS>
<ALBANY_PATH>/projects/install/rhel6-x86_64/ACME/AlbanyTrilinos/Albany/build/install</ALBANY_PATH>
Expand Down
7 changes: 5 additions & 2 deletions config/acme/machines/config_machines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,19 @@
<command name="load">sems-env</command>
<command name="load">sems-git</command>
<command name="load">sems-python/2.7.9</command>
<command name="load">sems-cmake/2.8.12</command>
</modules>
<modules compiler="gnu">
<command name="load">sems-gcc/5.3.0</command>
</modules>
<modules compiler="intel">
<command name="load">sems-intel/16.0.3</command>
</modules>
<modules>
<modules mpilib="mpi-serial">
<command name="load">sems-netcdf/4.4.1/exo</command>
</modules>
<modules mpilib="!mpi-serial">
<command name="load">sems-openmpi/1.8.7</command>
<command name="load">sems-cmake/2.8.12</command>
<command name="load">sems-netcdf/4.4.1/exo_parallel</command>
</modules>
</module_system>
Expand Down
12 changes: 6 additions & 6 deletions scripts/fortran_unit_testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def parse_command_line(args):
args.use_openmp, args.xml_test_list, args.verbose


def cmake_stage(name, test_spec_dir, build_optimized, use_mpiserial, mpirun_command, output,
def cmake_stage(name, test_spec_dir, build_optimized, use_mpiserial, mpirun_command, output, pfunit_path,
cmake_args=None, clean=False, verbose=False, enable_genf90=True, color=True):
"""Run cmake in the current working directory.
Expand Down Expand Up @@ -178,10 +178,12 @@ def cmake_stage(name, test_spec_dir, build_optimized, use_mpiserial, mpirun_comm

cmake_command = [
"cmake",
"-C Macros.cmake",
test_spec_dir,
"-DCIME_CMAKE_MODULE_DIRECTORY="+os.path.abspath(os.path.join(_CIMEROOT,"src","CMake")),
"-DCMAKE_BUILD_TYPE="+build_type,
"-DPFUNIT_MPIRUN='"+mpirun_command+"'",
"-DPFUNIT_PATH="+pfunit_path
]
if use_mpiserial:
cmake_command.append("-DUSE_MPI_SERIAL=ON")
Expand Down Expand Up @@ -241,6 +243,7 @@ def find_pfunit(compilerobj, mpilib, use_openmp):
"""PFUNIT_PATH not found for this machine and compiler, with MPILIB={} and compile_threaded={}.
You must specify PFUNIT_PATH in config_compilers.xml, with attributes MPILIB and compile_threaded.""".format(mpilib, attrs['compile_threaded']))
logger.info("Using PFUNIT_PATH: {}".format(pfunit_path.text))
return pfunit_path.text

#=================================================
# Iterate over input suite specs, building the tests.
Expand Down Expand Up @@ -306,7 +309,7 @@ def _main():

compilerobj = Compilers(machobj, compiler=compiler, mpilib=mpilib)

find_pfunit(compilerobj, mpilib=mpilib, use_openmp=use_openmp)
pfunit_path = find_pfunit(compilerobj, mpilib=mpilib, use_openmp=use_openmp)

debug = not build_optimized
os_ = machobj.get_value("OS")
Expand Down Expand Up @@ -375,7 +378,7 @@ def _main():
if not os.path.islink("Macros.cmake"):
os.symlink(os.path.join(build_dir,"Macros.cmake"), "Macros.cmake")
use_mpiserial = not use_mpi
cmake_stage(name, directory, build_optimized, use_mpiserial, mpirun_command, output, verbose=verbose,
cmake_stage(name, directory, build_optimized, use_mpiserial, mpirun_command, output, pfunit_path, verbose=verbose,
enable_genf90=enable_genf90, cmake_args=cmake_args)
make_stage(name, output, make_j, clean=clean, verbose=verbose)

Expand All @@ -399,8 +402,5 @@ def _main():
run_cmd_no_fail(" ".join(ctest_command), from_dir=label, arg_stdout=None, arg_stderr=subprocess.STDOUT)





if __name__ == "__main__":
_main()
2 changes: 1 addition & 1 deletion scripts/lib/CIME/BuildTools/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def _copy_depends_files(machine_name, machines_dir, output_dir, compiler):
if os.path.isfile(dfile) and not os.path.isfile(outputdfile):
shutil.copyfile(dfile, outputdfile)


def _generate_env_mach_specific(output_dir, machobj, compiler, mpilib, debug,
sysos, unit_testing):
"""
Expand All @@ -79,6 +78,7 @@ def _generate_env_mach_specific(output_dir, machobj, compiler, mpilib, debug,
ems_file = EnvMachSpecific(output_dir, unit_testing=unit_testing)
ems_file.populate(machobj)
ems_file.write()
ems_file.load_env(compiler, debug, mpilib)
for shell in ('sh', 'csh'):
ems_file.make_env_mach_specific_file(compiler, debug, mpilib, shell)
shell_path = os.path.join(output_dir, ".env_mach_specific." + shell)
Expand Down
18 changes: 12 additions & 6 deletions scripts/lib/CIME/BuildTools/macrowriterbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
from abc import ABCMeta, abstractmethod
from CIME.XML.standard_module_setup import *
from CIME.utils import get_cime_root
logger = logging.getLogger(__name__)

def _get_components(value):
Expand Down Expand Up @@ -234,14 +235,15 @@ def write_macros_file_v1(macros, compiler, os_, machine, macros_file="Macros", o
'''#
# cmake Macros generated from $compiler_file
#
set(CMAKE_MODULE_PATH %s)
include(Compilers)
set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "Flags used by c compiler." FORCE)
set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Flags used by c compiler." FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "" CACHE STRING "Flags used by Fortran compiler." FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Flags used by Fortran compiler." FORCE)
set(all_build_types "None Debug Release RelWithDebInfo MinSizeRel")
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${all_build_types}." FORCE)
''')
''' % os.path.join(get_cime_root(), "src", "CMake"))

# print the settings out to the Macros file, do it in
# two passes so that path values appear first in the
Expand All @@ -254,7 +256,10 @@ def write_macros_file_v1(macros, compiler, os_, machine, macros_file="Macros", o
if key.endswith("_PATH"):
if value.startswith("$"):
value = "$ENV{}".format(value[1:])
fd.write("set({} {})\n".format(key, value))


cmake_var = key.replace("NETCDF_PATH", "NetCDF_PATH").replace("PNETCDF_PATH", "Pnetcdf_PATH")
fd.write("set({} {})\n".format(cmake_var, value))
fd.write("list(APPEND CMAKE_PREFIX_PATH {})\n\n".format(value))

for key, value in sorted(macros.iteritems()):
Expand All @@ -268,6 +273,7 @@ def write_macros_file_v1(macros, compiler, os_, machine, macros_file="Macros", o

idx = 0
for is_shell, component in components:
component = component.replace("NETCDF", "NetCDF").replace("PNETCDF_PATH", "Pnetcdf_PATH")
if is_shell:
fd.write('execute_process(COMMAND {} OUTPUT_VARIABLE TEMP{:d})\n'.format(component, idx))
fd.write('string(REGEX REPLACE "\\n$" "" TEMP{:d} "${{TEMP{:d}}}")\n'.format(idx, idx))
Expand All @@ -281,13 +287,13 @@ def write_macros_file_v1(macros, compiler, os_, machine, macros_file="Macros", o
fd.write('set(TEMP "{}")\n'.format(value))

if "CFLAGS" in key:
fd.write("add_flags(CMAKE_C_FLAGS ${TEMP})\n\n")
fd.write("add_flags(CFLAGS ${TEMP})\n\n")
elif "FFLAGS" in key:
fd.write("add_flags(CMAKE_Fortran_FLAGS ${TEMP})\n\n")
fd.write("add_flags(FFLAGS ${TEMP})\n\n")
elif "CPPDEFS" in key:
fd.write("list(APPEND COMPILE_DEFINITIONS ${TEMP})\n\n")
fd.write("list(APPEND CPPDEFS ${TEMP})\n\n")
elif "SLIBS" in key or "LDFLAGS" in key:
fd.write("add_flags(CMAKE_EXE_LINKER_FLAGS ${TEMP})\n\n")
fd.write("add_flags(LDFLAGS ${TEMP})\n\n")

# Recursively print the conditionals, combining tests to avoid repetition
_parse_hash(macros["_COND_"], fd, 0, output_format)
Expand Down
2 changes: 1 addition & 1 deletion src/CMake/Compilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ endfunction()
#=================================================

# Detect "STOP" for CTest.
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL NAG)
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL NAG)
# NAG prints the stop code instead of yielding a non-zero return, so we
# have to use a regex to catch that.
function(define_Fortran_stop_failure test_name)
Expand Down

0 comments on commit 751fd7a

Please sign in to comment.