Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cprnc build fix #3431

Merged
merged 6 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config/cesm/machines/config_machines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ This allows using a different mpirun command to launch unit tests
<DIN_LOC_ROOT_CLMFORC>$DIN_LOC_ROOT</DIN_LOC_ROOT_CLMFORC>
<DOUT_S_ROOT>${CIME_OUTPUT_ROOT}/archive/$CASE</DOUT_S_ROOT>
<BASELINE_ROOT>${CIME_OUTPUT_ROOT}/cesm_baselines</BASELINE_ROOT>
<CCSM_CPRNC>/home/jedwards/cesm_tools/cprnc/cprnc</CCSM_CPRNC>
<GMAKE_J>8</GMAKE_J>
<BATCH_SYSTEM>pbs</BATCH_SYSTEM>
<SUPPORTED_BY> @ pusan.ac.kr</SUPPORTED_BY>
Expand Down Expand Up @@ -1430,7 +1429,7 @@ This allows using a different mpirun command to launch unit tests
<DIN_LOC_ROOT_CLMFORC>$ENV{HOME}/projects/ptclm-data</DIN_LOC_ROOT_CLMFORC>
<DOUT_S_ROOT>$ENV{HOME}/projects/scratch/archive/$CASE</DOUT_S_ROOT>
<BASELINE_ROOT>$ENV{HOME}/projects/baselines</BASELINE_ROOT>
<CCSM_CPRNC>$CIMEROOT/tools/cprnc/build/cprnc</CCSM_CPRNC>
<CCSM_CPRNC>$ENV{HOME}/cesm/tools/cprnc/cprnc</CCSM_CPRNC>
<GMAKE>make</GMAKE>
<GMAKE_J>4</GMAKE_J>
<BATCH_SYSTEM>none</BATCH_SYSTEM>
Expand Down
5 changes: 3 additions & 2 deletions scripts/lib/CIME/SystemTests/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, case):
run_two_description='pause/resume')
self._stopopt = ''
self._stopn = 0

self._cprnc_exe = None
###########################################################################
def _case_one_setup(self):
###########################################################################
Expand Down Expand Up @@ -76,6 +76,7 @@ def run_phase(self): # pylint: disable=arguments-differ
logger = logging.getLogger(__name__)
self._activate_case1()
rundir1 = self._case.get_value("RUNDIR")
self._cprnc_exe = self._case.get_value("CCSM_CPRNC")
self._activate_case2()
rundir2 = self._case.get_value("RUNDIR")
compare_ok = True
Expand Down Expand Up @@ -113,7 +114,7 @@ def run_phase(self): # pylint: disable=arguments-differ
expect((len(restart_files_2) == 1),
"Missing case2 restart file, {}", glob_str)
rfile2 = restart_files_2[0]
ok = cprnc(comp, rfile1, rfile2, self._case, rundir2)[0]
ok = cprnc(comp, rfile1, rfile2, self._case, rundir2, cprnc_exe=self._cprnc_exe)[0]
logger.warning("CPRNC result for {}: {}".format(os.path.basename(rfile1), "PASS" if (ok == should_match) else "FAIL"))
compare_ok = compare_ok and (should_match == ok)

Expand Down
19 changes: 14 additions & 5 deletions scripts/lib/CIME/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,31 @@ def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid
os.makedirs(shared_item)

mpilib = case.get_value("MPILIB")
libs = ["gptl", "mct", "pio", "csm_share"]
if 'CPL' in case.get_values("COMP_CLASSES"):
libs = ["gptl", "mct", "pio", "csm_share"]
else:
libs = []

if mpilib == "mpi-serial":
libs.insert(0, mpilib)

if uses_kokkos(case):
libs.append("kokkos")

sharedlibroot = os.path.abspath(case.get_value("SHAREDLIBROOT"))
# Check if we need to build our own cprnc
if case.get_value("TEST"):
cprnc_loc = case.get_value("CCSM_CPRNC")
if not cprnc_loc or not os.path.exists(cprnc_loc):
libs.append("cprnc")
full_lib_path = os.path.join(sharedlibroot, compiler, "cprnc")
case.set_value("CCSM_CPRNC", os.path.join(full_lib_path, "cprnc"))
if not os.path.isdir(full_lib_path):
os.makedirs(full_lib_path)
libs.append("cprnc")


logs = []
sharedlibroot = os.path.abspath(case.get_value("SHAREDLIBROOT"))

for lib in libs:
if buildlist is not None and lib not in buildlist:
continue
Expand All @@ -266,7 +276,6 @@ def _build_libraries(case, exeroot, sharedpath, caseroot, cimeroot, libroot, lid
full_lib_path = os.path.join(sharedlibroot, sharedpath, "mct", lib)
elif lib == "cprnc":
full_lib_path = os.path.join(sharedlibroot, compiler, "cprnc")
case.set_value("CCSM_CPRNC", os.path.join(full_lib_path, "cprnc"))
else:
full_lib_path = os.path.join(sharedlibroot, sharedpath, lib)
# pio build creates its own directory
Expand Down Expand Up @@ -514,7 +523,7 @@ def _case_build_impl(caseroot, case, sharedlib_only, model_only, buildlist,
t2 = time.time()
logs = []

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

Expand Down
5 changes: 3 additions & 2 deletions scripts/lib/CIME/hist_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def compare_test(case, suffix1, suffix2, ignore_fieldlist_diffs=False):
ignore_fieldlist_diffs=ignore_fieldlist_diffs)

def cprnc(model, file1, file2, case, rundir, multiinst_driver_compare=False, outfile_suffix="",
ignore_fieldlist_diffs=False):
ignore_fieldlist_diffs=False, cprnc_exe=None):
"""
Run cprnc to compare two individual nc files

Expand All @@ -322,7 +322,8 @@ def cprnc(model, file1, file2, case, rundir, multiinst_driver_compare=False, out
where 'comment' is either an empty string or one of the module-level constants
beginning with CPRNC_ (e.g., CPRNC_FIELDLISTS_DIFFER)
"""
cprnc_exe = case.get_value("CCSM_CPRNC")
if not cprnc_exe:
cprnc_exe = case.get_value("CCSM_CPRNC")
basename = os.path.basename(file1)
multiinst_regex = re.compile(r'.*%s[^_]*(_[0-9]{4})[.]h.?[.][^.]+?[.]nc' % model)
mstr = ''
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Environment variables CIME_COMPILER and CIME_MPILIB
# can be used to send --compiler and --mpilib settings to scripts_regression_tests.py
#

PROJECT(cime)
cmake_minimum_required(VERSION 2.8)

include(CTest)
Expand Down
6 changes: 3 additions & 3 deletions src/build_scripts/buildlib.cprnc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def buildlib(bldroot, installpath, case):
cimeroot = case.get_value("CIMEROOT")

# Generate macros and environment

run_bld_cmd_ensure_logging("{}/tools/configure --mpilib=mpi-serial --macros-format=CMake --machine={}".format(cimeroot, case.get_value("MACH")), logger, from_dir=bldroot)

cmake_args = get_standard_cmake_args(case, shared_lib=True)

cmake_cmd = "CIMEROOT={cimeroot} . .env_mach_specific.sh && NETCDF=$(dirname $(dirname $(which nf-config))) CIMEROOT={cimeroot} cmake {cmake_args} -DMPILIB=mpi-serial -DDEBUG=FALSE -C Macros.cmake {cimeroot}/tools/cprnc -DCMAKE_PREFIX_PATH={dest_path}".\
format(cimeroot=cimeroot, dest_path=installpath, cmake_args=cmake_args)
cmake_cmd = "CIMEROOT={cimeroot} . ./.env_mach_specific.sh && NETCDF=$(dirname $(dirname $(which nf-config))) CIMEROOT={cimeroot} cmake {cmake_args} -DMPILIB=mpi-serial -DDEBUG=FALSE -C Macros.cmake {cimeroot}/tools/cprnc -DCMAKE_PREFIX_PATH={dest_path} -DBLDROOT={bldroot}".\
format(cimeroot=cimeroot, dest_path=installpath, cmake_args=cmake_args, bldroot=bldroot)
run_bld_cmd_ensure_logging(cmake_cmd, logger, from_dir=bldroot)

gmake_cmd = case.get_value("GMAKE")
Expand Down
9 changes: 5 additions & 4 deletions tools/cprnc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
PROJECT(CPRNC C Fortran)

# Generate this with: $cimeroot/tools/configure --mpilib=mpi-serial --macros-format=CMake
# You'll also need to source the .env_mach_specific.sh file before trying to build cprnc
include("${PROJECT_BINARY_DIR}/Macros.cmake")
set(CMAKE_Fortran_Compiler "${SFC}")

include("${BLDROOT}/Macros.cmake")
set(CMAKE_C_COMPILER "${SCC}")
set(CMAKE_Fortran_COMPILER "${SFC}")
set(CMAKE_Fortran_FLAGS "${FFLAGS}")

PROJECT(CPRNC C Fortran)
ENABLE_LANGUAGE(Fortran)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
Expand Down