From 9600ed43eec9cb9fdd6dc67676e9e00919e1aa3b Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 2 Mar 2020 10:46:32 -0700 Subject: [PATCH 1/6] cprnc build fix --- scripts/lib/CIME/build.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/lib/CIME/build.py b/scripts/lib/CIME/build.py index bc22d329094..7720cb209ee 100644 --- a/scripts/lib/CIME/build.py +++ b/scripts/lib/CIME/build.py @@ -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 @@ -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 @@ -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) From fc24f117b62a1a341daa8e9dd64cb63e073fb1ba Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 2 Mar 2020 10:48:39 -0700 Subject: [PATCH 2/6] fix for pre test --- scripts/lib/CIME/SystemTests/pre.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/lib/CIME/SystemTests/pre.py b/scripts/lib/CIME/SystemTests/pre.py index b1578b51a6b..3c15ab2a829 100644 --- a/scripts/lib/CIME/SystemTests/pre.py +++ b/scripts/lib/CIME/SystemTests/pre.py @@ -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 @@ -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) From 061aa8fc9175a941dce448e9999791ffa0e3f50a Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 2 Mar 2020 15:31:35 -0700 Subject: [PATCH 3/6] fix pylint issue --- scripts/lib/CIME/SystemTests/pre.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/CIME/SystemTests/pre.py b/scripts/lib/CIME/SystemTests/pre.py index 3c15ab2a829..c8f0e4952f3 100644 --- a/scripts/lib/CIME/SystemTests/pre.py +++ b/scripts/lib/CIME/SystemTests/pre.py @@ -34,7 +34,7 @@ def __init__(self, case): run_two_description='pause/resume') self._stopopt = '' self._stopn = 0 - + self._cprnc = None ########################################################################### def _case_one_setup(self): ########################################################################### From 4a648f22d745bd63753b7f9ff7bdd1f3802e680c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 2 Mar 2020 17:01:35 -0700 Subject: [PATCH 4/6] fix issue on homebrew --- config/cesm/machines/config_machines.xml | 3 +-- scripts/tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/config/cesm/machines/config_machines.xml b/config/cesm/machines/config_machines.xml index 8b859ca1f74..84ab79d1e91 100644 --- a/config/cesm/machines/config_machines.xml +++ b/config/cesm/machines/config_machines.xml @@ -60,7 +60,6 @@ This allows using a different mpirun command to launch unit tests $DIN_LOC_ROOT ${CIME_OUTPUT_ROOT}/archive/$CASE ${CIME_OUTPUT_ROOT}/cesm_baselines - /home/jedwards/cesm_tools/cprnc/cprnc 8 pbs @ pusan.ac.kr @@ -1430,7 +1429,7 @@ This allows using a different mpirun command to launch unit tests $ENV{HOME}/projects/ptclm-data $ENV{HOME}/projects/scratch/archive/$CASE $ENV{HOME}/projects/baselines - $CIMEROOT/tools/cprnc/build/cprnc + $ENV{HOME}/cesm/tools/cprnc/cprnc make 4 none diff --git a/scripts/tests/CMakeLists.txt b/scripts/tests/CMakeLists.txt index 235e29c71dd..89e240604e7 100644 --- a/scripts/tests/CMakeLists.txt +++ b/scripts/tests/CMakeLists.txt @@ -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) From afdff7d91c91387502ab93c7b032ffba95632bc6 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 3 Mar 2020 15:05:07 -0700 Subject: [PATCH 5/6] fix cprnc build issues --- scripts/lib/CIME/SystemTests/pre.py | 2 +- src/build_scripts/buildlib.cprnc | 6 +++--- tools/cprnc/CMakeLists.txt | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/lib/CIME/SystemTests/pre.py b/scripts/lib/CIME/SystemTests/pre.py index c8f0e4952f3..da002c4f639 100644 --- a/scripts/lib/CIME/SystemTests/pre.py +++ b/scripts/lib/CIME/SystemTests/pre.py @@ -34,7 +34,7 @@ def __init__(self, case): run_two_description='pause/resume') self._stopopt = '' self._stopn = 0 - self._cprnc = None + self._cprnc_exe = None ########################################################################### def _case_one_setup(self): ########################################################################### diff --git a/src/build_scripts/buildlib.cprnc b/src/build_scripts/buildlib.cprnc index 703de06afe6..25aab6600cc 100755 --- a/src/build_scripts/buildlib.cprnc +++ b/src/build_scripts/buildlib.cprnc @@ -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") diff --git a/tools/cprnc/CMakeLists.txt b/tools/cprnc/CMakeLists.txt index 694d436a6a8..6ca481f20ac 100644 --- a/tools/cprnc/CMakeLists.txt +++ b/tools/cprnc/CMakeLists.txt @@ -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) From e1d8d5de5fe02d101b2b9eeeee2952b33be07a99 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 3 Mar 2020 15:18:08 -0700 Subject: [PATCH 6/6] optionally pass cprnc_exe --- scripts/lib/CIME/hist_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/lib/CIME/hist_utils.py b/scripts/lib/CIME/hist_utils.py index 87b96bd06e9..d279c3963d0 100644 --- a/scripts/lib/CIME/hist_utils.py +++ b/scripts/lib/CIME/hist_utils.py @@ -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 @@ -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 = ''