diff --git a/cime_config/customize/e3sm_compile_wrap.py b/cime_config/customize/e3sm_compile_wrap.py index d7604f6d47fb..608506f8c91e 100644 --- a/cime_config/customize/e3sm_compile_wrap.py +++ b/cime_config/customize/e3sm_compile_wrap.py @@ -21,10 +21,7 @@ def run_cmd(args): arglen = len(args) target = None - for ( - idx, - arg, - ) in enumerate(args): + for idx, arg in enumerate(args): if arg == "-o" and idx + 1 < arglen: target = args[idx + 1] break @@ -41,13 +38,11 @@ def run_cmd(args): return result - ############################################################################### def parse_command_line(args, _): ############################################################################### return args[1:] - ############################################################################### def _main_func(description): ############################################################################### @@ -57,7 +52,6 @@ def _main_func(description): sys.exit(result) - ############################################################################### if __name__ == "__main__": diff --git a/cime_config/machines/Depends.anlgce.gnu.cmake b/cime_config/machines/Depends.anlgce.gnu.cmake index 09ad9d987878..4b8e6d0fbbfb 100644 --- a/cime_config/machines/Depends.anlgce.gnu.cmake +++ b/cime_config/machines/Depends.anlgce.gnu.cmake @@ -4,8 +4,7 @@ set(NOOPT if (NOT DEBUG) foreach(ITEM IN LISTS NOOPT) - e3sm_remove_flags("${ITEM}" "-O2") - e3sm_remove_flags("${ITEM}" "-O") + e3sm_deoptimize_file(${ITEM}) endforeach() endif() diff --git a/cime_config/machines/Depends.chrysalis.intel.cmake b/cime_config/machines/Depends.chrysalis.intel.cmake index 8f4a1327ea6e..e14cc4d3a673 100644 --- a/cime_config/machines/Depends.chrysalis.intel.cmake +++ b/cime_config/machines/Depends.chrysalis.intel.cmake @@ -10,7 +10,6 @@ set(O2MODELSRC ) if (NOT DEBUG) foreach(ITEM IN LISTS O2MODELSRC) - e3sm_remove_flags("${ITEM}" "-O3") e3sm_add_flags("${ITEM}" "-O2") endforeach() endif() diff --git a/cime_config/machines/Depends.cray.cmake b/cime_config/machines/Depends.cray.cmake index 17168db6d817..459107cb3d7e 100644 --- a/cime_config/machines/Depends.cray.cmake +++ b/cime_config/machines/Depends.cray.cmake @@ -8,7 +8,6 @@ set(O0MODELSRC if (NOT DEBUG) foreach(ITEM IN LISTS O0MODELSRC) - e3sm_remove_flags("${ITEM}" "-O1") e3sm_add_flags("${ITEM}" "-O0 -vector0") endforeach() diff --git a/cime_config/machines/Depends.crayclanggpu.cmake b/cime_config/machines/Depends.crayclanggpu.cmake index 8c70a4610f11..eaff237a27fc 100644 --- a/cime_config/machines/Depends.crayclanggpu.cmake +++ b/cime_config/machines/Depends.crayclanggpu.cmake @@ -17,12 +17,9 @@ set(O2MODELSRC if (NOT DEBUG) foreach(ITEM IN LISTS O2MODELSRC) - e3sm_remove_flags("${ITEM}" "-O3") e3sm_add_flags("${ITEM}" "-O2") endforeach() foreach(ITEM IN LISTS O1MODELSRC) - e3sm_remove_flags("${ITEM}" "-O3") - e3sm_remove_flags("${ITEM}" "-O2") e3sm_add_flags("${ITEM}" "-O1") endforeach() endif() diff --git a/cime_config/machines/Depends.pgi.cmake b/cime_config/machines/Depends.pgi.cmake index 0d49910683b4..0b6bbd571126 100644 --- a/cime_config/machines/Depends.pgi.cmake +++ b/cime_config/machines/Depends.pgi.cmake @@ -12,13 +12,10 @@ set(O0MODELSRC if (NOT DEBUG) foreach(ITEM IN LISTS O1MODELSRC) - e3sm_remove_flags("${ITEM}" "-O2") e3sm_add_flags("${ITEM}" "-O1 -Mnovect") endforeach() foreach(ITEM IN LISTS O0MODELSRC) - e3sm_remove_flags("${ITEM}" "-O2") - e3sm_remove_flags("${ITEM}" "-O1") e3sm_add_flags("${ITEM}" "-O0 -Mnovect") endforeach() endif() diff --git a/cime_config/machines/Depends.pgigpu.cmake b/cime_config/machines/Depends.pgigpu.cmake index 43d22444afb1..22acbcc33c3b 100644 --- a/cime_config/machines/Depends.pgigpu.cmake +++ b/cime_config/machines/Depends.pgigpu.cmake @@ -19,13 +19,10 @@ set(O0MODELSRC if (NOT DEBUG) foreach(ITEM IN LISTS O1MODELSRC) - e3sm_remove_flags("${ITEM}" "-O2") e3sm_add_flags("${ITEM}" "-O1 -Mnovect") endforeach() foreach(ITEM IN LISTS O0MODELSRC) - e3sm_remove_flags("${ITEM}" "-O2") - e3sm_remove_flags("${ITEM}" "-O1") e3sm_add_flags("${ITEM}" "-O0 -Mnovect") endforeach() endif() diff --git a/cime_config/machines/Depends.pm-cpu.alvarez.cmake b/cime_config/machines/Depends.pm-cpu.alvarez.cmake index 58c0c05d273f..c9577afc47c2 100644 --- a/cime_config/machines/Depends.pm-cpu.alvarez.cmake +++ b/cime_config/machines/Depends.pm-cpu.alvarez.cmake @@ -4,11 +4,6 @@ set(NOOPT if (NOT DEBUG) foreach(ITEM IN LISTS NOOPT) - e3sm_remove_flags("${ITEM}" "-O2") - e3sm_remove_flags("${ITEM}" "-O") + e3sm_deoptimize_file(${ITEM}) endforeach() endif() - - - - diff --git a/cime_config/machines/Depends.pm-cpu.gnu.cmake b/cime_config/machines/Depends.pm-cpu.gnu.cmake index 58c0c05d273f..9ebd88ff8762 100644 --- a/cime_config/machines/Depends.pm-cpu.gnu.cmake +++ b/cime_config/machines/Depends.pm-cpu.gnu.cmake @@ -4,8 +4,7 @@ set(NOOPT if (NOT DEBUG) foreach(ITEM IN LISTS NOOPT) - e3sm_remove_flags("${ITEM}" "-O2") - e3sm_remove_flags("${ITEM}" "-O") + e3sm_deoptimize_file("${ITEM}") endforeach() endif() diff --git a/cime_config/machines/Depends.pm-cpu.intel.cmake b/cime_config/machines/Depends.pm-cpu.intel.cmake index a6deb4e6efec..4c217216b390 100644 --- a/cime_config/machines/Depends.pm-cpu.intel.cmake +++ b/cime_config/machines/Depends.pm-cpu.intel.cmake @@ -5,7 +5,6 @@ #if (NOT DEBUG) # foreach(ITEM IN LISTS NOOPT) -# e3sm_remove_flags("${ITEM}" "-O2") # e3sm_add_flags("${ITEM}" "-O0") # endforeach() #endif() diff --git a/cime_config/machines/Depends.pm-cpu.nvidia.cmake b/cime_config/machines/Depends.pm-cpu.nvidia.cmake index 803b1719a230..2947c73aacc4 100644 --- a/cime_config/machines/Depends.pm-cpu.nvidia.cmake +++ b/cime_config/machines/Depends.pm-cpu.nvidia.cmake @@ -26,7 +26,6 @@ set(PERFOBJS if (NOT DEBUG) foreach(ITEM IN LISTS PERFOBJS) - e3sm_remove_flags("${ITEM}" "-O1") e3sm_add_flags("${ITEM}" "-O2") endforeach() endif() diff --git a/cime_config/machines/cmake_macros/CMakeLists.txt b/cime_config/machines/cmake_macros/CMakeLists.txt index c2ebcb51be40..e502fc932dd4 100644 --- a/cime_config/machines/cmake_macros/CMakeLists.txt +++ b/cime_config/machines/cmake_macros/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_policy(SET CMP0057 NEW) cmake_minimum_required(VERSION 3.5) project(cime LANGUAGES C Fortran) -include(../Macros.cmake) +include(${CMAKE_CURRENT_BINARY_DIR}/../Macros.cmake) diff --git a/cime_config/machines/cmake_macros/Macros.cmake b/cime_config/machines/cmake_macros/Macros.cmake index 95c38ee39a53..581f39d42009 100644 --- a/cime_config/machines/cmake_macros/Macros.cmake +++ b/cime_config/machines/cmake_macros/Macros.cmake @@ -12,13 +12,19 @@ set(UNIVERSAL_MACRO ${MACROS_DIR}/universal.cmake) set(COMPILER_MACRO ${MACROS_DIR}/${COMPILER}.cmake) set(MACHINE_MACRO ${MACROS_DIR}/${MACH}.cmake) set(COMPILER_MACHINE_MACRO ${MACROS_DIR}/${COMPILER}_${MACH}.cmake) +set(POST_PROCESS_MACRO ${SRCROOT}/cime_config/machines/cmake_macros/post_process.cmake) if (CONVERT_TO_MAKE) - get_cmake_property(VARS_BEFORE_BUILD_INTERNAL_IGNORE VARIABLES) + get_cmake_property(E3SM_CMAKE_INTERNAL_VARS_BEFORE_BUILD_INTERNAL_IGNORE VARIABLES) + foreach (VAR_BEFORE IN LISTS E3SM_CMAKE_INTERNAL_VARS_BEFORE_BUILD_INTERNAL_IGNORE) + set("E3SM_CMAKE_INTERNAL_${VAR_BEFORE}" "${${VAR_BEFORE}}") + endforeach() + list(APPEND E3SM_CMAKE_INTERNAL_VARS_BEFORE_BUILD_INTERNAL_IGNORE "VAR_BEFORE") + list(APPEND E3SM_CMAKE_INTERNAL_VARS_BEFORE_BUILD_INTERNAL_IGNORE "MACRO_FILE") endif() # Include order defines precedence -foreach (MACRO_FILE ${UNIVERSAL_MACRO} ${COMPILER_MACRO} ${MACHINE_MACRO} ${COMPILER_MACHINE_MACRO}) +foreach (MACRO_FILE ${UNIVERSAL_MACRO} ${COMPILER_MACRO} ${MACHINE_MACRO} ${COMPILER_MACHINE_MACRO} ${POST_PROCESS_MACRO}) if (EXISTS ${MACRO_FILE}) include(${MACRO_FILE}) else() @@ -30,8 +36,17 @@ if (CONVERT_TO_MAKE) get_cmake_property(VARS_AFTER VARIABLES) foreach (VAR_AFTER IN LISTS VARS_AFTER) - if (NOT VAR_AFTER IN_LIST VARS_BEFORE_BUILD_INTERNAL_IGNORE) - message("CIME_SET_MAKEFILE_VAR ${VAR_AFTER} := ${${VAR_AFTER}}") + if (VAR_AFTER MATCHES "^E3SM_CMAKE_INTERNAL_") + # skip + else() + if (NOT VAR_AFTER IN_LIST E3SM_CMAKE_INTERNAL_VARS_BEFORE_BUILD_INTERNAL_IGNORE) + message("CIME_SET_MAKEFILE_VAR ${VAR_AFTER} := ${${VAR_AFTER}}") + list(APPEND E3SM_CMAKE_INTERNAL_VARS_BEFORE_BUILD_INTERNAL_IGNORE "${VAR_AFTER}") + set("E3SM_CMAKE_INTERNAL_${VAR_AFTER}" "${${VAR_AFTER}}") + elseif (NOT "${${VAR_AFTER}}" STREQUAL "${E3SM_CMAKE_INTERNAL_${VAR_AFTER}}") + message("CIME_SET_MAKEFILE_VAR ${VAR_AFTER} := ${${VAR_AFTER}}") + set("E3SM_CMAKE_INTERNAL_${VAR_AFTER}" "${${VAR_AFTER}}") + endif() endif() endforeach() endif() diff --git a/cime_config/machines/cmake_macros/amdclang.cmake b/cime_config/machines/cmake_macros/amdclang.cmake index 3687e798f8b5..dab2976836b1 100644 --- a/cime_config/machines/cmake_macros/amdclang.cmake +++ b/cime_config/machines/cmake_macros/amdclang.cmake @@ -1,21 +1,14 @@ -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") if (compile_threaded) - string(APPEND FFLAGS " -fopenmp") - string(APPEND CFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() string(APPEND CPPDEFS " -DNO_R16 -DCPRAMD -DFORTRANUNDERSCORE") -string(APPEND FFLAGS_NOOPT " -O0") -set(HAS_F2008_CONTIGUOUS "FALSE") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/amdclang_alvarez.cmake b/cime_config/machines/cmake_macros/amdclang_alvarez.cmake index 2472dfc3b8a5..ab5f71464212 100644 --- a/cime_config/machines/cmake_macros/amdclang_alvarez.cmake +++ b/cime_config/machines/cmake_macros/amdclang_alvarez.cmake @@ -1,25 +1,18 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") - string(APPEND CXXFLAGS " -O2 -g") - string(APPEND FFLAGS " -O2 -g") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") #string(APPEND FFLAGS " -march=znver3") set(SCC "clang") set(SCXX "clang++") set(SFC "flang") -if (COMP_NAME STREQUAL cism) - string(APPEND CMAKE_OPTS " -D CISM_GNU=ON") -endif() - -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS " -Mflushz ") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfreeform") +string(APPEND CMAKE_Fortran_FLAGS " -Mflushz ") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfreeform") if (compile_threaded) - string(APPEND FFLAGS " -mp") - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_Fortran_FLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() diff --git a/cime_config/machines/cmake_macros/amdclang_chicoma-cpu.cmake b/cime_config/machines/cmake_macros/amdclang_chicoma-cpu.cmake index ccd946877052..9ee7cb2fa2a1 100644 --- a/cime_config/machines/cmake_macros/amdclang_chicoma-cpu.cmake +++ b/cime_config/machines/cmake_macros/amdclang_chicoma-cpu.cmake @@ -2,25 +2,18 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() set(PIO_FILESYSTEM_HINTS "lustre") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") - string(APPEND CXXFLAGS " -O2 -g") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") #string(APPEND FFLAGS " -march=znver3") set(SCC "clang") set(SCXX "clang++") set(SFC "flang") -if (COMP_NAME STREQUAL cism) - string(APPEND CMAKE_OPTS " -D CISM_GNU=ON") -endif() - -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS " -Mflushz ") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfreeform") +string(APPEND CMAKE_Fortran_FLAGS " -Mflushz ") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfreeform") if (compile_threaded) - string(APPEND FFLAGS " -mp") - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_Fortran_FLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() diff --git a/cime_config/machines/cmake_macros/amdclang_crusher.cmake b/cime_config/machines/cmake_macros/amdclang_crusher.cmake index cf774e04276e..2df5074d11f3 100644 --- a/cime_config/machines/cmake_macros/amdclang_crusher.cmake +++ b/cime_config/machines/cmake_macros/amdclang_crusher.cmake @@ -9,5 +9,4 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -string(APPEND SLIBS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") -set(CRAY_LIBSCI_PREFIX_DIR "$ENV{CRAY_LIBSCI_PREFIX_DIR}") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") diff --git a/cime_config/machines/cmake_macros/amdclang_frontier.cmake b/cime_config/machines/cmake_macros/amdclang_frontier.cmake index cf774e04276e..2df5074d11f3 100644 --- a/cime_config/machines/cmake_macros/amdclang_frontier.cmake +++ b/cime_config/machines/cmake_macros/amdclang_frontier.cmake @@ -9,5 +9,4 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -string(APPEND SLIBS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") -set(CRAY_LIBSCI_PREFIX_DIR "$ENV{CRAY_LIBSCI_PREFIX_DIR}") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") diff --git a/cime_config/machines/cmake_macros/amdclang_pm-cpu.cmake b/cime_config/machines/cmake_macros/amdclang_pm-cpu.cmake index 68b74a723c84..dfdd5d9c37e2 100644 --- a/cime_config/machines/cmake_macros/amdclang_pm-cpu.cmake +++ b/cime_config/machines/cmake_macros/amdclang_pm-cpu.cmake @@ -1,25 +1,18 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") - string(APPEND CXXFLAGS " -O2 -g") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") #string(APPEND FFLAGS " -march=znver3") set(SCC "clang") set(SCXX "clang++") set(SFC "flang") -if (COMP_NAME STREQUAL cism) - string(APPEND CMAKE_OPTS " -D CISM_GNU=ON") -endif() - -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS " -Mflushz ") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfreeform") +string(APPEND CMAKE_Fortran_FLAGS " -Mflushz ") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfreeform") if (compile_threaded) - string(APPEND FFLAGS " -mp") - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_Fortran_FLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() diff --git a/cime_config/machines/cmake_macros/amdclanggpu.cmake b/cime_config/machines/cmake_macros/amdclanggpu.cmake index 5fde6320f590..c0997d421b94 100644 --- a/cime_config/machines/cmake_macros/amdclanggpu.cmake +++ b/cime_config/machines/cmake_macros/amdclanggpu.cmake @@ -1,24 +1,17 @@ -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") if (compile_threaded) - string(APPEND FFLAGS " -fopenmp") - string(APPEND CFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() string(APPEND CPPDEFS " -DNO_R16 -DCPRAMD -DFORTRANUNDERSCORE") -string(APPEND FFLAGS_NOOPT " -O0") -set(HAS_F2008_CONTIGUOUS "FALSE") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") set(SCC "cc") set(SCXX "CC") set(SFC "ftn") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/amdclanggpu_crusher.cmake b/cime_config/machines/cmake_macros/amdclanggpu_crusher.cmake index 5968c8627c64..6f3c0074798e 100644 --- a/cime_config/machines/cmake_macros/amdclanggpu_crusher.cmake +++ b/cime_config/machines/cmake_macros/amdclanggpu_crusher.cmake @@ -9,20 +9,18 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") -string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND SLIBS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") +string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") set(MPICXX "hipcc") set(SCXX "hipcc") -string(APPEND CXXFLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") -string(APPEND SLIBS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") +string(APPEND CMAKE_CXX_FLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_HIP=On -DKokkos_ARCH_ZEN3=On -DKokkos_ARCH_VEGA90A=On") set(USE_HIP "TRUE") -string(APPEND HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") +string(APPEND CMAKE_HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") diff --git a/cime_config/machines/cmake_macros/amdclanggpu_frontier.cmake b/cime_config/machines/cmake_macros/amdclanggpu_frontier.cmake index 5968c8627c64..6f3c0074798e 100644 --- a/cime_config/machines/cmake_macros/amdclanggpu_frontier.cmake +++ b/cime_config/machines/cmake_macros/amdclanggpu_frontier.cmake @@ -9,20 +9,18 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") -string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND SLIBS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") +string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CRAY_LIBSCI_PREFIX_DIR}/lib -lsci_amd") set(MPICXX "hipcc") set(SCXX "hipcc") -string(APPEND CXXFLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") -string(APPEND SLIBS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") +string(APPEND CMAKE_CXX_FLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_HIP=On -DKokkos_ARCH_ZEN3=On -DKokkos_ARCH_VEGA90A=On") set(USE_HIP "TRUE") -string(APPEND HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") +string(APPEND CMAKE_HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") diff --git a/cime_config/machines/cmake_macros/cray.cmake b/cime_config/machines/cmake_macros/cray.cmake index 22439785e4f7..2be947870fac 100644 --- a/cime_config/machines/cmake_macros/cray.cmake +++ b/cime_config/machines/cmake_macros/cray.cmake @@ -1,26 +1,18 @@ if (compile_threaded) - string(APPEND CFLAGS " -h omp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -g -O0") + string(APPEND CMAKE_C_FLAGS " -h omp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -g -O0") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRCRAY") -string(APPEND FC_AUTO_R8 " -s real64") -string(APPEND FFLAGS " -f free -em") +string(APPEND CMAKE_Fortran_FLAGS " -f free -em") if (compile_threaded) - string(APPEND FFLAGS " -h omp") + string(APPEND CMAKE_Fortran_FLAGS " -h omp") endif() if (NOT compile_threaded) - string(APPEND FFLAGS " -M1077") -endif() -if (DEBUG) - string(APPEND FFLAGS " -g -O0") + string(APPEND CMAKE_Fortran_FLAGS " -M1077") endif() -string(APPEND FFLAGS_NOOPT " -O0") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -O0") set(HAS_F2008_CONTIGUOUS "TRUE") -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition") if (compile_threaded) - string(APPEND LDFLAGS " -h omp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -h omp") endif() -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") diff --git a/cime_config/machines/cmake_macros/cray_theta.cmake b/cime_config/machines/cmake_macros/cray_theta.cmake index 655ece365ec6..2d857ae638ec 100644 --- a/cime_config/machines/cmake_macros/cray_theta.cmake +++ b/cime_config/machines/cmake_macros/cray_theta.cmake @@ -1,18 +1,11 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O1") - string(APPEND FFLAGS " -O1") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O1") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O1") if (COMP_NAME STREQUAL eam) - string(APPEND FFLAGS " -vector0") + string(APPEND CMAKE_Fortran_FLAGS " -vector0") endif() -set(CXX_LINKER "CXX") string(APPEND KOKKOS_OPTIONS " -DKokkos_INTERNAL_GCC_TOOLCHAIN=/opt/gcc/9.3.0/snos") if (compile_threaded) - string(APPEND CXXFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -g -Wall") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O1") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -Wall") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O1") diff --git a/cime_config/machines/cmake_macros/crayclang-scream.cmake b/cime_config/machines/cmake_macros/crayclang-scream.cmake index 70a815f34b4b..ab352a7e6c58 100644 --- a/cime_config/machines/cmake_macros/crayclang-scream.cmake +++ b/cime_config/machines/cmake_macros/crayclang-scream.cmake @@ -1,30 +1,24 @@ if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND CPPDEFS " -DYAKL_DEBUG") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRCRAY") -string(APPEND FC_AUTO_R8 " -s real64") # -em (default) generates MODULENAME.mod files -string(APPEND FFLAGS " -f free -N 255 -h byteswapio -em") +string(APPEND CMAKE_Fortran_FLAGS " -f free -N 255 -h byteswapio -em") if (NOT compile_threaded) # -M1077 flag used to suppress message about OpenMP directives # that are ignored for non-threaded builds. (-h omp inactive) # Details: `explain ftn-1077` - string(APPEND FFLAGS " -M1077") + string(APPEND CMAKE_Fortran_FLAGS " -M1077") endif() -string(APPEND FFLAGS_NOOPT " -O0") set(HAS_F2008_CONTIGUOUS "TRUE") -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition -h byteswapio") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition -h byteswapio") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-cpu.cmake b/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-cpu.cmake index e9ae066609a2..f8176ccb3d0b 100644 --- a/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-cpu.cmake +++ b/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-cpu.cmake @@ -1,12 +1,11 @@ if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() set(PIO_FILESYSTEM_HINTS "gpfs") -string(APPEND CXX_LIBS " -lstdc++") string(APPEND CPPDEFS " -DCPRCRAY") diff --git a/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-gpu.cmake b/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-gpu.cmake index 3cca240d9cc5..18564d4d301f 100644 --- a/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-gpu.cmake +++ b/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream-gpu.cmake @@ -1,28 +1,26 @@ if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() set(PIO_FILESYSTEM_HINTS "gpfs") -string(APPEND CXX_LIBS " -lstdc++") -set(CMAKE_C_COMPILER "cc") -set(CMAKE_Fortran_COMPILER "ftn") -set(CMAKE_CXX_COMPILER "hipcc") +set(MPICXX "hipcc") +set(SCXX "hipcc") -string(APPEND CXXFLAGS " -I${MPICH_DIR}/include") -string(APPEND LDFLAGS " -L${MPICH_DIR}/lib -lmpi -L/opt/cray/pe/mpich/8.1.16/gtl/lib -lmpi_gtl_hsa") +string(APPEND CMAKE_CXX_FLAGS " -I${MPICH_DIR}/include") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${MPICH_DIR}/lib -lmpi -L/opt/cray/pe/mpich/8.1.16/gtl/lib -lmpi_gtl_hsa") # For YAKL's -lroctx64 -lrocfft; the rocm module doesn't set this. -string(APPEND LDFLAGS " -L$ENV{ROCM_PATH}/lib") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ROCM_PATH}/lib") # 'NOT DEBUG': this resolves a crash in mct in docn init # 'DEBUG' casee, too: resolves a build error in elm/src/main/elm_varctl.F90 due to several OpenACC syntax errors #if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -hnoacc -hfp0 -hipa0") - string(APPEND FFLAGS " -O2 -hnoacc -hfp0 -hipa0") + string(APPEND CMAKE_C_FLAGS " -O2 -hnoacc -hfp0 -hipa0") + string(APPEND CMAKE_Fortran_FLAGS " -O2 -hnoacc -hfp0 -hipa0") #endif() string(APPEND CPPDEFS " -DCPRCRAY") diff --git a/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream.cmake b/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream.cmake index ad33ac5878ff..ef0d3303004b 100644 --- a/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream.cmake +++ b/cime_config/machines/cmake_macros/crayclang-scream_crusher-scream.cmake @@ -1,14 +1,13 @@ if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() if (COMP_NAME STREQUAL elm) - string(APPEND FFLAGS " -hfp0") + string(APPEND CMAKE_Fortran_FLAGS " -hfp0") endif() -string(APPEND FFLAGS " -hipa0 -hzero") -string(APPEND FFLAGS " -em -ef") +string(APPEND CMAKE_Fortran_FLAGS " -hipa0 -hzero") +string(APPEND CMAKE_Fortran_FLAGS " -em -ef") set(PIO_FILESYSTEM_HINTS "gpfs") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/crayclang.cmake b/cime_config/machines/cmake_macros/crayclang.cmake index d7e8a85d4e14..d41bab8d5d12 100644 --- a/cime_config/machines/cmake_macros/crayclang.cmake +++ b/cime_config/machines/cmake_macros/crayclang.cmake @@ -1,30 +1,24 @@ if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND CPPDEFS " -DYAKL_DEBUG") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRCRAY") -string(APPEND FC_AUTO_R8 " -s real64") # -em (default) generates MODULENAME.mod files -string(APPEND FFLAGS " -f free -em") +string(APPEND CMAKE_Fortran_FLAGS " -f free -em") if (NOT compile_threaded) # -M1077 flag used to suppress message about OpenMP directives # that are ignored for non-threaded builds. (-h omp inactive) # Details: `explain ftn-1077` - string(APPEND FFLAGS " -M1077") + string(APPEND CMAKE_Fortran_FLAGS " -M1077") endif() -string(APPEND FFLAGS_NOOPT " -O0") set(HAS_F2008_CONTIGUOUS "TRUE") -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition") set(MPICC "cc") set(MPICXX "CC") diff --git a/cime_config/machines/cmake_macros/crayclang_crusher.cmake b/cime_config/machines/cmake_macros/crayclang_crusher.cmake index 6292038ab681..7a5fb412cbb9 100644 --- a/cime_config/machines/cmake_macros/crayclang_crusher.cmake +++ b/cime_config/machines/cmake_macros/crayclang_crusher.cmake @@ -1,12 +1,10 @@ if (COMP_NAME STREQUAL elm) # See Land NaNs in conditionals: https://github.com/E3SM-Project/E3SM/issues/4996 - string(APPEND FFLAGS " -hfp0") + string(APPEND CMAKE_Fortran_FLAGS " -hfp0") endif() # Disable ipa and zero initialization are for other NaN isues: # https://github.com/E3SM-Project/E3SM/pull/5208 -string(APPEND FFLAGS " -hipa0 -hzero") +string(APPEND CMAKE_Fortran_FLAGS " -hipa0 -hzero") # -em -ef generates modulename.mod (lowercase files) to support # Scorpio installs -string(APPEND FFLAGS " -em -ef") - -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_Fortran_FLAGS " -em -ef") diff --git a/cime_config/machines/cmake_macros/crayclang_frontier.cmake b/cime_config/machines/cmake_macros/crayclang_frontier.cmake index 6292038ab681..7a5fb412cbb9 100644 --- a/cime_config/machines/cmake_macros/crayclang_frontier.cmake +++ b/cime_config/machines/cmake_macros/crayclang_frontier.cmake @@ -1,12 +1,10 @@ if (COMP_NAME STREQUAL elm) # See Land NaNs in conditionals: https://github.com/E3SM-Project/E3SM/issues/4996 - string(APPEND FFLAGS " -hfp0") + string(APPEND CMAKE_Fortran_FLAGS " -hfp0") endif() # Disable ipa and zero initialization are for other NaN isues: # https://github.com/E3SM-Project/E3SM/pull/5208 -string(APPEND FFLAGS " -hipa0 -hzero") +string(APPEND CMAKE_Fortran_FLAGS " -hipa0 -hzero") # -em -ef generates modulename.mod (lowercase files) to support # Scorpio installs -string(APPEND FFLAGS " -em -ef") - -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_Fortran_FLAGS " -em -ef") diff --git a/cime_config/machines/cmake_macros/crayclanggpu.cmake b/cime_config/machines/cmake_macros/crayclanggpu.cmake index ee1ed3f7d3ef..307085258f3e 100644 --- a/cime_config/machines/cmake_macros/crayclanggpu.cmake +++ b/cime_config/machines/cmake_macros/crayclanggpu.cmake @@ -16,7 +16,6 @@ # string(APPEND CPPDEFS " -DYAKL_DEBUG") # endif() # string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRCRAY") -# string(APPEND FC_AUTO_R8 " -s real64") # string(APPEND FFLAGS " -f free -em") # if (NOT compile_threaded) # # -M1077 flag used to suppress message about OpenMP directives @@ -27,8 +26,6 @@ # string(APPEND FFLAGS_NOOPT " -O0") # set(HAS_F2008_CONTIGUOUS "TRUE") # string(APPEND LDFLAGS " -Wl,--allow-multiple-definition") -# set(SUPPORTS_CXX "TRUE") -# set(CXX_LINKER "FORTRAN") # set(MPICC "cc") # set(MPICXX "hipcc") # set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/crayclanggpu_crusher.cmake b/cime_config/machines/cmake_macros/crayclanggpu_crusher.cmake index b53ebc3a2d2f..653938b81da9 100644 --- a/cime_config/machines/cmake_macros/crayclanggpu_crusher.cmake +++ b/cime_config/machines/cmake_macros/crayclanggpu_crusher.cmake @@ -11,63 +11,53 @@ if (COMP_NAME STREQUAL gptl) endif() if (compile_threaded) - string(APPEND FFLAGS " -fopenmp") - string(APPEND CFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND CPPDEFS " -DYAKL_DEBUG") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRCRAY") -string(APPEND FC_AUTO_R8 " -s real64") -string(APPEND FFLAGS " -f free -em") +string(APPEND CMAKE_Fortran_FLAGS " -f free -em") if (NOT compile_threaded) # -M1077 flag used to suppress message about OpenMP directives # that are ignored for non-threaded builds. (-h omp inactive) # Details: `explain ftn-1077` - string(APPEND FFLAGS " -M1077") + string(APPEND CMAKE_Fortran_FLAGS " -M1077") endif() -string(APPEND FFLAGS_NOOPT " -O0") set(HAS_F2008_CONTIGUOUS "TRUE") # -Wl,--allow-shlib-undefined was added to address rocm 5.4.3 Fortran linker issue: # /opt/rocm-5.4.3/lib/libhsa-runtime64.so.1: undefined reference to `std::condition_variable::wait(std::unique_lock&)@GLIBCXX_3.4.30' # AMD started building with GCC 12.2.0, which brings in a GLIBCXX symbol that isn't in CCE's default GCC toolchain. -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition -Wl,--allow-shlib-undefined") - -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition -Wl,--allow-shlib-undefined") # Switch to O3 for better performance # Using O2 to ensure passing tests -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (COMP_NAME STREQUAL elm) # See Land NaNs in conditionals: https://github.com/E3SM-Project/E3SM/issues/4996 - string(APPEND FFLAGS " -hfp0") + string(APPEND CMAKE_Fortran_FLAGS " -hfp0") endif() # -em -ef generates modulename.mod (lowercase files) to support # Scorpio installs # Disable ipa and zero initialization are for other NaN isues: # https://github.com/E3SM-Project/E3SM/pull/5208 -string(APPEND FFLAGS " -hipa0 -hzero -em -ef -hnoacc") +string(APPEND CMAKE_Fortran_FLAGS " -hipa0 -hzero -em -ef -hnoacc") -string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND CXXFLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") -string(APPEND SLIBS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") -string(APPEND SLIBS " -L$ENV{ROCM_PATH}/lib -lamdhip64") +string(APPEND CMAKE_CXX_FLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ROCM_PATH}/lib -lamdhip64") string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_HIP=On -DKokkos_ARCH_ZEN3=On -DKokkos_ARCH_VEGA90A=On") set(USE_HIP "TRUE") -string(APPEND HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") +string(APPEND CMAKE_HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") diff --git a/cime_config/machines/cmake_macros/crayclanggpu_frontier.cmake b/cime_config/machines/cmake_macros/crayclanggpu_frontier.cmake index 28fe05b151f6..32f125947b5c 100644 --- a/cime_config/machines/cmake_macros/crayclanggpu_frontier.cmake +++ b/cime_config/machines/cmake_macros/crayclanggpu_frontier.cmake @@ -11,63 +11,53 @@ if (COMP_NAME STREQUAL gptl) endif() if (compile_threaded) - string(APPEND FFLAGS " -fopenmp") - string(APPEND CFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND CPPDEFS " -DYAKL_DEBUG") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRCRAY") -string(APPEND FC_AUTO_R8 " -s real64") -string(APPEND FFLAGS " -f free -em") +string(APPEND CMAKE_Fortran_FLAGS " -f free -em") if (NOT compile_threaded) # -M1077 flag used to suppress message about OpenMP directives # that are ignored for non-threaded builds. (-h omp inactive) # Details: `explain ftn-1077` - string(APPEND FFLAGS " -M1077") + string(APPEND CMAKE_Fortran_FLAGS " -M1077") endif() -string(APPEND FFLAGS_NOOPT " -O0") set(HAS_F2008_CONTIGUOUS "TRUE") # -Wl,--allow-shlib-undefined was added to address rocm 5.4.3 Fortran linker issue: # /opt/rocm-5.4.3/lib/libhsa-runtime64.so.1: undefined reference to `std::condition_variable::wait(std::unique_lock&)@GLIBCXX_3.4.30' # AMD started building with GCC 12.2.0, which brings in a GLIBCXX symbol that isn't in CCE's default GCC toolchain. -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition -Wl,--allow-shlib-undefined") - -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition -Wl,--allow-shlib-undefined") # Switching to O3 for performance benchmarking # Will revisit any failing tests -if (NOT DEBUG) - string(APPEND CFLAGS " -O3") - string(APPEND CXXFLAGS " -O3") - string(APPEND FFLAGS " -O3") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O3") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O3") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O3") if (COMP_NAME STREQUAL elm) # See Land NaNs in conditionals: https://github.com/E3SM-Project/E3SM/issues/4996 - string(APPEND FFLAGS " -hfp0") + string(APPEND CMAKE_Fortran_FLAGS " -hfp0") endif() # -em -ef generates modulename.mod (lowercase files) to support # Scorpio installs # Disable ipa and zero initialization are for other NaN isues: # https://github.com/E3SM-Project/E3SM/pull/5208 -string(APPEND FFLAGS " -hipa0 -hzero -em -ef -hnoacc") +string(APPEND CMAKE_Fortran_FLAGS " -hipa0 -hzero -em -ef -hnoacc") -string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND CXXFLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") -string(APPEND SLIBS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") -string(APPEND SLIBS " -L$ENV{ROCM_PATH}/lib -lamdhip64") +string(APPEND CMAKE_CXX_FLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ROCM_PATH}/lib -lamdhip64") string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_HIP=On -DKokkos_ARCH_ZEN3=On -DKokkos_ARCH_VEGA90A=On") set(USE_HIP "TRUE") -string(APPEND HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") +string(APPEND CMAKE_HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") diff --git a/cime_config/machines/cmake_macros/fj.cmake b/cime_config/machines/cmake_macros/fj.cmake index 67322db271ee..51641b994e8d 100644 --- a/cime_config/machines/cmake_macros/fj.cmake +++ b/cime_config/machines/cmake_macros/fj.cmake @@ -1,31 +1,22 @@ if (compile_threaded) - string(APPEND CFLAGS " -Kopenmp") - string(APPEND CXXFLAGS " -Kopenmp") - string(APPEND FFLAGS " -Kopenmp") - string(APPEND LDFLAGS " -Kopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -g -Nquickdbg=subchk") - string(APPEND CXXFLAGS " -g -Nquickdbg=subchk") - string(APPEND FFLAGS " -g -Haefosux") - string(APPEND CPPDEFS "-DYAKL_DEBUG") -elseif (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2") + string(APPEND CMAKE_C_FLAGS " -Kopenmp") + string(APPEND CMAKE_CXX_FLAGS " -Kopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -Kopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -Kopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -g -Nquickdbg=subchk") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -Nquickdbg=subchk") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -Haefosux") +string(APPEND CPPDEFS_DEBUG "-DYAKL_DEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (COMP_NAME STREQUAL csm_share) - string(APPEND CFLAGS " -std=c99") + string(APPEND CMAKE_C_FLAGS " -std=c99") endif() -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -set(CXX_LIBS "--linkstl=libfjc++") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRFJ") -set(FC_AUTO_R8 "-CcdRR8") -set(FFLAGS_NOOPT " -O0") -set(FIXEDFLAGS "-Fixed") -set(FREEFLAGS "-Free") -set(HAS_F2008_CONTIGUOUS "FALSE") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Free") set(MPICC "mpifcc") set(MPICXX "mpiFCC") set(MPIFC "mpifrt") @@ -33,5 +24,5 @@ set(SCC "fcc") set(SCXX "FCC") set(SFC "frt") if (COMP_NAME MATCHES "^pio") - string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") + string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") endif() diff --git a/cime_config/machines/cmake_macros/gnu.cmake b/cime_config/machines/cmake_macros/gnu.cmake index 48a30dd42d9b..82828f39892d 100644 --- a/cime_config/machines/cmake_macros/gnu.cmake +++ b/cime_config/machines/cmake_macros/gnu.cmake @@ -1,51 +1,39 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") - string(APPEND CFLAGS "-mcmodel=small") - string(APPEND FFLAGS "-mcmodel=small") + string(APPEND CMAKE_C_FLAGS "-mcmodel=small") + string(APPEND CMAKE_Fortran_FLAGS "-mcmodel=small") elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") - string(APPEND CFLAGS " -mcmodel=large") - string(APPEND FFLAGS " -mcmodel=large") + string(APPEND CMAKE_C_FLAGS " -mcmodel=large") + string(APPEND CMAKE_Fortran_FLAGS " -mcmodel=large") else() - string(APPEND CFLAGS "-mcmodel=medium") - string(APPEND FFLAGS "-mcmodel=medium") + string(APPEND CMAKE_C_FLAGS "-mcmodel=medium") + string(APPEND CMAKE_Fortran_FLAGS "-mcmodel=medium") endif() -string(APPEND FFLAGS " -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") +string(APPEND CMAKE_Fortran_FLAGS " -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10) - string(APPEND FFLAGS " -fallow-argument-mismatch") + string(APPEND CMAKE_Fortran_FLAGS " -fallow-argument-mismatch") endif() string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU") if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") - string(APPEND CXXFLAGS " -g -Wall -fbacktrace") - string(APPEND FFLAGS " -g -Wall -fbacktrace -fcheck=bounds,pointer -ffpe-trap=invalid,zero,overflow") - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O") - string(APPEND CXXFLAGS " -O") - string(APPEND FFLAGS " -O") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -Wall -fbacktrace") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds,pointer -ffpe-trap=invalid,zero,overflow") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O") if (COMP_NAME STREQUAL csm_share) - string(APPEND CFLAGS " -std=c99") -endif() -if (COMP_NAME STREQUAL cism) - string(APPEND CMAKE_OPTS " -D CISM_GNU=ON") + string(APPEND CMAKE_C_FLAGS " -std=c99") endif() -set(CXX_LINKER "FORTRAN") -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -ffixed-form") -string(APPEND FREEFLAGS " -ffree-form") -set(HAS_F2008_CONTIGUOUS "FALSE") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -ffixed-form") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -ffree-form") set(MPICC "mpicc") set(MPICXX "mpicxx") set(MPIFC "mpif90") set(SCC "gcc") set(SCXX "g++") set(SFC "gfortran") -set(SUPPORTS_CXX "TRUE") diff --git a/cime_config/machines/cmake_macros/gnu9.cmake b/cime_config/machines/cmake_macros/gnu9.cmake index ad96d56c46be..02662c7d4c77 100644 --- a/cime_config/machines/cmake_macros/gnu9.cmake +++ b/cime_config/machines/cmake_macros/gnu9.cmake @@ -1,51 +1,30 @@ -string(APPEND CFLAGS " -mcmodel=medium") +string(APPEND CMAKE_C_FLAGS " -mcmodel=medium") if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") -endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O") + string(APPEND CMAKE_C_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O") if (COMP_NAME STREQUAL csm_share) - string(APPEND CFLAGS " -std=c99") + string(APPEND CMAKE_C_FLAGS " -std=c99") endif() -string(APPEND CXXFLAGS " -std=c++14") +string(APPEND CMAKE_CXX_FLAGS " -std=c++14") if (compile_threaded) - string(APPEND CXXFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -g -Wall -fbacktrace") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O") -endif() -if (COMP_NAME STREQUAL cism) - string(APPEND CMAKE_OPTS " -D CISM_GNU=ON") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -Wall -fbacktrace") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU") -if (DEBUG) - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() -set(CXX_LINKER "FORTRAN") -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS " -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") +string(APPEND CMAKE_Fortran_FLAGS " -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") if (compile_threaded) - string(APPEND FFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND FFLAGS " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") endif() -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -ffixed-form") -string(APPEND FREEFLAGS " -ffree-form") -set(HAS_F2008_CONTIGUOUS "FALSE") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -ffixed-form") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -ffree-form") if (compile_threaded) - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() set(MPICC "mpicc") set(MPICXX "mpicxx") @@ -53,4 +32,3 @@ set(MPIFC "mpif90") set(SCC "gcc") set(SCXX "g++") set(SFC "gfortran") -set(SUPPORTS_CXX "TRUE") diff --git a/cime_config/machines/cmake_macros/gnu9_mappy.cmake b/cime_config/machines/cmake_macros/gnu9_mappy.cmake index e827ad7a067b..945113b5dc84 100644 --- a/cime_config/machines/cmake_macros/gnu9_mappy.cmake +++ b/cime_config/machines/cmake_macros/gnu9_mappy.cmake @@ -1,13 +1,8 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (MPILIB STREQUAL mpi-serial AND NOT compile_threaded) set(PFUNIT_PATH "$ENV{SEMS_PFUNIT_ROOT}") endif() diff --git a/cime_config/machines/cmake_macros/gnu_WSL2.cmake b/cime_config/machines/cmake_macros/gnu_WSL2.cmake index 712670b06ea1..e69de29bb2d1 100644 --- a/cime_config/machines/cmake_macros/gnu_WSL2.cmake +++ b/cime_config/machines/cmake_macros/gnu_WSL2.cmake @@ -1 +0,0 @@ -set(CXX_LINKER "CXX") diff --git a/cime_config/machines/cmake_macros/gnu_alvarez.cmake b/cime_config/machines/cmake_macros/gnu_alvarez.cmake index 6ce5e2fa733f..226d07350a78 100644 --- a/cime_config/machines/cmake_macros/gnu_alvarez.cmake +++ b/cime_config/machines/cmake_macros/gnu_alvarez.cmake @@ -2,14 +2,8 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -g") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnu_anlgce-ub18.cmake b/cime_config/machines/cmake_macros/gnu_anlgce-ub18.cmake index 7761eb2aa51e..02365e4a1b59 100644 --- a/cime_config/machines/cmake_macros/gnu_anlgce-ub18.cmake +++ b/cime_config/machines/cmake_macros/gnu_anlgce-ub18.cmake @@ -1,8 +1,2 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() -set(ZLIB_PATH "$ENV{ZLIB_PATH}") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_anlgce.cmake b/cime_config/machines/cmake_macros/gnu_anlgce.cmake index 7761eb2aa51e..02365e4a1b59 100644 --- a/cime_config/machines/cmake_macros/gnu_anlgce.cmake +++ b/cime_config/machines/cmake_macros/gnu_anlgce.cmake @@ -1,8 +1,2 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() -set(ZLIB_PATH "$ENV{ZLIB_PATH}") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_anlworkstation.cmake b/cime_config/machines/cmake_macros/gnu_anlworkstation.cmake index 8e12c67a61c9..02365e4a1b59 100644 --- a/cime_config/machines/cmake_macros/gnu_anlworkstation.cmake +++ b/cime_config/machines/cmake_macros/gnu_anlworkstation.cmake @@ -1,9 +1,2 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() -set(SZIP_PATH "$ENV{SZIP_PATH}") -set(ZLIB_PATH "$ENV{ZLIB_PATH}") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_anvil.cmake b/cime_config/machines/cmake_macros/gnu_anvil.cmake index abaf456c5ecc..d3f99e211552 100644 --- a/cime_config/machines/cmake_macros/gnu_anvil.cmake +++ b/cime_config/machines/cmake_macros/gnu_anvil.cmake @@ -2,4 +2,3 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() set(PIO_FILESYSTEM_HINTS "gpfs") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_ascent.cmake b/cime_config/machines/cmake_macros/gnu_ascent.cmake index 9c8a5aeba195..58b5caf746db 100644 --- a/cime_config/machines/cmake_macros/gnu_ascent.cmake +++ b/cime_config/machines/cmake_macros/gnu_ascent.cmake @@ -1,14 +1,9 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -O0") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICXX "mpiCC") set(PIO_FILESYSTEM_HINTS "gpfs") diff --git a/cime_config/machines/cmake_macros/gnu_badger.cmake b/cime_config/machines/cmake_macros/gnu_badger.cmake index e3cef7b0dd05..f58661715275 100644 --- a/cime_config/machines/cmake_macros/gnu_badger.cmake +++ b/cime_config/machines/cmake_macros/gnu_badger.cmake @@ -1,3 +1,2 @@ set(PIO_FILESYSTEM_HINTS "lustre") set(MPICXX "mpic++") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_bebop.cmake b/cime_config/machines/cmake_macros/gnu_bebop.cmake index 715f201171e2..3252a469cd0a 100644 --- a/cime_config/machines/cmake_macros/gnu_bebop.cmake +++ b/cime_config/machines/cmake_macros/gnu_bebop.cmake @@ -1,4 +1,3 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_cades.cmake b/cime_config/machines/cmake_macros/gnu_cades.cmake index 4d93b6e8e9a6..0f06accfb87e 100644 --- a/cime_config/machines/cmake_macros/gnu_cades.cmake +++ b/cime_config/machines/cmake_macros/gnu_cades.cmake @@ -1,3 +1,3 @@ -string(APPEND FFLAGS " -O -fno-range-check") +string(APPEND CMAKE_Fortran_FLAGS " -O -fno-range-check") set(MPICXX "mpic++") set(SCXX "gcpp") diff --git a/cime_config/machines/cmake_macros/gnu_chicoma-cpu.cmake b/cime_config/machines/cmake_macros/gnu_chicoma-cpu.cmake index 90254fd08c09..a6148451eb76 100644 --- a/cime_config/machines/cmake_macros/gnu_chicoma-cpu.cmake +++ b/cime_config/machines/cmake_macros/gnu_chicoma-cpu.cmake @@ -2,15 +2,9 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") set(PIO_FILESYSTEM_HINTS "lustre") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -g") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnu_chrysalis.cmake b/cime_config/machines/cmake_macros/gnu_chrysalis.cmake index abaf456c5ecc..d3f99e211552 100644 --- a/cime_config/machines/cmake_macros/gnu_chrysalis.cmake +++ b/cime_config/machines/cmake_macros/gnu_chrysalis.cmake @@ -2,4 +2,3 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() set(PIO_FILESYSTEM_HINTS "gpfs") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_crusher.cmake b/cime_config/machines/cmake_macros/gnu_crusher.cmake index ba74699e1fdd..9b242243989b 100644 --- a/cime_config/machines/cmake_macros/gnu_crusher.cmake +++ b/cime_config/machines/cmake_macros/gnu_crusher.cmake @@ -9,10 +9,7 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -string(APPEND FFLAGS " -Wno-implicit-interface") +string(APPEND CMAKE_Fortran_FLAGS " -Wno-implicit-interface") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_docker-scream.cmake b/cime_config/machines/cmake_macros/gnu_docker-scream.cmake index 963b8c0fdb73..03bd340fb545 100644 --- a/cime_config/machines/cmake_macros/gnu_docker-scream.cmake +++ b/cime_config/machines/cmake_macros/gnu_docker-scream.cmake @@ -1,63 +1,40 @@ -set(AR "/opt/conda/bin/x86_64-conda-linux-gnu-ar") -string(APPEND CFLAGS " -mcmodel=medium") +string(APPEND CMAKE_C_FLAGS " -mcmodel=medium") if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") -endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O") + string(APPEND CMAKE_C_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O") if (COMP_NAME STREQUAL csm_share) - string(APPEND CFLAGS " -std=c99") + string(APPEND CMAKE_C_FLAGS " -std=c99") endif() -string(APPEND CXXFLAGS " -std=c++14") +string(APPEND CMAKE_CXX_FLAGS " -std=c++14") if (compile_threaded) - string(APPEND CXXFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -g -Wall -fbacktrace") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O") -endif() -if (COMP_NAME STREQUAL cism) - string(APPEND CMAKE_OPTS " -D CISM_GNU=ON") -endif() -string(APPEND CMAKE_OPTS " -D CMAKE_AR=/opt/conda/bin/x86_64-conda-linux-gnu-ar") -string(APPEND CMAKE_OPTS " -DCMAKE_Fortran_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib") -string(APPEND CMAKE_OPTS " -DCMAKE_C_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib") -string(APPEND CMAKE_OPTS " -DCMAKE_CXX_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") +endif() +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -Wall -fbacktrace") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O") +set(CMAKE_AR "/opt/conda/bin/x86_64-conda-linux-gnu-ar") +string(APPEND SPIO_CMAKE_OPTS " -DCMAKE_AR=/opt/conda/bin/x86_64-conda-linux-gnu-ar") +string(APPEND SPIO_CMAKE_OPTS " -DCMAKE_Fortran_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib") +string(APPEND SPIO_CMAKE_OPTS " -DCMAKE_C_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib") +string(APPEND SPIO_CMAKE_OPTS " -DCMAKE_CXX_COMPILER_RANLIB=/opt/conda/bin/x86_64-conda-linux-gnu-ranlib") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU") -if (DEBUG) - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() -set(CXX_LIBS "-lstdc++") -set(CXX_LINKER "FORTRAN") -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS " -I/opt/conda/include -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") +string(APPEND CMAKE_Fortran_FLAGS " -I/opt/conda/include -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") if (compile_threaded) - string(APPEND FFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND FFLAGS " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") endif() -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -ffixed-form") -string(APPEND FREEFLAGS " -ffree-form") -set(HAS_F2008_CONTIGUOUS "FALSE") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -ffixed-form") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -ffree-form") if (compile_threaded) - string(APPEND LDFLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() -set(SLIBS " -L/opt/conda/lib") +set(CMAKE_EXE_LINKER_FLAGS " -L/opt/conda/lib") set(MPICC "/opt/conda/bin/mpicc") set(MPICXX "/opt/conda/bin/mpicxx") set(MPIFC "/opt/conda/bin/mpif90") set(SCC "/opt/conda/bin/x86_64-conda-linux-gnu-gcc") set(SCXX "/opt/conda/bin/x86_64-conda-linux-gnu-g++") set(SFC "/opt/conda/bin/x86_64-conda-linux-gnu-gfortran") -set(SUPPORTS_CXX "TRUE") diff --git a/cime_config/machines/cmake_macros/gnu_eddi.cmake b/cime_config/machines/cmake_macros/gnu_eddi.cmake index 2caf327872f8..009de57acb5d 100644 --- a/cime_config/machines/cmake_macros/gnu_eddi.cmake +++ b/cime_config/machines/cmake_macros/gnu_eddi.cmake @@ -1,18 +1,12 @@ -set(SUPPORTS_CXX "TRUE") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_VPRINTF -DHAVE_GETTIMEOFDAY -DHAVE_BACKTRACE") endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -fno-unsafe-math-optimizations ") -endif() -if (DEBUG) - string(APPEND FFLAGS " -g -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow -Wall") -endif() -string(APPEND SLIBS " -lcurl") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -fno-unsafe-math-optimizations ") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow -Wall") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lcurl") if (MPILIB STREQUAL mpi-serial) set(SCC "gcc") endif() if (MPILIB STREQUAL mpi-serial) set(SFC "gfortran") endif() -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_frontier.cmake b/cime_config/machines/cmake_macros/gnu_frontier.cmake index ba74699e1fdd..9b242243989b 100644 --- a/cime_config/machines/cmake_macros/gnu_frontier.cmake +++ b/cime_config/machines/cmake_macros/gnu_frontier.cmake @@ -9,10 +9,7 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -string(APPEND FFLAGS " -Wno-implicit-interface") +string(APPEND CMAKE_Fortran_FLAGS " -Wno-implicit-interface") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_fugaku.cmake b/cime_config/machines/cmake_macros/gnu_fugaku.cmake index 9241b41d8d15..530075290883 100644 --- a/cime_config/machines/cmake_macros/gnu_fugaku.cmake +++ b/cime_config/machines/cmake_macros/gnu_fugaku.cmake @@ -1,9 +1,6 @@ string(APPEND CPPDEFS " -DHAVE_SLASHPROC") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() -set(CXX_LIBS "-lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (COMP_NAME MATCHES "^pio") - string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") + string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") endif() diff --git a/cime_config/machines/cmake_macros/gnu_gcp10.cmake b/cime_config/machines/cmake_macros/gnu_gcp10.cmake index 6f4cad7d618b..b4b93eabb63f 100644 --- a/cime_config/machines/cmake_macros/gnu_gcp10.cmake +++ b/cime_config/machines/cmake_macros/gnu_gcp10.cmake @@ -1,8 +1,5 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_VPRINTF -DHAVE_GETTIMEOFDAY -DHAVE_BACKTRACE -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -fno-unsafe-math-optimizations") -endif() -string(APPEND SLIBS " -L$ENV{CURL_PATH}/lib -lcurl") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -fno-unsafe-math-optimizations") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CURL_PATH}/lib -lcurl") diff --git a/cime_config/machines/cmake_macros/gnu_gcp12.cmake b/cime_config/machines/cmake_macros/gnu_gcp12.cmake index 6f4cad7d618b..b4b93eabb63f 100644 --- a/cime_config/machines/cmake_macros/gnu_gcp12.cmake +++ b/cime_config/machines/cmake_macros/gnu_gcp12.cmake @@ -1,8 +1,5 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_VPRINTF -DHAVE_GETTIMEOFDAY -DHAVE_BACKTRACE -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -fno-unsafe-math-optimizations") -endif() -string(APPEND SLIBS " -L$ENV{CURL_PATH}/lib -lcurl") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -fno-unsafe-math-optimizations") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CURL_PATH}/lib -lcurl") diff --git a/cime_config/machines/cmake_macros/gnu_grizzly.cmake b/cime_config/machines/cmake_macros/gnu_grizzly.cmake index e3cef7b0dd05..f58661715275 100644 --- a/cime_config/machines/cmake_macros/gnu_grizzly.cmake +++ b/cime_config/machines/cmake_macros/gnu_grizzly.cmake @@ -1,3 +1,2 @@ set(PIO_FILESYSTEM_HINTS "lustre") set(MPICXX "mpic++") -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_jlse.cmake b/cime_config/machines/cmake_macros/gnu_jlse.cmake index ca87d3a5377e..7c8b127f1f16 100644 --- a/cime_config/machines/cmake_macros/gnu_jlse.cmake +++ b/cime_config/machines/cmake_macros/gnu_jlse.cmake @@ -1,5 +1,3 @@ string(APPEND CPPDEFS " -DHAVE_SLASHPROC") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_lawrencium-lr6.cmake b/cime_config/machines/cmake_macros/gnu_lawrencium-lr6.cmake index ef00e08fbb3c..02365e4a1b59 100644 --- a/cime_config/machines/cmake_macros/gnu_lawrencium-lr6.cmake +++ b/cime_config/machines/cmake_macros/gnu_lawrencium-lr6.cmake @@ -1,7 +1,2 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++ -lmpi_cxx") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_lobata.cmake b/cime_config/machines/cmake_macros/gnu_lobata.cmake index a1128c8aa36c..c8d60ffbf716 100644 --- a/cime_config/machines/cmake_macros/gnu_lobata.cmake +++ b/cime_config/machines/cmake_macros/gnu_lobata.cmake @@ -1,15 +1,10 @@ -set(SUPPORTS_CXX "TRUE") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_VPRINTF -DHAVE_TIMES -DHAVE_GETTIMEOFDAY -DHAVE_BACKTRACE") endif() -string(APPEND SLIBS " -lcurl") -if (DEBUG) - string(APPEND FFLAGS " -g -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow") -else() - string(APPEND FFLAGS " -fno-unsafe-math-optimizations") -endif() +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lcurl") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -fno-unsafe-math-optimizations") if (MPILIB STREQUAL mpi-serial) set(SCC "gcc") set(SFC "gfortran") endif() -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnu_mappy.cmake b/cime_config/machines/cmake_macros/gnu_mappy.cmake index e827ad7a067b..945113b5dc84 100644 --- a/cime_config/machines/cmake_macros/gnu_mappy.cmake +++ b/cime_config/machines/cmake_macros/gnu_mappy.cmake @@ -1,13 +1,8 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (MPILIB STREQUAL mpi-serial AND NOT compile_threaded) set(PFUNIT_PATH "$ENV{SEMS_PFUNIT_ROOT}") endif() diff --git a/cime_config/machines/cmake_macros/gnu_melvin.cmake b/cime_config/machines/cmake_macros/gnu_melvin.cmake index e827ad7a067b..945113b5dc84 100644 --- a/cime_config/machines/cmake_macros/gnu_melvin.cmake +++ b/cime_config/machines/cmake_macros/gnu_melvin.cmake @@ -1,13 +1,8 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (MPILIB STREQUAL mpi-serial AND NOT compile_threaded) set(PFUNIT_PATH "$ENV{SEMS_PFUNIT_ROOT}") endif() diff --git a/cime_config/machines/cmake_macros/gnu_miller.cmake b/cime_config/machines/cmake_macros/gnu_miller.cmake index 6ce5e2fa733f..226d07350a78 100644 --- a/cime_config/machines/cmake_macros/gnu_miller.cmake +++ b/cime_config/machines/cmake_macros/gnu_miller.cmake @@ -2,14 +2,8 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -g") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnu_modex.cmake b/cime_config/machines/cmake_macros/gnu_modex.cmake index e15205225b94..73073f18dbf7 100644 --- a/cime_config/machines/cmake_macros/gnu_modex.cmake +++ b/cime_config/machines/cmake_macros/gnu_modex.cmake @@ -1,10 +1,6 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_VPRINTF -DHAVE_GETTIMEOFDAY -DHAVE_BACKTRACE") endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -fno-unsafe-math-optimizations") -endif() -if (DEBUG) - string(APPEND FFLAGS " -fbounds-check -ffpe-trap=invalid,zero,overflow") -endif() -string(APPEND SLIBS " -lcurl") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -fno-unsafe-math-optimizations") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -fbounds-check -ffpe-trap=invalid,zero,overflow") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lcurl") diff --git a/cime_config/machines/cmake_macros/gnu_muller.cmake b/cime_config/machines/cmake_macros/gnu_muller.cmake index 6ce5e2fa733f..44823a9a686a 100644 --- a/cime_config/machines/cmake_macros/gnu_muller.cmake +++ b/cime_config/machines/cmake_macros/gnu_muller.cmake @@ -2,14 +2,9 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -g") -endif() -string(APPEND CXX_LIBS " -lstdc++") +set(E3SM_LINK_WITH_FORTRAN "ON") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnu_pm-cpu.cmake b/cime_config/machines/cmake_macros/gnu_pm-cpu.cmake index 6ce5e2fa733f..226d07350a78 100644 --- a/cime_config/machines/cmake_macros/gnu_pm-cpu.cmake +++ b/cime_config/machines/cmake_macros/gnu_pm-cpu.cmake @@ -2,14 +2,8 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -g") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnu_pm-gpu.cmake b/cime_config/machines/cmake_macros/gnu_pm-gpu.cmake index 6ce5e2fa733f..226d07350a78 100644 --- a/cime_config/machines/cmake_macros/gnu_pm-gpu.cmake +++ b/cime_config/machines/cmake_macros/gnu_pm-gpu.cmake @@ -2,14 +2,8 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -g") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -g") -endif() -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -g") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -g") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnu_spock.cmake b/cime_config/machines/cmake_macros/gnu_spock.cmake index ab79175d059e..9ab0853b6fcd 100644 --- a/cime_config/machines/cmake_macros/gnu_spock.cmake +++ b/cime_config/machines/cmake_macros/gnu_spock.cmake @@ -1,8 +1,4 @@ -set(SUPPORTS_CXX "TRUE") -string(APPEND FFLAGS " -Wno-implicit-interface ") -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") - string(APPEND CFLAGS " -O2") -endif() +string(APPEND CMAKE_Fortran_FLAGS " -Wno-implicit-interface ") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") set(PIO_FILESYSTEM_HINTS "gpfs") diff --git a/cime_config/machines/cmake_macros/gnu_summit.cmake b/cime_config/machines/cmake_macros/gnu_summit.cmake index 9c8a5aeba195..58b5caf746db 100644 --- a/cime_config/machines/cmake_macros/gnu_summit.cmake +++ b/cime_config/machines/cmake_macros/gnu_summit.cmake @@ -1,14 +1,9 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -O0") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICXX "mpiCC") set(PIO_FILESYSTEM_HINTS "gpfs") diff --git a/cime_config/machines/cmake_macros/gnu_theta.cmake b/cime_config/machines/cmake_macros/gnu_theta.cmake index 4ad8e7d81844..b3efb5203c6b 100644 --- a/cime_config/machines/cmake_macros/gnu_theta.cmake +++ b/cime_config/machines/cmake_macros/gnu_theta.cmake @@ -1,15 +1,3 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND FFLAGS " -O0") -endif() -execute_process(COMMAND nf-config --flibs OUTPUT_VARIABLE SHELL_CMD_OUTPUT_BUILD_INTERNAL_IGNORE0 OUTPUT_STRIP_TRAILING_WHITESPACE) -string(APPEND SLIBS " ${SHELL_CMD_OUTPUT_BUILD_INTERNAL_IGNORE0}") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") diff --git a/cime_config/machines/cmake_macros/gnu_tulip.cmake b/cime_config/machines/cmake_macros/gnu_tulip.cmake index 58240f5509ef..fc6c3685f974 100644 --- a/cime_config/machines/cmake_macros/gnu_tulip.cmake +++ b/cime_config/machines/cmake_macros/gnu_tulip.cmake @@ -1,5 +1,4 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++") diff --git a/cime_config/machines/cmake_macros/gnugpu.cmake b/cime_config/machines/cmake_macros/gnugpu.cmake index 11dac962635e..e8d08889a09a 100644 --- a/cime_config/machines/cmake_macros/gnugpu.cmake +++ b/cime_config/machines/cmake_macros/gnugpu.cmake @@ -1,37 +1,27 @@ -string(APPEND CFLAGS " -mcmodel=medium") -string(APPEND FFLAGS " -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") +string(APPEND CMAKE_C_FLAGS " -mcmodel=medium") +string(APPEND CMAKE_Fortran_FLAGS " -mcmodel=medium -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10) - string(APPEND FFLAGS " -fallow-argument-mismatch") + string(APPEND CMAKE_Fortran_FLAGS " -fallow-argument-mismatch") endif() string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU") if (compile_threaded) - string(APPEND CFLAGS " -fopenmp") - string(APPEND CXXFLAGS " -fopenmp") - string(APPEND FFLAGS " -fopenmp") - string(APPEND LDFLAGS " -fopenmp") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") - string(APPEND FFLAGS " -O0 -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow") - string(APPEND CXXFLAGS " -O0 -g -Wall -fbacktrace") - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O") - string(APPEND CXXFLAGS " -O") - string(APPEND FFLAGS " -O") + string(APPEND CMAKE_C_FLAGS " -fopenmp") + string(APPEND CMAKE_CXX_FLAGS " -fopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") endif() +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=zero,overflow") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g -Wall -fbacktrace") +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O") if (COMP_NAME STREQUAL csm_share) - string(APPEND CFLAGS " -std=c99") + string(APPEND CMAKE_C_FLAGS " -std=c99") endif() -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LIBS " -lstdc++") -string(APPEND FC_AUTO_R8 " -fdefault-real-8") -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -ffixed-form") -string(APPEND FREEFLAGS " -ffree-form") -set(HAS_F2008_CONTIGUOUS "FALSE") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -ffixed-form") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -ffree-form") set(MPICC "mpicc") set(MPICXX "mpicxx") set(MPIFC "mpif90") diff --git a/cime_config/machines/cmake_macros/gnugpu_ascent.cmake b/cime_config/machines/cmake_macros/gnugpu_ascent.cmake index fb8eca4ed39d..330853a6d8a1 100644 --- a/cime_config/machines/cmake_macros/gnugpu_ascent.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_ascent.cmake @@ -1,15 +1,11 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") - string(APPEND CUDA_FLAGS " -O3 -arch sm_70 --use_fast_math") -endif() -if (DEBUG) - string(APPEND CUDA_FLAGS " -O0 -g -arch sm_70") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CUDA_FLAGS_RELEASE " -O3 -arch sm_70 --use_fast_math") +string(APPEND CMAKE_CUDA_FLAGS_DEBUG " -O0 -g -arch sm_70") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICXX "mpiCC") set(PIO_FILESYSTEM_HINTS "gpfs") set(USE_CUDA "TRUE") diff --git a/cime_config/machines/cmake_macros/gnugpu_crusher.cmake b/cime_config/machines/cmake_macros/gnugpu_crusher.cmake index 8cb67348c46e..bb213014b2f5 100644 --- a/cime_config/machines/cmake_macros/gnugpu_crusher.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_crusher.cmake @@ -9,19 +9,17 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -string(APPEND FFLAGS " -Wno-implicit-interface") +string(APPEND CMAKE_Fortran_FLAGS " -Wno-implicit-interface") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() -string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND CXXFLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") -string(APPEND SLIBS " -Wl,--copy-dt-needed-entries -L/opt/cray/pe/gcc-libs -lgfortran -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa ") +string(APPEND CMAKE_CXX_FLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--copy-dt-needed-entries -L/opt/cray/pe/gcc-libs -lgfortran -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa ") string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_HIP=On -DKokkos_ARCH_ZEN3=On -DKokkos_ARCH_VEGA90A=On") set(USE_HIP "TRUE") -string(APPEND HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") +string(APPEND CMAKE_HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") diff --git a/cime_config/machines/cmake_macros/gnugpu_frontier.cmake b/cime_config/machines/cmake_macros/gnugpu_frontier.cmake index 31bc97afd0e3..5991fce010a5 100644 --- a/cime_config/machines/cmake_macros/gnugpu_frontier.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_frontier.cmake @@ -9,19 +9,17 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() -string(APPEND FFLAGS " -Wno-implicit-interface") +string(APPEND CMAKE_Fortran_FLAGS " -Wno-implicit-interface") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() -string(APPEND CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND SPIO_CMAKE_OPTS " -DPIO_ENABLE_TOOLS:BOOL=OFF") -string(APPEND CXXFLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") -string(APPEND SLIBS " -Wl,--copy-dt-needed-entries -L/opt/cray/pe/gcc-libs -lgfortran -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa ") +string(APPEND CMAKE_CXX_FLAGS " -I$ENV{MPICH_DIR}/include --offload-arch=gfx90a") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--copy-dt-needed-entries -L/opt/cray/pe/gcc-libs -lgfortran -L$ENV{MPICH_DIR}/lib -lmpi -L$ENV{CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa ") string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_HIP=On -DKokkos_ARCH_ZEN3=On -DKokkos_ARCH_VEGA90A=On -DKokkos_ENABLE_OPENMP=Off") set(USE_HIP "TRUE") -string(APPEND HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") +string(APPEND CMAKE_HIP_FLAGS "${CXXFLAGS} -munsafe-fp-atomics -x hip") diff --git a/cime_config/machines/cmake_macros/gnugpu_muller.cmake b/cime_config/machines/cmake_macros/gnugpu_muller.cmake index 670e1a67a20e..e61e893d001b 100644 --- a/cime_config/machines/cmake_macros/gnugpu_muller.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_muller.cmake @@ -5,12 +5,10 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() string(APPEND CPPDEFS " -DTHRUST_IGNORE_CUB_VERSION_CHECK") -string(APPEND CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") +string(APPEND CMAKE_CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_AMPERE80=On -DKokkos_ENABLE_CUDA=On -DKokkos_ENABLE_CUDA_LAMBDA=On -DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_OPENMP=Off") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnugpu_pm-gpu.cmake b/cime_config/machines/cmake_macros/gnugpu_pm-gpu.cmake index 670e1a67a20e..e61e893d001b 100644 --- a/cime_config/machines/cmake_macros/gnugpu_pm-gpu.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_pm-gpu.cmake @@ -5,12 +5,10 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() string(APPEND CPPDEFS " -DTHRUST_IGNORE_CUB_VERSION_CHECK") -string(APPEND CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") +string(APPEND CMAKE_CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_AMPERE80=On -DKokkos_ENABLE_CUDA=On -DKokkos_ENABLE_CUDA_LAMBDA=On -DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_OPENMP=Off") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") set(MPICC "cc") set(MPICXX "CC") set(MPIFC "ftn") diff --git a/cime_config/machines/cmake_macros/gnugpu_summit.cmake b/cime_config/machines/cmake_macros/gnugpu_summit.cmake index 2a5e1b6ef51e..af7b5c3749d9 100644 --- a/cime_config/machines/cmake_macros/gnugpu_summit.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_summit.cmake @@ -1,16 +1,12 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") - string(APPEND CUDA_FLAGS " -O3 -arch sm_70 --use_fast_math") -endif() -if (DEBUG) - string(APPEND CUDA_FLAGS " -O0 -g -arch sm_70") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CUDA_FLAGS_RELEASE " -O3 -arch sm_70 --use_fast_math") +string(APPEND CMAKE_CUDA_FLAGS_DEBUG " -O0 -g -arch sm_70") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() string(APPEND CPPDEFS " -DTHRUST_IGNORE_CUB_VERSION_CHECK") -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICXX "mpiCC") set(PIO_FILESYSTEM_HINTS "gpfs") set(USE_CUDA "TRUE") diff --git a/cime_config/machines/cmake_macros/gnugpu_weaver.cmake b/cime_config/machines/cmake_macros/gnugpu_weaver.cmake index 87c25b27313b..30c14a1f92fc 100644 --- a/cime_config/machines/cmake_macros/gnugpu_weaver.cmake +++ b/cime_config/machines/cmake_macros/gnugpu_weaver.cmake @@ -1,12 +1,9 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() string(APPEND CPPDEFS " -DTHRUST_IGNORE_CUB_VERSION_CHECK") -string(APPEND CXX_LIBS " -lstdc++") set(MPICXX "mpiCC") #string(APPEND CUDA_FLAGS " -O3 -arch sm_70 --use_fast_math") set(USE_CUDA "TRUE") diff --git a/cime_config/machines/cmake_macros/ibm.cmake b/cime_config/machines/cmake_macros/ibm.cmake index cec9889c23a2..b1c97ece74f1 100644 --- a/cime_config/machines/cmake_macros/ibm.cmake +++ b/cime_config/machines/cmake_macros/ibm.cmake @@ -1,20 +1,15 @@ -string(APPEND CFLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") -string(APPEND CXXFLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") -if (NOT DEBUG) - string(APPEND CFLAGS " -O3") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2 -qstrict -Q") -endif() +string(APPEND CMAKE_C_FLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") +string(APPEND CMAKE_CXX_FLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O3") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -qstrict -Q") if (compile_threaded) - if (DEBUG) - string(APPEND CFLAGS " -qsmp=omp:noopt") - string(APPEND CXXFLAGS " -qsmp=omp:noopt") - string(APPEND FFLAGS " -qsmp=omp:noopt") - elseif (NOT DEBUG) - string(APPEND CFLAGS " -qsmp=omp") - string(APPEND CXXFLAGS " -qsmp=omp") - string(APPEND FFLAGS " -qsmp=omp") - endif() + string(APPEND CMAKE_C_FLAGS_DEBUG " -qsmp=omp:noopt") + string(APPEND CMAKE_CXX_FLAGS_DEBUG " -qsmp=omp:noopt") + string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -qsmp=omp:noopt") + string(APPEND CMAKE_C_FLAGS_RELEASE " -qsmp=omp") + string(APPEND CMAKE_CXX_FLAGS_RELEASE " -qsmp=omp") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qsmp=omp") endif() string(APPEND CPPDEFS " -DFORTRAN_SAME -DCPRIBM") @@ -22,12 +17,8 @@ if (COMP_NAME STREQUAL eam) string(APPEND CPPDEFS " -DUSE_CBOOL") endif() set(CPRE "-WF,-D") -string(APPEND FC_AUTO_R8 " -qrealsize=8") -string(APPEND FFLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") -if (DEBUG) - string(APPEND FFLAGS " -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en") -endif() -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -qsuffix=f=f -qfixed=132") -string(APPEND FREEFLAGS " -qsuffix=f=f90:cpp=F90") +string(APPEND CMAKE_Fortran_FLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -qsuffix=f=f -qfixed=132") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -qsuffix=f=f90:cpp=F90") set(HAS_F2008_CONTIGUOUS "TRUE") diff --git a/cime_config/machines/cmake_macros/ibm_ascent.cmake b/cime_config/machines/cmake_macros/ibm_ascent.cmake index 2687a326cb83..fb50d5b1f53d 100644 --- a/cime_config/machines/cmake_macros/ibm_ascent.cmake +++ b/cime_config/machines/cmake_macros/ibm_ascent.cmake @@ -2,13 +2,12 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND FFLAGS " -qzerosize -qfree=f90 -qxlf2003=polymorphic -qspillsize=2500 -qextname=flush") +string(APPEND CMAKE_Fortran_FLAGS " -qzerosize -qfree=f90 -qxlf2003=polymorphic -qspillsize=2500 -qextname=flush") if (COMP_NAME STREQUAL cice AND compile_threaded) - string(APPEND FFLAGS " -qsmp=omp:noopt") + string(APPEND CMAKE_Fortran_FLAGS " -qsmp=omp:noopt") endif() -string(APPEND LDFLAGS " -Wl,--relax -Wl,--allow-multiple-definition") -string(APPEND SLIBS " -lxlopt -lxl -lxlsmp -L$ENV{ESSL_PATH}/lib64 -lessl") -string(APPEND CXX_LIBS "-lstdc++ -L$ENV{OLCF_XLC_ROOT}/lib -libmc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--relax -Wl,--allow-multiple-definition") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lxlopt -lxl -lxlsmp -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICC "mpicc") set(MPICXX "mpiCC") set(MPIFC "mpif90") @@ -16,5 +15,4 @@ set(PIO_FILESYSTEM_HINTS "gpfs") set(SCC "xlc_r") set(SFC "xlf90_r") set(SCXX "xlc++_r") -set(SUPPORTS_CXX "TRUE") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_POWER9=On") diff --git a/cime_config/machines/cmake_macros/ibm_summit.cmake b/cime_config/machines/cmake_macros/ibm_summit.cmake index 2687a326cb83..fb50d5b1f53d 100644 --- a/cime_config/machines/cmake_macros/ibm_summit.cmake +++ b/cime_config/machines/cmake_macros/ibm_summit.cmake @@ -2,13 +2,12 @@ string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND FFLAGS " -qzerosize -qfree=f90 -qxlf2003=polymorphic -qspillsize=2500 -qextname=flush") +string(APPEND CMAKE_Fortran_FLAGS " -qzerosize -qfree=f90 -qxlf2003=polymorphic -qspillsize=2500 -qextname=flush") if (COMP_NAME STREQUAL cice AND compile_threaded) - string(APPEND FFLAGS " -qsmp=omp:noopt") + string(APPEND CMAKE_Fortran_FLAGS " -qsmp=omp:noopt") endif() -string(APPEND LDFLAGS " -Wl,--relax -Wl,--allow-multiple-definition") -string(APPEND SLIBS " -lxlopt -lxl -lxlsmp -L$ENV{ESSL_PATH}/lib64 -lessl") -string(APPEND CXX_LIBS "-lstdc++ -L$ENV{OLCF_XLC_ROOT}/lib -libmc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--relax -Wl,--allow-multiple-definition") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lxlopt -lxl -lxlsmp -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICC "mpicc") set(MPICXX "mpiCC") set(MPIFC "mpif90") @@ -16,5 +15,4 @@ set(PIO_FILESYSTEM_HINTS "gpfs") set(SCC "xlc_r") set(SFC "xlf90_r") set(SCXX "xlc++_r") -set(SUPPORTS_CXX "TRUE") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_POWER9=On") diff --git a/cime_config/machines/cmake_macros/ibmgpu.cmake b/cime_config/machines/cmake_macros/ibmgpu.cmake index 96d009a0fb1e..9a491fbca00c 100644 --- a/cime_config/machines/cmake_macros/ibmgpu.cmake +++ b/cime_config/machines/cmake_macros/ibmgpu.cmake @@ -1,24 +1,19 @@ -string(APPEND CFLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") -string(APPEND CXXFLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") -string(APPEND FFLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo -qzerosize -qfree=f90 -qxlf2003=polymorphic -qspillsize=2500 -qextname=flush") -if (NOT DEBUG) - string(APPEND CFLAGS " -O3") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2 -qstrict -Q") -endif() +string(APPEND CMAKE_C_FLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") +string(APPEND CMAKE_CXX_FLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo") +string(APPEND CMAKE_Fortran_FLAGS " -g -qfullpath -qmaxmem=-1 -qphsinfo -qzerosize -qfree=f90 -qxlf2003=polymorphic -qspillsize=2500 -qextname=flush") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O3") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -qstrict -Q") if (compile_threaded) - if (DEBUG) - string(APPEND CFLAGS " -qsmp=omp:noopt") - string(APPEND CXXFLAGS " -qsmp=omp:noopt") - string(APPEND FFLAGS " -qsmp=omp:noopt") - elseif (NOT DEBUG) - string(APPEND CFLAGS " -qsmp=omp") - string(APPEND CXXFLAGS " -qsmp=omp") - string(APPEND FFLAGS " -qsmp=omp") + string(APPEND CMAKE_C_FLAGS_DEBUG " -qsmp=omp:noopt") + string(APPEND CMAKE_CXX_FLAGS_DEBUG " -qsmp=omp:noopt") + string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -qsmp=omp:noopt") + string(APPEND CMAKE_C_FLAGS_RELEASE " -qsmp=omp") + string(APPEND CMAKE_CXX_FLAGS_RELEASE " -qsmp=omp") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qsmp=omp") if (COMP_NAME STREQUAL cice) - string(APPEND FFLAGS " -qsmp=omp:noopt") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qsmp=omp:noopt") endif() - endif() endif() string(APPEND CPPDEFS " -DFORTRAN_SAME -DCPRIBM -DLINUX") if (COMP_NAME STREQUAL eam) @@ -28,14 +23,11 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() set(CPRE "-WF,-D") -string(APPEND FC_AUTO_R8 " -qrealsize=8") -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -qsuffix=f=f -qfixed=132") -string(APPEND FREEFLAGS " -qsuffix=f=f90:cpp=F90") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -qsuffix=f=f -qfixed=132") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -qsuffix=f=f90:cpp=F90") set(HAS_F2008_CONTIGUOUS "TRUE") -string(APPEND LDFLAGS " -Wl,--relax -Wl,--allow-multiple-definition -qsmp -qoffload -lcudart -L$ENV{CUDA_DIR}/lib64") -string(APPEND SLIBS " -lxlopt -lxl -lxlsmp -L$ENV{ESSL_PATH}/lib64 -lessl") -string(APPEND CXX_LIBS " -lstdc++ -L$ENV{OLCF_XLC_ROOT}/lib -libmc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--relax -Wl,--allow-multiple-definition -qsmp -qoffload -lcudart -L$ENV{CUDA_DIR}/lib64") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lxlopt -lxl -lxlsmp -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICC "mpicc") set(MPICXX "mpiCC") set(MPIFC "mpif90") @@ -43,5 +35,4 @@ set(PIO_FILESYSTEM_HINTS "gpfs") set(SCC "xlc_r") set(SFC "xlf90_r") set(SCXX "xlc++_r") -set(SUPPORTS_CXX "TRUE") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_POWER9=On") diff --git a/cime_config/machines/cmake_macros/ibmgpu_ascent.cmake b/cime_config/machines/cmake_macros/ibmgpu_ascent.cmake index de1464d8af9b..522473844dc9 100644 --- a/cime_config/machines/cmake_macros/ibmgpu_ascent.cmake +++ b/cime_config/machines/cmake_macros/ibmgpu_ascent.cmake @@ -1,3 +1 @@ -if (DEBUG) - string(APPEND FFLAGS " -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en") diff --git a/cime_config/machines/cmake_macros/intel.cmake b/cime_config/machines/cmake_macros/intel.cmake index 4747193f844c..e9a808135fb2 100644 --- a/cime_config/machines/cmake_macros/intel.cmake +++ b/cime_config/machines/cmake_macros/intel.cmake @@ -1,29 +1,21 @@ -string(APPEND CFLAGS " -fp-model precise -std=gnu99") +string(APPEND CMAKE_C_FLAGS " -fp-model precise -std=gnu99") if (compile_threaded) - string(APPEND CFLAGS " -qopenmp") - string(APPEND CXXFLAGS " -qopenmp") - string(APPEND FFLAGS " -qopenmp") - string(APPEND LDFLAGS " -qopenmp") + string(APPEND CMAKE_C_FLAGS " -qopenmp") + string(APPEND CMAKE_CXX_FLAGS " -qopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -qopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -qopenmp") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -debug minimal") - string(APPEND CXXFLAGS " -O2") - string(APPEND FFLAGS " -O2 -debug minimal") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND FFLAGS " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -init=snan,arrays") -endif() -string(APPEND CXXFLAGS " -fp-model source") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -debug minimal") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -debug minimal") +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -init=snan,arrays") +string(APPEND CMAKE_CXX_FLAGS " -fp-model source") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRINTEL") -string(APPEND CXX_LDFLAGS " -cxxlib") -set(CXX_LINKER "FORTRAN") -string(APPEND FC_AUTO_R8 " -r8") -string(APPEND FFLAGS " -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -fp-model source") -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -fixed -132") -string(APPEND FREEFLAGS " -free") +string(APPEND CMAKE_Fortran_FLAGS " -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -fp-model source") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed -132") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -free") set(HAS_F2008_CONTIGUOUS "TRUE") set(MPICC "mpicc") set(MPICXX "mpicxx") @@ -31,4 +23,6 @@ set(MPIFC "mpif90") set(SCC "icc") set(SCXX "icpc") set(SFC "ifort") -set(SUPPORTS_CXX "TRUE") + +# Intel has to link fortran mains with fortran +set(E3SM_LINK_WITH_FORTRAN "TRUE") diff --git a/cime_config/machines/cmake_macros/intel18_snl-blake.cmake b/cime_config/machines/cmake_macros/intel18_snl-blake.cmake index 3b53e8b9cda2..de87699240c2 100644 --- a/cime_config/machines/cmake_macros/intel18_snl-blake.cmake +++ b/cime_config/machines/cmake_macros/intel18_snl-blake.cmake @@ -1,42 +1,26 @@ string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRINTEL") -string(APPEND CFLAGS " -xCORE_AVX512 -mkl -std=gnu99") -if (NOT DEBUG) - string(APPEND CFLAGS " -O3 -g -debug minimal") -endif() -if (DEBUG) - string(APPEND CFLAGS " -O0 -g") -endif() -string(APPEND CXXFLAGS " -xCORE_AVX512 -mkl") -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O3 -g -debug minimal") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -O0 -g") -endif() +string(APPEND CMAKE_C_FLAGS " -xCORE_AVX512 -mkl -std=gnu99") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O3 -g -debug minimal") +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS " -xCORE_AVX512 -mkl") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O3 -g -debug minimal") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") if (compile_threaded) - string(APPEND CXXFLAGS " -qopenmp") + string(APPEND CMAKE_CXX_FLAGS " -qopenmp") endif() -string(APPEND FFLAGS " -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -xCORE_AVX512 -mkl") +string(APPEND CMAKE_Fortran_FLAGS " -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -xCORE_AVX512 -mkl") if (compile_threaded) - string(APPEND FFLAGS " -qopenmp") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O3 -g -debug minimal") -endif() -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") + string(APPEND CMAKE_Fortran_FLAGS " -qopenmp") endif() -string(APPEND LDFLAGS " -lstdc++") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O3 -g -debug minimal") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lstdc++") if (compile_threaded) - string(APPEND LDFLAGS " -qopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -qopenmp") endif() -string(APPEND FIXEDFLAGS " -fixed -132") -string(APPEND FREEFLAGS " -free") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed -132") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -free") set(HAS_F2008_CONTIGUOUS "TRUE") -string(APPEND FC_AUTO_R8 " -r8") set(SFC "ifort") set(SCC "icc") set(SCXX "icpc") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LDFLAGS " -cxxlib") -set(SUPPORTS_CXX "TRUE") diff --git a/cime_config/machines/cmake_macros/intel_alvarez.cmake b/cime_config/machines/cmake_macros/intel_alvarez.cmake index ea5741b0b9a4..4505a59a0f92 100644 --- a/cime_config/machines/cmake_macros/intel_alvarez.cmake +++ b/cime_config/machines/cmake_macros/intel_alvarez.cmake @@ -2,7 +2,6 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") set(MPICC "cc") set(MPICXX "CC") @@ -16,24 +15,18 @@ set(SFC "ifx") # on the compiler ID or version, so for now, simply manually adjust the CXXFLAG setting for pm-cpu/intel # Try to manually remove -fp-model=source (and replace with -fp-model=precise) from CXXFLAGS #message(STATUS "ndk CXXFLAGS=${CXXFLAGS}") -set(CXXFLAGS " ") # hardcode it here to blank, then try to do same things as in intel.cmake +set(CMAKE_CXX_FLAGS " ") # hardcode it here to blank, then try to do same things as in intel.cmake if (compile_threaded) - string(APPEND CXXFLAGS " -qopenmp") + string(APPEND CMAKE_CXX_FLAGS " -qopenmp") endif() -if (DEBUG) - string(APPEND CXXFLAGS " -O0 -g") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -string(APPEND CXXFLAGS " -fp-model=precise") # and manually add precise +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS " -fp-model=precise") # and manually add precise #message(STATUS "ndk CXXFLAGS=${CXXFLAGS}") -string(APPEND FFLAGS " -fp-model=consistent -fimf-use-svml") -if (NOT DEBUG) +string(APPEND CMAKE_Fortran_FLAGS " -fp-model=consistent -fimf-use-svml") # string(APPEND FFLAGS " -qno-opt-dynamic-align") - string(APPEND FFLAGS " -g -traceback") - string(APPEND CXXFLAGS " -g -traceback") -endif() -string(APPEND FFLAGS " -DHAVE_ERF_INTRINSICS") -string(APPEND CXXFLAGS " -fp-model=consistent") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -g -traceback") + string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g -traceback") +string(APPEND CMAKE_Fortran_FLAGS " -DHAVE_ERF_INTRINSICS") +string(APPEND CMAKE_CXX_FLAGS " -fp-model=consistent") diff --git a/cime_config/machines/cmake_macros/intel_anvil.cmake b/cime_config/machines/cmake_macros/intel_anvil.cmake index 69c908c8be18..d96639725ac3 100644 --- a/cime_config/machines/cmake_macros/intel_anvil.cmake +++ b/cime_config/machines/cmake_macros/intel_anvil.cmake @@ -1,19 +1,14 @@ if (compile_threaded) - string(APPEND CFLAGS " -static-intel") - string(APPEND FFLAGS " -static-intel") - string(APPEND FFLAGS_NOOPT " -static-intel") - string(APPEND LDFLAGS " -static-intel") -endif() -if (compile_threaded AND DEBUG) - string(APPEND CFLAGS " -heap-arrays") - string(APPEND FFLAGS " -heap-arrays") + string(APPEND CMAKE_C_FLAGS " -static-intel") + string(APPEND CMAKE_Fortran_FLAGS " -static-intel") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -static-intel") + string(APPEND CMAKE_C_FLAGS_DEBUG " -heap-arrays") + string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -heap-arrays") endif() if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align") -endif() +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align") if (MPILIB STREQUAL impi) set(MPICC "mpiicc") set(MPICXX "mpiicpc") diff --git a/cime_config/machines/cmake_macros/intel_badger.cmake b/cime_config/machines/cmake_macros/intel_badger.cmake index 7cc9dad8c1b1..3d9a38f5886b 100644 --- a/cime_config/machines/cmake_macros/intel_badger.cmake +++ b/cime_config/machines/cmake_macros/intel_badger.cmake @@ -7,5 +7,4 @@ endif() if (NOT MPILIB STREQUAL impi) set(MPICXX "mpic++") endif() -string(APPEND SLIBS " -lpthread") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/intel_bebop.cmake b/cime_config/machines/cmake_macros/intel_bebop.cmake index 259a0d9e54a9..04b470743b84 100644 --- a/cime_config/machines/cmake_macros/intel_bebop.cmake +++ b/cime_config/machines/cmake_macros/intel_bebop.cmake @@ -1,10 +1,7 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++") -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align") -endif() +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align") if (MPILIB STREQUAL impi) set(MPICC "mpiicc") set(MPICXX "mpiicpc") diff --git a/cime_config/machines/cmake_macros/intel_cascade.cmake b/cime_config/machines/cmake_macros/intel_cascade.cmake index 36dd6361911a..7267a797b364 100644 --- a/cime_config/machines/cmake_macros/intel_cascade.cmake +++ b/cime_config/machines/cmake_macros/intel_cascade.cmake @@ -1,6 +1,4 @@ string(APPEND CONFIG_ARGS " --enable-filesystem-hints=lustre") string(APPEND CPPDEFS " -DLINUX") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv") set(PIO_FILESYSTEM_HINTS "lustre") diff --git a/cime_config/machines/cmake_macros/intel_chicoma-cpu.cmake b/cime_config/machines/cmake_macros/intel_chicoma-cpu.cmake index c790c2d15556..28380b1e94f5 100644 --- a/cime_config/machines/cmake_macros/intel_chicoma-cpu.cmake +++ b/cime_config/machines/cmake_macros/intel_chicoma-cpu.cmake @@ -1,7 +1,6 @@ set(PIO_FILESYSTEM_HINTS "lustre") string(APPEND CONFIG_ARGS " --host=cray") -string(APPEND SLIBS " -qmkl") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -qmkl") set(MPICC "cc") set(MPICXX "CC") diff --git a/cime_config/machines/cmake_macros/intel_chrysalis.cmake b/cime_config/machines/cmake_macros/intel_chrysalis.cmake index b816b55a61ba..9763f20474f8 100644 --- a/cime_config/machines/cmake_macros/intel_chrysalis.cmake +++ b/cime_config/machines/cmake_macros/intel_chrysalis.cmake @@ -1,23 +1,17 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND CFLAGS " -static-intel") -string(APPEND CFLAGS " -march=core-avx2") -if (NOT DEBUG) - string(APPEND CFLAGS " -O3") -endif() -string(APPEND CXXFLAGS " -static-intel") -string(APPEND CXXFLAGS " -axCORE-AVX2") -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O3") -endif() -string(APPEND FFLAGS " -static-intel") -string(APPEND FFLAGS " -axCORE-AVX2") -if (NOT DEBUG) - string(APPEND FFLAGS " -O3 -qno-opt-dynamic-align") -endif() +string(APPEND CMAKE_C_FLAGS " -static-intel") +string(APPEND CMAKE_C_FLAGS " -march=core-avx2") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O3") +string(APPEND CMAKE_CXX_FLAGS " -static-intel") +string(APPEND CMAKE_CXX_FLAGS " -axCORE-AVX2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O3") +string(APPEND CMAKE_Fortran_FLAGS " -static-intel") +string(APPEND CMAKE_Fortran_FLAGS " -axCORE-AVX2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O3 -qno-opt-dynamic-align") set(PIO_FILESYSTEM_HINTS "gpfs") -string(APPEND LDFLAGS " -static-intel") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -static-intel") if (MPILIB STREQUAL impi) set(MPICC "mpiicc") set(MPICXX "mpiicpc") diff --git a/cime_config/machines/cmake_macros/intel_compy.cmake b/cime_config/machines/cmake_macros/intel_compy.cmake index 2514a8e24246..d53723bf976e 100644 --- a/cime_config/machines/cmake_macros/intel_compy.cmake +++ b/cime_config/machines/cmake_macros/intel_compy.cmake @@ -1,12 +1,10 @@ if (COMP_NAME STREQUAL gptl) - string(APPEND CFLAGS " -DHAVE_SLASHPROC") + string(APPEND CMAKE_C_FLAGS " -DHAVE_SLASHPROC") endif() string(APPEND CPPDEFS " -DLINUX") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv -init=snan") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv -init=snan") set(PIO_FILESYSTEM_HINTS "lustre") -string(APPEND SLIBS " -lpmi ") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi ") if (MPILIB STREQUAL impi) set(MPICC "mpiicc") set(MPICXX "mpiicpc") diff --git a/cime_config/machines/cmake_macros/intel_constance.cmake b/cime_config/machines/cmake_macros/intel_constance.cmake index 44bdcf0ffc9e..4030965cd78a 100644 --- a/cime_config/machines/cmake_macros/intel_constance.cmake +++ b/cime_config/machines/cmake_macros/intel_constance.cmake @@ -1,6 +1,4 @@ string(APPEND CPPDEFS " -DLINUX") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv") set(PIO_FILESYSTEM_HINTS "lustre") -string(APPEND SLIBS " -lpmi") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi") diff --git a/cime_config/machines/cmake_macros/intel_grizzly.cmake b/cime_config/machines/cmake_macros/intel_grizzly.cmake index 7cc9dad8c1b1..3d9a38f5886b 100644 --- a/cime_config/machines/cmake_macros/intel_grizzly.cmake +++ b/cime_config/machines/cmake_macros/intel_grizzly.cmake @@ -7,5 +7,4 @@ endif() if (NOT MPILIB STREQUAL impi) set(MPICXX "mpic++") endif() -string(APPEND SLIBS " -lpthread") -string(APPEND CXX_LIBS " -lstdc++") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/intel_itasca.cmake b/cime_config/machines/cmake_macros/intel_itasca.cmake index 081c74c2e7b2..a8b1f4fa8f51 100644 --- a/cime_config/machines/cmake_macros/intel_itasca.cmake +++ b/cime_config/machines/cmake_macros/intel_itasca.cmake @@ -1,13 +1,13 @@ -string(APPEND CFLAGS " -O2 -I/soft/intel/x86_64/2013/composer_xe_2013/composer_xe_2013_sp1.3.174/mkl/include") +string(APPEND CMAKE_C_FLAGS " -O2 -I/soft/intel/x86_64/2013/composer_xe_2013/composer_xe_2013_sp1.3.174/mkl/include") if (compile_threaded) - string(APPEND CFLAGS " -openmp") + string(APPEND CMAKE_C_FLAGS " -openmp") endif() -string(APPEND FFLAGS " -I/soft/intel/x86_64/2013/composer_xe_2013/composer_xe_2013_sp1.3.174/mkl/include") +string(APPEND CMAKE_Fortran_FLAGS " -I/soft/intel/x86_64/2013/composer_xe_2013/composer_xe_2013_sp1.3.174/mkl/include") if (compile_threaded) - string(APPEND FFLAGS " -openmp") - string(APPEND LDFLAGS " -openmp") + string(APPEND CMAKE_Fortran_FLAGS " -openmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -openmp") endif() set(MPICC "mpiicc") set(MPICXX "mpiicpc") set(MPIFC "mpiifort") -string(APPEND SLIBS " -openmp -fPIC -lpthread -lm") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -openmp -fPIC -lpthread -lm") diff --git a/cime_config/machines/cmake_macros/intel_mappy.cmake b/cime_config/machines/cmake_macros/intel_mappy.cmake index 7b3b14351e1b..3252a469cd0a 100644 --- a/cime_config/machines/cmake_macros/intel_mappy.cmake +++ b/cime_config/machines/cmake_macros/intel_mappy.cmake @@ -1,4 +1,3 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++ -lmpi_cxx") diff --git a/cime_config/machines/cmake_macros/intel_melvin.cmake b/cime_config/machines/cmake_macros/intel_melvin.cmake index 7b3b14351e1b..3252a469cd0a 100644 --- a/cime_config/machines/cmake_macros/intel_melvin.cmake +++ b/cime_config/machines/cmake_macros/intel_melvin.cmake @@ -1,4 +1,3 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND CXX_LIBS " -lstdc++ -lmpi_cxx") diff --git a/cime_config/machines/cmake_macros/intel_narwhal.cmake b/cime_config/machines/cmake_macros/intel_narwhal.cmake index 6d4cdee2a189..0981ed709a75 100644 --- a/cime_config/machines/cmake_macros/intel_narwhal.cmake +++ b/cime_config/machines/cmake_macros/intel_narwhal.cmake @@ -1,6 +1,4 @@ -string(APPEND FFLAGS " -fp-model consistent -fimf-use-svml") -string(APPEND CXXFLAGS " -fp-model consistent") -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align") -endif() -string(APPEND SLIBS " -lpthread") +string(APPEND CMAKE_Fortran_FLAGS " -fp-model consistent -fimf-use-svml") +string(APPEND CMAKE_CXX_FLAGS " -fp-model consistent") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/intel_onyx.cmake b/cime_config/machines/cmake_macros/intel_onyx.cmake index 5a0cca777548..bc8639879b76 100644 --- a/cime_config/machines/cmake_macros/intel_onyx.cmake +++ b/cime_config/machines/cmake_macros/intel_onyx.cmake @@ -1,5 +1,3 @@ -string(APPEND FFLAGS " -fimf-use-svml") -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align") -endif() -string(APPEND SLIBS " -lpthread") +string(APPEND CMAKE_Fortran_FLAGS " -fimf-use-svml") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/intel_pm-cpu.cmake b/cime_config/machines/cmake_macros/intel_pm-cpu.cmake index ea5741b0b9a4..4505a59a0f92 100644 --- a/cime_config/machines/cmake_macros/intel_pm-cpu.cmake +++ b/cime_config/machines/cmake_macros/intel_pm-cpu.cmake @@ -2,7 +2,6 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") set(MPICC "cc") set(MPICXX "CC") @@ -16,24 +15,18 @@ set(SFC "ifx") # on the compiler ID or version, so for now, simply manually adjust the CXXFLAG setting for pm-cpu/intel # Try to manually remove -fp-model=source (and replace with -fp-model=precise) from CXXFLAGS #message(STATUS "ndk CXXFLAGS=${CXXFLAGS}") -set(CXXFLAGS " ") # hardcode it here to blank, then try to do same things as in intel.cmake +set(CMAKE_CXX_FLAGS " ") # hardcode it here to blank, then try to do same things as in intel.cmake if (compile_threaded) - string(APPEND CXXFLAGS " -qopenmp") + string(APPEND CMAKE_CXX_FLAGS " -qopenmp") endif() -if (DEBUG) - string(APPEND CXXFLAGS " -O0 -g") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -string(APPEND CXXFLAGS " -fp-model=precise") # and manually add precise +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS " -fp-model=precise") # and manually add precise #message(STATUS "ndk CXXFLAGS=${CXXFLAGS}") -string(APPEND FFLAGS " -fp-model=consistent -fimf-use-svml") -if (NOT DEBUG) +string(APPEND CMAKE_Fortran_FLAGS " -fp-model=consistent -fimf-use-svml") # string(APPEND FFLAGS " -qno-opt-dynamic-align") - string(APPEND FFLAGS " -g -traceback") - string(APPEND CXXFLAGS " -g -traceback") -endif() -string(APPEND FFLAGS " -DHAVE_ERF_INTRINSICS") -string(APPEND CXXFLAGS " -fp-model=consistent") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -g -traceback") + string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g -traceback") +string(APPEND CMAKE_Fortran_FLAGS " -DHAVE_ERF_INTRINSICS") +string(APPEND CMAKE_CXX_FLAGS " -fp-model=consistent") diff --git a/cime_config/machines/cmake_macros/intel_quartz.cmake b/cime_config/machines/cmake_macros/intel_quartz.cmake index cfafc2dcdfa6..8091325c6cec 100644 --- a/cime_config/machines/cmake_macros/intel_quartz.cmake +++ b/cime_config/machines/cmake_macros/intel_quartz.cmake @@ -1,6 +1,4 @@ string(APPEND CPPDEFS " -DNO_SHR_VMATH -DCNL") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv") -endif() -string(APPEND LDFLAGS " -L/usr/tce/packages/gcc/gcc-10.3.1-magic/lib/gcc/x86_64-redhat-linux/10/") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L/usr/tce/packages/gcc/gcc-10.3.1-magic/lib/gcc/x86_64-redhat-linux/10/") set(KOKKOS_OPTIONS "--with-serial --ldflags='-L/usr/tce/packages/gcc/gcc-10.3.1-magic/lib/gcc/x86_64-redhat-linux/10/'") diff --git a/cime_config/machines/cmake_macros/intel_ruby.cmake b/cime_config/machines/cmake_macros/intel_ruby.cmake index cfafc2dcdfa6..8091325c6cec 100644 --- a/cime_config/machines/cmake_macros/intel_ruby.cmake +++ b/cime_config/machines/cmake_macros/intel_ruby.cmake @@ -1,6 +1,4 @@ string(APPEND CPPDEFS " -DNO_SHR_VMATH -DCNL") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv") -endif() -string(APPEND LDFLAGS " -L/usr/tce/packages/gcc/gcc-10.3.1-magic/lib/gcc/x86_64-redhat-linux/10/") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L/usr/tce/packages/gcc/gcc-10.3.1-magic/lib/gcc/x86_64-redhat-linux/10/") set(KOKKOS_OPTIONS "--with-serial --ldflags='-L/usr/tce/packages/gcc/gcc-10.3.1-magic/lib/gcc/x86_64-redhat-linux/10/'") diff --git a/cime_config/machines/cmake_macros/intel_sooty.cmake b/cime_config/machines/cmake_macros/intel_sooty.cmake index 5c7cb680f7ef..e645487c0274 100644 --- a/cime_config/machines/cmake_macros/intel_sooty.cmake +++ b/cime_config/machines/cmake_macros/intel_sooty.cmake @@ -1,6 +1,4 @@ string(APPEND CPPDEFS " -DLINUX") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv -init=snan") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv -init=snan") set(PIO_FILESYSTEM_HINTS "lustre") -string(APPEND SLIBS " -lpmi") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi") diff --git a/cime_config/machines/cmake_macros/intel_stampede2.cmake b/cime_config/machines/cmake_macros/intel_stampede2.cmake index ae5dc8bfe772..ff958842a506 100644 --- a/cime_config/machines/cmake_macros/intel_stampede2.cmake +++ b/cime_config/machines/cmake_macros/intel_stampede2.cmake @@ -1,13 +1,10 @@ -string(APPEND CFLAGS " -xCORE-AVX2") +string(APPEND CMAKE_C_FLAGS " -xCORE-AVX2") string(APPEND CPPDEFS " -DLINUX") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_VPRINTF -DHAVE_BACKTRACE -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY") endif() string(APPEND CPPDEFS " -DARCH_MIC_KNL") -string(APPEND FFLAGS " -fp-model consistent -fimf-use-svml") -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align") -endif() -string(APPEND FFLAGS " -xCORE-AVX2") -set(PETSC_PATH "$ENV{PETSC_DIR}") -string(APPEND SLIBS " -lpthread") +string(APPEND CMAKE_Fortran_FLAGS " -fp-model consistent -fimf-use-svml") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align") +string(APPEND CMAKE_Fortran_FLAGS " -xCORE-AVX2") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/intel_tahoma.cmake b/cime_config/machines/cmake_macros/intel_tahoma.cmake index 51d3550c0645..0bfed9e947f1 100644 --- a/cime_config/machines/cmake_macros/intel_tahoma.cmake +++ b/cime_config/machines/cmake_macros/intel_tahoma.cmake @@ -1,12 +1,10 @@ if (COMP_NAME STREQUAL gptl) - string(APPEND CFLAGS " -DHAVE_SLASHPROC") + string(APPEND CMAKE_C_FLAGS " -DHAVE_SLASHPROC") endif() string(APPEND CPPDEFS " -DLINUX") -if (DEBUG) - string(APPEND FFLAGS " -check all -ftrapuv -init=snan") -endif() -string(APPEND SLIBS " -L$ENV{CURL_PATH}/lib -lcurl") -string(APPEND SLIBS " -lpmi") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -check all -ftrapuv -init=snan") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{CURL_PATH}/lib -lcurl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi") set(PIO_FILESYSTEM_HINTS "lustre") diff --git a/cime_config/machines/cmake_macros/intel_theta.cmake b/cime_config/machines/cmake_macros/intel_theta.cmake index 0d6fbb8c2846..6913b2eb2698 100644 --- a/cime_config/machines/cmake_macros/intel_theta.cmake +++ b/cime_config/machines/cmake_macros/intel_theta.cmake @@ -1,11 +1,9 @@ string(APPEND CONFIG_ARGS " --host=cray") string(APPEND CPPDEFS " -DARCH_MIC_KNL") -string(APPEND FFLAGS " -fp-model consistent -fimf-use-svml=true") -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align -fp-speculation=off") -endif() -string(APPEND FFLAGS " -DHAVE_ERF_INTRINSICS") +string(APPEND CMAKE_Fortran_FLAGS " -fp-model consistent -fimf-use-svml=true") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align -fp-speculation=off") +string(APPEND CMAKE_Fortran_FLAGS " -DHAVE_ERF_INTRINSICS") set(SCC "icc") set(SCXX "icpc") set(SFC "ifort") -string(APPEND SLIBS " -lpthread") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/intel_warhawk.cmake b/cime_config/machines/cmake_macros/intel_warhawk.cmake index 6d4cdee2a189..0981ed709a75 100644 --- a/cime_config/machines/cmake_macros/intel_warhawk.cmake +++ b/cime_config/machines/cmake_macros/intel_warhawk.cmake @@ -1,6 +1,4 @@ -string(APPEND FFLAGS " -fp-model consistent -fimf-use-svml") -string(APPEND CXXFLAGS " -fp-model consistent") -if (NOT DEBUG) - string(APPEND FFLAGS " -qno-opt-dynamic-align") -endif() -string(APPEND SLIBS " -lpthread") +string(APPEND CMAKE_Fortran_FLAGS " -fp-model consistent -fimf-use-svml") +string(APPEND CMAKE_CXX_FLAGS " -fp-model consistent") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -qno-opt-dynamic-align") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpthread") diff --git a/cime_config/machines/cmake_macros/nag.cmake b/cime_config/machines/cmake_macros/nag.cmake index 9f9a8d77aa9a..6707b8440b56 100644 --- a/cime_config/machines/cmake_macros/nag.cmake +++ b/cime_config/machines/cmake_macros/nag.cmake @@ -1,27 +1,19 @@ -if (DEBUG) - string(APPEND CFLAGS " -g") -endif() -string(APPEND CFLAGS " -std=c99") +string(APPEND CMAKE_C_FLAGS_DEBUG " -g") +string(APPEND CMAKE_C_FLAGS " -std=c99") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_CRAY_POINTERS -DNO_SHR_VMATH -DCPRNAG") -string(APPEND FC_AUTO_R8 " -r8") -string(APPEND FFLAGS " -wmismatch=mpi_send,mpi_recv,mpi_bcast,mpi_allreduce,mpi_reduce,mpi_isend,mpi_irecv,mpi_irsend,mpi_rsend,mpi_gatherv,mpi_gather,mpi_scatterv,mpi_allgather,mpi_alltoallv,mpi_file_read_all,mpi_file_write_all,mpibcast,mpiscatterv,mpi_alltoallw,nfmpi_get_vara_all,NFMPI_IPUT_VARA,NFMPI_GET_VAR_ALL,NFMPI_PUT_VARA,NFMPI_PUT_ATT_REAL,NFMPI_PUT_ATT_DOUBLE,NFMPI_PUT_ATT_INT,NFMPI_GET_ATT_REAL,NFMPI_GET_ATT_INT,NFMPI_GET_ATT_DOUBLE,NFMPI_PUT_VARA_DOUBLE_ALL,NFMPI_PUT_VARA_REAL_ALL,NFMPI_PUT_VARA_INT_ALL -convert=BIG_ENDIAN") -if (NOT DEBUG) - string(APPEND FFLAGS " -ieee=full -O2") -endif() -if (DEBUG) - string(APPEND FFLAGS " -C=all -g -time -f2003 -ieee=stop") -endif() -if (DEBUG AND NOT compile_threaded) - string(APPEND FFLAGS " -gline") -endif() +string(APPEND CMAKE_Fortran_FLAGS " -wmismatch=mpi_send,mpi_recv,mpi_bcast,mpi_allreduce,mpi_reduce,mpi_isend,mpi_irecv,mpi_irsend,mpi_rsend,mpi_gatherv,mpi_gather,mpi_scatterv,mpi_allgather,mpi_alltoallv,mpi_file_read_all,mpi_file_write_all,mpibcast,mpiscatterv,mpi_alltoallw,nfmpi_get_vara_all,NFMPI_IPUT_VARA,NFMPI_GET_VAR_ALL,NFMPI_PUT_VARA,NFMPI_PUT_ATT_REAL,NFMPI_PUT_ATT_DOUBLE,NFMPI_PUT_ATT_INT,NFMPI_GET_ATT_REAL,NFMPI_GET_ATT_INT,NFMPI_GET_ATT_DOUBLE,NFMPI_PUT_VARA_DOUBLE_ALL,NFMPI_PUT_VARA_REAL_ALL,NFMPI_PUT_VARA_INT_ALL -convert=BIG_ENDIAN") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -ieee=full -O2") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -C=all -g -time -f2003 -ieee=stop") + if (NOT compile_threaded) + string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -gline") + endif() if (compile_threaded) - string(APPEND FFLAGS " -openmp") + string(APPEND CMAKE_Fortran_FLAGS " -openmp") endif() -string(APPEND FIXEDFLAGS " -fixed") -string(APPEND FREEFLAGS " -free") -set(HAS_F2008_CONTIGUOUS "FALSE") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -free") if (compile_threaded) - string(APPEND LDFLAGS " -openmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -openmp") endif() set(MPICC "mpicc") set(MPIFC "mpif90") diff --git a/cime_config/machines/cmake_macros/nag_constance.cmake b/cime_config/machines/cmake_macros/nag_constance.cmake index edebba16c33d..3c13ba865422 100644 --- a/cime_config/machines/cmake_macros/nag_constance.cmake +++ b/cime_config/machines/cmake_macros/nag_constance.cmake @@ -1,12 +1,6 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -kind=byte") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -kind=byte") string(APPEND CPPDEFS " -DLINUX") -if (NOT DEBUG) - string(APPEND FFLAGS " -kind=byte") -endif() -if (DEBUG) - string(APPEND FFLAGS " -O0 -v") -endif() +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -kind=byte") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -v") set(PIO_FILESYSTEM_HINTS "lustre") -string(APPEND SLIBS " -lpmi") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi") diff --git a/cime_config/machines/cmake_macros/nvidia.cmake b/cime_config/machines/cmake_macros/nvidia.cmake index d9f8e5ebf142..56097c8ee683 100644 --- a/cime_config/machines/cmake_macros/nvidia.cmake +++ b/cime_config/machines/cmake_macros/nvidia.cmake @@ -5,37 +5,19 @@ set(SCC "nvcc") set(SCXX "nvc++") set(SFC "nvfortran") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRNVIDIA") -if (NOT DEBUG) - string(APPEND CFLAGS " -O0 -Mnofma -Mvect=nosimd") -endif() -if (DEBUG) - string(APPEND CFLAGS " -g") -endif() -string(APPEND FFLAGS " -i4 -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -DHAVE_IEEE_ARITHMETIC -Mallocatable=03 -DNO_R16 -traceback") -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -Ktrap=fp -Mbounds -Kieee") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O1") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -g -O0 -Mnofma -Wall -Kieee -traceback") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O0 -Mnofma -Mvect=nosimd") +string(APPEND CMAKE_C_FLAGS_DEBUG " -g") +string(APPEND CMAKE_Fortran_FLAGS " -i4 -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -DHAVE_IEEE_ARITHMETIC -Mallocatable=03 -DNO_R16 -traceback") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -Ktrap=fp -Mbounds -Kieee") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O1") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -O0 -Mnofma -Wall -Kieee -traceback") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") if (compile_threaded) - string(APPEND FFLAGS " -mp") - string(APPEND CFLAGS " -mp") - string(APPEND CXXFLAGS " -mp") - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_Fortran_FLAGS " -mp") + string(APPEND CMAKE_C_FLAGS " -mp") + string(APPEND CMAKE_CXX_FLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() -set(CXX_LINKER "CXX") -string(APPEND CXX_LIBS " -lstdc++") -string(APPEND FC_AUTO_R8 " -r8") -string(APPEND FFLAGS_NOOPT " -O0 -Mnofma") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfree") -set(HAS_F2008_CONTIGUOUS "FALSE") -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition") -set(SUPPORTS_CXX "TRUE") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfree") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition") diff --git a/cime_config/machines/cmake_macros/nvidia_alvarez.cmake b/cime_config/machines/cmake_macros/nvidia_alvarez.cmake index 8aba3b5f6d57..1818df0707f0 100644 --- a/cime_config/machines/cmake_macros/nvidia_alvarez.cmake +++ b/cime_config/machines/cmake_macros/nvidia_alvarez.cmake @@ -2,16 +2,9 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -g") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -g") if (compile_threaded) string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_OPENMP=Off") # work-around for nvidia as kokkos is not passing "-mp" for threaded build endif() diff --git a/cime_config/machines/cmake_macros/nvidia_chicoma-cpu.cmake b/cime_config/machines/cmake_macros/nvidia_chicoma-cpu.cmake index 77db876cb00a..b8b0bef18977 100644 --- a/cime_config/machines/cmake_macros/nvidia_chicoma-cpu.cmake +++ b/cime_config/machines/cmake_macros/nvidia_chicoma-cpu.cmake @@ -2,17 +2,10 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") set(PIO_FILESYSTEM_HINTS "lustre") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (compile_threaded) string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_OPENMP=Off") # work-around for nvidia as kokkos is not passing "-mp" for threaded build endif() diff --git a/cime_config/machines/cmake_macros/nvidia_muller.cmake b/cime_config/machines/cmake_macros/nvidia_muller.cmake index a8b9f5cdcf38..53ace59f13f0 100644 --- a/cime_config/machines/cmake_macros/nvidia_muller.cmake +++ b/cime_config/machines/cmake_macros/nvidia_muller.cmake @@ -2,16 +2,10 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +set(E3SM_LINK_WITH_FORTRAN "ON") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (compile_threaded) string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_OPENMP=Off") # work-around for nvidia as kokkos is not passing "-mp" for threaded build endif() diff --git a/cime_config/machines/cmake_macros/nvidia_pm-cpu.cmake b/cime_config/machines/cmake_macros/nvidia_pm-cpu.cmake index 8aba3b5f6d57..1818df0707f0 100644 --- a/cime_config/machines/cmake_macros/nvidia_pm-cpu.cmake +++ b/cime_config/machines/cmake_macros/nvidia_pm-cpu.cmake @@ -2,16 +2,9 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -g") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -g") if (compile_threaded) string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_OPENMP=Off") # work-around for nvidia as kokkos is not passing "-mp" for threaded build endif() diff --git a/cime_config/machines/cmake_macros/nvidia_pm-gpu.cmake b/cime_config/machines/cmake_macros/nvidia_pm-gpu.cmake index a8b9f5cdcf38..13d3b42fc48b 100644 --- a/cime_config/machines/cmake_macros/nvidia_pm-gpu.cmake +++ b/cime_config/machines/cmake_macros/nvidia_pm-gpu.cmake @@ -2,16 +2,9 @@ string(APPEND CONFIG_ARGS " --host=cray") if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() -set(CXX_LINKER "FORTRAN") -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") if (compile_threaded) string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_OPENMP=Off") # work-around for nvidia as kokkos is not passing "-mp" for threaded build endif() diff --git a/cime_config/machines/cmake_macros/nvidiagpu.cmake b/cime_config/machines/cmake_macros/nvidiagpu.cmake index 3950961a6216..31d43e179ff2 100644 --- a/cime_config/machines/cmake_macros/nvidiagpu.cmake +++ b/cime_config/machines/cmake_macros/nvidiagpu.cmake @@ -5,46 +5,26 @@ set(SCC "nvcc") set(SCXX "nvc++") set(SFC "nvfortran") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRNVIDIA") -if (DEBUG) - string(APPEND CPPDEFS " -DYAKL_DEBUG") -endif() +string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") if (compile_threaded) - string(APPEND CFLAGS " -mp") -endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") + string(APPEND CMAKE_C_FLAGS " -mp") endif() -if (DEBUG) - string(APPEND CFLAGS " -g") -endif() -string(APPEND FFLAGS " -i4 -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -DHAVE_IEEE_ARITHMETIC -Mallocatable=03 -DNO_R16 -traceback") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_C_FLAGS_DEBUG " -g") +string(APPEND CMAKE_Fortran_FLAGS " -i4 -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -DHAVE_IEEE_ARITHMETIC -Mallocatable=03 -DNO_R16 -traceback") if (compile_threaded) - string(APPEND FFLAGS " -mp") -endif() -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -Ktrap=fp -Mbounds -Kieee") -endif() -if (NOT DEBUG) - string(APPEND FFLAGS " -O2 -DHAVE_IEEE_ARITHMETIC") + string(APPEND CMAKE_Fortran_FLAGS " -mp") endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -Ktrap=fp -Mbounds -Kieee") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -DHAVE_IEEE_ARITHMETIC") if (compile_threaded) - string(APPEND CXXFLAGS " -mp") -endif() -if (DEBUG) - string(APPEND CXXFLAGS " -g -O0 -Mnofma -Wall -traceback") -endif() -if (NOT DEBUG) - string(APPEND CXXFLAGS " -O2") + string(APPEND CMAKE_CXX_FLAGS " -mp") endif() -set(CXX_LINKER "CXX") -string(APPEND CXX_LIBS " -lstdc++") -string(APPEND FC_AUTO_R8 " -r8") -string(APPEND FFLAGS_NOOPT " -O0 -Mnofma") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfree") -set(HAS_F2008_CONTIGUOUS "FALSE") -string(APPEND LDFLAGS " -Wl,--allow-multiple-definition") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -O0 -Mnofma -Wall -traceback") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfree") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--allow-multiple-definition") if (compile_threaded) - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() -set(SUPPORTS_CXX "TRUE") diff --git a/cime_config/machines/cmake_macros/nvidiagpu_muller.cmake b/cime_config/machines/cmake_macros/nvidiagpu_muller.cmake index 98ba1d5227e1..b1d7ad8da897 100644 --- a/cime_config/machines/cmake_macros/nvidiagpu_muller.cmake +++ b/cime_config/machines/cmake_macros/nvidiagpu_muller.cmake @@ -5,8 +5,8 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() string(APPEND CPPDEFS " -DTHRUST_IGNORE_CUB_VERSION_CHECK") -string(APPEND CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") +set(E3SM_LINK_WITH_FORTRAN "ON") set(SCC "cc") set(SCXX "CC") set(SFC "ftn") diff --git a/cime_config/machines/cmake_macros/nvidiagpu_pm-gpu.cmake b/cime_config/machines/cmake_macros/nvidiagpu_pm-gpu.cmake index 98ba1d5227e1..2bf105ca8a7e 100644 --- a/cime_config/machines/cmake_macros/nvidiagpu_pm-gpu.cmake +++ b/cime_config/machines/cmake_macros/nvidiagpu_pm-gpu.cmake @@ -5,8 +5,7 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_SLASHPROC -DHAVE_GETTIMEOFDAY") endif() string(APPEND CPPDEFS " -DTHRUST_IGNORE_CUB_VERSION_CHECK") -string(APPEND CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") -set(CXX_LINKER "FORTRAN") +string(APPEND CMAKE_CUDA_FLAGS " -ccbin CC -O2 -arch sm_80 --use_fast_math") set(SCC "cc") set(SCXX "CC") set(SFC "ftn") diff --git a/cime_config/machines/cmake_macros/oneapi-ifx.cmake b/cime_config/machines/cmake_macros/oneapi-ifx.cmake index ce8c8cf1cbc3..28852175a4ec 100644 --- a/cime_config/machines/cmake_macros/oneapi-ifx.cmake +++ b/cime_config/machines/cmake_macros/oneapi-ifx.cmake @@ -1,30 +1,21 @@ if (compile_threaded) - string(APPEND CFLAGS " -qopenmp") - string(APPEND FFLAGS " -qopenmp") - string(APPEND CXXFLAGS " -qopenmp") - string(APPEND LDFLAGS " -qopenmp") + string(APPEND CMAKE_C_FLAGS " -qopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -qopenmp") + string(APPEND CMAKE_CXX_FLAGS " -qopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -qopenmp") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") - string(APPEND CFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") -endif() -string(APPEND CFLAGS " -traceback -fp-model precise -std=gnu99") -string(APPEND CXXFLAGS " -traceback -fp-model precise") -string(APPEND FFLAGS " -traceback -convert big_endian -assume byterecl -assume realloc_lhs -fp-model precise") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LDFLAGS " -cxxlib") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_C_FLAGS " -traceback -fp-model precise -std=gnu99") +string(APPEND CMAKE_CXX_FLAGS " -traceback -fp-model precise") +string(APPEND CMAKE_Fortran_FLAGS " -traceback -convert big_endian -assume byterecl -assume realloc_lhs -fp-model precise") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRINTEL -DHAVE_SLASHPROC -DHIDE_MPI") -string(APPEND FC_AUTO_R8 " -r8") -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -fixed -132") -string(APPEND FREEFLAGS " -free") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed -132") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -free") set(HAS_F2008_CONTIGUOUS "TRUE") set(MPIFC "mpifort") set(MPICC "mpicc") diff --git a/cime_config/machines/cmake_macros/oneapi-ifxgpu.cmake b/cime_config/machines/cmake_macros/oneapi-ifxgpu.cmake index 2c0261bd3ea1..9b799f29e220 100644 --- a/cime_config/machines/cmake_macros/oneapi-ifxgpu.cmake +++ b/cime_config/machines/cmake_macros/oneapi-ifxgpu.cmake @@ -1,28 +1,21 @@ if (compile_threaded) - string(APPEND CFLAGS " -qopenmp") - string(APPEND FFLAGS " -qopenmp") - string(APPEND CXXFLAGS " -qopenmp") - string(APPEND LDFLAGS " -qopenmp") + string(APPEND CMAKE_C_FLAGS " -qopenmp") + string(APPEND CMAKE_Fortran_FLAGS " -qopenmp") + string(APPEND CMAKE_CXX_FLAGS " -qopenmp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -qopenmp") endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") - string(APPEND CFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") -endif() -string(APPEND CFLAGS " -traceback -fp-model precise -std=gnu99") -string(APPEND CXXFLAGS " -traceback -fp-model precise") -string(APPEND FFLAGS " -traceback -convert big_endian -assume byterecl -assume realloc_lhs -fp-model precise") -set(SUPPORTS_CXX "TRUE") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created") +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_C_FLAGS " -traceback -fp-model precise -std=gnu99") +string(APPEND CMAKE_CXX_FLAGS " -traceback -fp-model precise") +string(APPEND CMAKE_Fortran_FLAGS " -traceback -convert big_endian -assume byterecl -assume realloc_lhs -fp-model precise") string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRINTEL -DHAVE_SLASHPROC -DHIDE_MPI") -string(APPEND FC_AUTO_R8 " -r8") -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -fixed -132") -string(APPEND FREEFLAGS " -free") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed -132") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -free") set(HAS_F2008_CONTIGUOUS "TRUE") set(MPIFC "mpifort") set(MPICC "mpicc") @@ -30,8 +23,6 @@ set(MPICXX "mpicxx") set(SCC "icx") set(SCXX "icpx") set(SFC "ifx") -set(CXX_LINKER "CXX") -string(APPEND SLIBS " -fiopenmp -fopenmp-targets=spir64") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -fiopenmp -fopenmp-targets=spir64") set(USE_SYCL "TRUE") string(APPEND SYCL_FLAGS " -\-intel -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend \"-device 12.60.7\"") -string(APPEND CXX_LDFLAGS " -Wl,-\-defsym,main=MAIN_\_ -lifcore -\-intel -fsycl -lsycl -Xsycl-target-backend \"-device 12.60.7\"") diff --git a/cime_config/machines/cmake_macros/pgi.cmake b/cime_config/machines/cmake_macros/pgi.cmake index 4457f85d216c..bf37790b4405 100644 --- a/cime_config/machines/cmake_macros/pgi.cmake +++ b/cime_config/machines/cmake_macros/pgi.cmake @@ -1,53 +1,47 @@ -string(APPEND CFLAGS " -time") -string(APPEND CXXFLAGS " -time") -string(APPEND FFLAGS " -i4 -time -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -Mallocatable=03") +string(APPEND CMAKE_C_FLAGS " -time") +string(APPEND CMAKE_CXX_FLAGS " -time") +string(APPEND CMAKE_Fortran_FLAGS " -i4 -time -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -Mallocatable=03") if (compile_threaded) - string(APPEND CFLAGS " -mp") - string(APPEND CXXFLAGS " -mp") - string(APPEND FFLAGS " -mp") - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_C_FLAGS " -mp") + string(APPEND CMAKE_CXX_FLAGS " -mp") + string(APPEND CMAKE_Fortran_FLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_SHR_VMATH -DNO_R16 -DCPRPGI") -set(CXX_LINKER "CXX") -string(APPEND FC_AUTO_R8 " -r8") -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -Mbounds") - string(APPEND CFLAGS " -O0 -g") - string(APPEND CXXFLAGS " -O0 -g") - string(APPEND LDFLAGS " -g") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -Mbounds") +string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g") +string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " -g") if (COMP_NAME STREQUAL datm) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL dlnd) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL drof) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL dwav) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL dice) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL docn) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfree") -set(HAS_F2008_CONTIGUOUS "FALSE") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LIBS " -lstdc++") -string(APPEND LDFLAGS " -time -Wl,--allow-multiple-definition") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfree") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -time -Wl,--allow-multiple-definition") set(MPICC "mpicc") set(MPICXX "mpicxx") set(MPIFC "mpif90") set(SCC "pgcc") set(SCXX "pgc++") set(SFC "pgf95") + +# PGI has to link fortran mains with fortran +set(E3SM_LINK_WITH_FORTRAN "TRUE") diff --git a/cime_config/machines/cmake_macros/pgi_ascent.cmake b/cime_config/machines/cmake_macros/pgi_ascent.cmake index cd2b9d7f9d3a..87e02077bd05 100644 --- a/cime_config/machines/cmake_macros/pgi_ascent.cmake +++ b/cime_config/machines/cmake_macros/pgi_ascent.cmake @@ -1,18 +1,16 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") if (COMP_NAME STREQUAL eam) - string(APPEND FFLAGS " -O1 -Mnovect -DSUMMITDEV_PGI") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O1 -Mnovect -DSUMMITDEV_PGI") else() - string(APPEND FFLAGS " -O2 -DSUMMITDEV_PGI") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -DSUMMITDEV_PGI") endif() -endif() if (COMP_NAME STREQUAL cice) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICXX "mpiCC") set(PIO_FILESYSTEM_HINTS "gpfs") set(SFC "pgfortran") -set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) +set(CMAKE_NO_SYSTEM_FROM_IMPORTED "ON") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_POWER9=On") diff --git a/cime_config/machines/cmake_macros/pgi_compy.cmake b/cime_config/machines/cmake_macros/pgi_compy.cmake index df3569b54131..21740e56fe12 100644 --- a/cime_config/machines/cmake_macros/pgi_compy.cmake +++ b/cime_config/machines/cmake_macros/pgi_compy.cmake @@ -1,19 +1,15 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND FFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") string(APPEND CPPDEFS " -DLINUX") -if (DEBUG) - string(APPEND FFLAGS " -C -traceback -Mchkfpstk -Mchkstk -Mdalign -Mdepchk -Miomutex -Mrecursive -Meh_frame -Ktrap=fp") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -C -traceback -Mchkfpstk -Mchkstk -Mdalign -Mdepchk -Miomutex -Mrecursive -Meh_frame -Ktrap=fp") if (COMP_NAME STREQUAL eam) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL cice) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() set(PIO_FILESYSTEM_HINTS "lustre") -string(APPEND SLIBS " -lpmi") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi") if (MPILIB STREQUAL impi) set(MPICC "mpipgcc") set(MPICXX "mpipgcxx") diff --git a/cime_config/machines/cmake_macros/pgi_constance.cmake b/cime_config/machines/cmake_macros/pgi_constance.cmake index 98fc6fad465b..258e32157375 100644 --- a/cime_config/machines/cmake_macros/pgi_constance.cmake +++ b/cime_config/machines/cmake_macros/pgi_constance.cmake @@ -1,13 +1,7 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") -endif() +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") string(APPEND CPPDEFS " -DLINUX") -if (NOT DEBUG) - string(APPEND FFLAGS " -O2") -endif() -if (DEBUG) - string(APPEND FFLAGS " -traceback -fpe0 -check all -check noarg_temp_created -ftrapuv") - string(APPEND FFLAGS " -C -Mchkfpstk -Mchkstk -Mdalign -Mdepchk -Miomutex -Mrecursive -Meh_frame") -endif() +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -traceback -fpe0 -check all -check noarg_temp_created -ftrapuv") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -C -Mchkfpstk -Mchkstk -Mdalign -Mdepchk -Miomutex -Mrecursive -Meh_frame") set(PIO_FILESYSTEM_HINTS "lustre") -string(APPEND SLIBS " -lpmi -L$ENV{MPI_LIB} -lmpich") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -lpmi -L$ENV{MPI_LIB} -lmpich") diff --git a/cime_config/machines/cmake_macros/pgi_summit.cmake b/cime_config/machines/cmake_macros/pgi_summit.cmake index 2ad7e9f89fd2..5c08facd6192 100644 --- a/cime_config/machines/cmake_macros/pgi_summit.cmake +++ b/cime_config/machines/cmake_macros/pgi_summit.cmake @@ -1,16 +1,14 @@ -if (NOT DEBUG) - string(APPEND CFLAGS " -O2") - string(APPEND CXXFLAGS " -O2") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2") if (COMP_NAME STREQUAL eam) - string(APPEND FFLAGS " -O1 -Mnovect -DSUMMITDEV_PGI") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O1 -Mnovect -DSUMMITDEV_PGI") else() - string(APPEND FFLAGS " -O2 -DSUMMITDEV_PGI") + string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -DSUMMITDEV_PGI") endif() -endif() if (COMP_NAME STREQUAL cice) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") set(MPICXX "mpiCC") set(PIO_FILESYSTEM_HINTS "gpfs") set(SFC "pgfortran") diff --git a/cime_config/machines/cmake_macros/pgigpu.cmake b/cime_config/machines/cmake_macros/pgigpu.cmake index 53739c8f76ac..9912172ed9ef 100644 --- a/cime_config/machines/cmake_macros/pgigpu.cmake +++ b/cime_config/machines/cmake_macros/pgigpu.cmake @@ -1,49 +1,39 @@ -string(APPEND CFLAGS " -time") -string(APPEND FFLAGS " -i4 -time -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -Mallocatable=03") +string(APPEND CMAKE_C_FLAGS " -time") +string(APPEND CMAKE_Fortran_FLAGS " -i4 -time -Mstack_arrays -Mextend -byteswapio -Mflushz -Kieee -Mallocatable=03") if (compile_threaded) - string(APPEND CFLAGS " -mp") - string(APPEND CXXFLAGS " -mp") - string(APPEND FFLAGS " -mp") - string(APPEND LDFLAGS " -mp") + string(APPEND CMAKE_C_FLAGS " -mp") + string(APPEND CMAKE_CXX_FLAGS " -mp") + string(APPEND CMAKE_Fortran_FLAGS " -mp") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -mp") endif() string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_SHR_VMATH -DNO_R16 -DCPRPGI") -string(APPEND FC_AUTO_R8 " -r8") -if (DEBUG) - string(APPEND FFLAGS " -O0 -g -Mbounds") -endif() -if (NOT DEBUG) - string(APPEND CFLAGS " -O2 -Mvect=nosimd") - string(APPEND FFLAGS " -O2 -Mvect=nosimd -DSUMMITDEV_PGI") -endif() +string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -Mbounds") +string(APPEND CMAKE_C_FLAGS_RELEASE " -O2 -Mvect=nosimd") +string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O2 -Mvect=nosimd -DSUMMITDEV_PGI") if (COMP_NAME STREQUAL datm) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL dlnd) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL drof) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL dwav) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL dice) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL docn) - string(APPEND FFLAGS " -Mnovect") + string(APPEND CMAKE_Fortran_FLAGS " -Mnovect") endif() if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_SLASHPROC") endif() -string(APPEND FFLAGS_NOOPT " -O0") -string(APPEND FIXEDFLAGS " -Mfixed") -string(APPEND FREEFLAGS " -Mfree") -set(HAS_F2008_CONTIGUOUS "FALSE") -set(SUPPORTS_CXX "TRUE") -set(CXX_LINKER "FORTRAN") -string(APPEND CXX_LIBS " -lstdc++") -string(APPEND LDFLAGS " -time -Wl,--allow-multiple-definition -acc") +string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -Mfixed") +string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -Mfree") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -time -Wl,--allow-multiple-definition -acc") set(MPICC "mpicc") set(MPICXX "mpiCC") set(MPIFC "mpif90") @@ -51,3 +41,6 @@ set(SCC "pgcc") set(SCXX "pgc++") set(SFC "pgfortran") set(PIO_FILESYSTEM_HINTS "gpfs") + +# PGI has to link fortran mains with fortran +set(E3SM_LINK_WITH_FORTRAN "TRUE") diff --git a/cime_config/machines/cmake_macros/pgigpu_ascent.cmake b/cime_config/machines/cmake_macros/pgigpu_ascent.cmake index 4f204a79edec..5d0e5f000f90 100644 --- a/cime_config/machines/cmake_macros/pgigpu_ascent.cmake +++ b/cime_config/machines/cmake_macros/pgigpu_ascent.cmake @@ -1,3 +1,3 @@ -string(APPEND LDFLAGS " -gpu=cc70,cc60 -Minfo=accel") -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -gpu=cc70,cc60 -Minfo=accel") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_POWER9=On -DKokkos_ARCH_VOLTA70=On -DKokkos_ENABLE_CUDA=On -DKokkos_ENABLE_CUDA_LAMBDA=On") diff --git a/cime_config/machines/cmake_macros/pgigpu_blues.cmake b/cime_config/machines/cmake_macros/pgigpu_blues.cmake index d227d901e1ac..057a2bedf3de 100644 --- a/cime_config/machines/cmake_macros/pgigpu_blues.cmake +++ b/cime_config/machines/cmake_macros/pgigpu_blues.cmake @@ -1,5 +1,5 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_GETTIMEOFDAY") endif() -string(APPEND LDFLAGS " -Minline -ta=tesla:ccall,fastmath,loadcache:L1,unroll,fma,managed,deepcopy,nonvvm -Mcuda -Minfo=accel") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -Minline -ta=tesla:ccall,fastmath,loadcache:L1,unroll,fma,managed,deepcopy,nonvvm -Mcuda -Minfo=accel") diff --git a/cime_config/machines/cmake_macros/pgigpu_summit.cmake b/cime_config/machines/cmake_macros/pgigpu_summit.cmake index 4f204a79edec..5d0e5f000f90 100644 --- a/cime_config/machines/cmake_macros/pgigpu_summit.cmake +++ b/cime_config/machines/cmake_macros/pgigpu_summit.cmake @@ -1,3 +1,3 @@ -string(APPEND LDFLAGS " -gpu=cc70,cc60 -Minfo=accel") -string(APPEND SLIBS " -L$ENV{ESSL_PATH}/lib64 -lessl") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -gpu=cc70,cc60 -Minfo=accel") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -L$ENV{ESSL_PATH}/lib64 -lessl") string(APPEND KOKKOS_OPTIONS " -DKokkos_ARCH_POWER9=On -DKokkos_ARCH_VOLTA70=On -DKokkos_ENABLE_CUDA=On -DKokkos_ENABLE_CUDA_LAMBDA=On") diff --git a/cime_config/machines/cmake_macros/pgigpu_swing.cmake b/cime_config/machines/cmake_macros/pgigpu_swing.cmake index 7dced20dcc15..95667f16138f 100644 --- a/cime_config/machines/cmake_macros/pgigpu_swing.cmake +++ b/cime_config/machines/cmake_macros/pgigpu_swing.cmake @@ -1,4 +1,4 @@ if (COMP_NAME STREQUAL gptl) string(APPEND CPPDEFS " -DHAVE_NANOTIME -DBIT64 -DHAVE_GETTIMEOFDAY") endif() -string(APPEND LDFLAGS " -gpu=cc70,cc60,deepcopy -Minfo=accel") +string(APPEND CMAKE_EXE_LINKER_FLAGS " -gpu=cc70,cc60,deepcopy -Minfo=accel") diff --git a/cime_config/machines/cmake_macros/post_process.cmake b/cime_config/machines/cmake_macros/post_process.cmake new file mode 100644 index 000000000000..8e076da1c2b5 --- /dev/null +++ b/cime_config/machines/cmake_macros/post_process.cmake @@ -0,0 +1,22 @@ +# Error checking? + +# Do not edit this file + +# These are set to full paths in the main CMakeLists.txt file by the project +# command. We don't want to override the full path every time we load +# the macros in the components. +if (NOT CMAKE_Fortran_COMPILER) + if (MPILIB STREQUAL "mpi-serial") + set(CMAKE_Fortran_COMPILER ${SFC}) + set(CMAKE_C_COMPILER ${SCC}) + set(CMAKE_CXX_COMPILER ${SCXX}) + else() + set(CMAKE_Fortran_COMPILER ${MPIFC}) + set(CMAKE_C_COMPILER ${MPICC}) + set(CMAKE_CXX_COMPILER ${MPICXX}) + endif() +endif() + +if (DEBUG) + string(APPEND CPPDEFS " ${CPPDEFS_DEBUG}") +endif() diff --git a/cime_config/machines/cmake_macros/universal.cmake b/cime_config/machines/cmake_macros/universal.cmake index 5239a1c23b51..24e9fa72d021 100644 --- a/cime_config/machines/cmake_macros/universal.cmake +++ b/cime_config/machines/cmake_macros/universal.cmake @@ -1,5 +1,3 @@ -set(SUPPORTS_CXX "FALSE") - # Default guess at KOKKOS_OPTIONS. These can be overridden by # appending -D${OPTION_NAME}=Off. The CMAKE_CXX_COMPILER will # be handled automatically by CIME unless explicitly set in @@ -9,3 +7,24 @@ set(KOKKOS_OPTIONS "-DKokkos_ENABLE_SERIAL=On") if (compile_threaded) string(APPEND KOKKOS_OPTIONS " -DKokkos_ENABLE_OPENMP=On") endif() + +# Unless told otherwise, set has_contiguous to FALSE +set(HAS_F2008_CONTIGUOUS "FALSE") + +# By default, link with CXX +set(E3SM_LINK_WITH_FORTRAN "FALSE") + +# Do not use any automatic settings for these +set(CMAKE_Fortran_FLAGS "") +set(CMAKE_Fortran_FLAGS_DEBUG "") +set(CMAKE_Fortran_FLAGS_RELEASE "") +set(CMAKE_C_FLAGS "") +set(CMAKE_C_FLAGS_DEBUG "") +set(CMAKE_C_FLAGS_RELEASE "") +set(CMAKE_CXX_FLAGS "") +set(CMAKE_CXX_FLAGS_DEBUG "") +set(CMAKE_CXX_FLAGS_RELEASE "") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "") + + diff --git a/cime_config/machines/config_machines.xml b/cime_config/machines/config_machines.xml index 7ec299ce70f9..779e3972babe 100644 --- a/cime_config/machines/config_machines.xml +++ b/cime_config/machines/config_machines.xml @@ -4371,6 +4371,7 @@ Generic $ENV{OLCF_ESSL_ROOT} $ENV{OLCF_HDF5_ROOT} + True $ENV{OLCF_PARALLEL_NETCDF_ROOT} 0 diff --git a/cime_config/machines/scripts/cmakeify-macros b/cime_config/machines/scripts/cmakeify-macros new file mode 100755 index 000000000000..187ae0e1ff97 --- /dev/null +++ b/cime_config/machines/scripts/cmakeify-macros @@ -0,0 +1,275 @@ +#! /usr/bin/env python3 + +""" +Convert E3SM cmake macros to use cmake names for things +""" + +import argparse, sys, re, pathlib + +NAME_MAP_TYPE_SENSITIVE = { + "CFLAGS" : "CMAKE_C_FLAGS", + "FFLAGS" : "CMAKE_Fortran_FLAGS", + "CXXFLAGS" : "CMAKE_CXX_FLAGS", + "CPPDEFS" : "CPPDEFS", # CMake doesn't use variables to store CPP defs + "CUDA_FLAGS": "CMAKE_CUDA_FLAGS", + "HIP_FLAGS" : "CMAKE_HIP_FLAGS", + "LDFLAGS" : "CMAKE_EXE_LINKER_FLAGS", + "SLIBS" : "CMAKE_EXE_LINKER_FLAGS", +} + +NAME_MAP = { + "FFLAGS_NOOPT" : "CMAKE_Fortran_FLAGS_DEBUG" +} + +# Regexes for parsing our cmake macros +SET_RE = re.compile(r'^\s*set[(](\w+)\s+"([^"]*)"[)]\s*$') +APPEND_RE = re.compile(r'^\s*string[(]APPEND\s+(\w+)\s+"([^"]+)"[)]\s*$') +IF_RE = re.compile(r'^\s*if\s*[(]([^)]+)[)]\s*$') +ELSEIF_RE = re.compile(r'^\s*elseif\s*[(]([^)]+)[)]\s*$') +ELSE_RE = re.compile(r'^\s*else\s*[(]\s*[)]\s*$') +ENDIF_RE = re.compile(r'^\s*endif') +DEBUG_RE = re.compile(r'^\s*DEBUG\s*$') +NDEBUG_RE = re.compile(r'^\s*NOT\s+DEBUG\s*$') + +############################################################################### +def parse_command_line(args, description): +############################################################################### + parser = argparse.ArgumentParser( + usage="""\n{0} +OR +{0} --help + +\033[1mEXAMPLES:\033[0m + \033[1;32m# Convert all macros \033[0m + > {0} $repo/cime_config/machines/cmake_macros/*.cmake +""".format(pathlib.Path(args[0]).name), + description=description, + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + + parser.add_argument("macro_files", nargs="+", help="The name of the package") + + return parser.parse_args(args[1:]) + +############################################################################### +def get_conditional_type(conditional): +############################################################################### + if "DEBUG" in conditional: + debug_m = DEBUG_RE.match(conditional) + ndebug_m = NDEBUG_RE.match(conditional) + if debug_m: + return "DEBUG" + elif ndebug_m: + return "NDEBUG" + else: + assert False, f"Conditional '{conditional}' appeared to be related to DEBUG but did not match anything" + else: + return None + +############################################################################### +class ParseStateStruct(object): +############################################################################### + + ########################################################################### + def __init__(self): + ########################################################################### + self._active_conditionals = [] # Stack of active conditional statements + self._current_build_type = "GLOBAL" + + ########################################################################### + def push_conditional(self, condition): + ########################################################################### + self._active_conditionals.append(condition) + cond_type = get_conditional_type(condition) + if cond_type == "DEBUG": + self._current_build_type = "DEBUG" + elif cond_type == "NDEBUG": + self._current_build_type = "RELEASE" + + ########################################################################### + def pop_conditional(self): + ########################################################################### + orig_conditional = self._active_conditionals.pop() + cond_type = get_conditional_type(orig_conditional) + if cond_type == "DEBUG" or cond_type == "NDEBUG": + self._current_build_type = "GLOBAL" + + return orig_conditional + + ########################################################################### + def current_build_type(self): + ########################################################################### + return self._current_build_type + +WARNED_VARS = set() +############################################################################### +def convert_set_append(line, var, val, state, is_append=False): +############################################################################### + curr_build_type = state.current_build_type() + global WARNED_VARS + if curr_build_type == "GLOBAL": + if var in NAME_MAP_TYPE_SENSITIVE: + return line.replace(var, NAME_MAP_TYPE_SENSITIVE[var]) + elif var in NAME_MAP: + return line.replace(var, NAME_MAP[var]) + else: + if var not in WARNED_VARS: + WARNED_VARS.add(var) + print(f"Warning: var {var} in line '{line}' is being left alone") + + return line + + else: + if var in NAME_MAP_TYPE_SENSITIVE: + return line.replace(var, NAME_MAP_TYPE_SENSITIVE[var] + f"_{curr_build_type}").replace(" ", "", 1) + else: + assert False, f"Non build-type sensitive var '{var}' within build-type conditional" + +############################################################################### +def convert_if(line, conditional, state): +############################################################################### + state.push_conditional(conditional) + + cond_type = get_conditional_type(conditional) + if cond_type == "DEBUG" or cond_type == "NDEBUG": + return None + else: + return line + +############################################################################### +def convert_elseif(line, conditional, state): +############################################################################### + orig_conditional = state.pop_conditional() + state.push_conditional(conditional) + + cond_type = get_conditional_type(conditional) + orig_cond_type = get_conditional_type(orig_conditional) + if orig_cond_type == "DEBUG" or orig_cond_type == "NDEBUG": + assert (cond_type == "DEBUG" or cond_type == "NDEBUG"), "Mismatch conditional type" + return None + else: + return line + +############################################################################### +def convert_else(line, state): +############################################################################### + orig_conditional = state.pop_conditional() + conditional = orig_conditional.replace("NOT ", "", 1) if orig_conditional.strip().startswith("NOT ") else "NOT " + orig_conditional + state.push_conditional(conditional) + + cond_type = get_conditional_type(conditional) + if cond_type == "DEBUG" or cond_type == "NDEBUG": + return None + else: + return line + +############################################################################### +def convert_endif(line, state): +############################################################################### + orig_conditional = state.pop_conditional() + + cond_type = get_conditional_type(orig_conditional) + if cond_type == "DEBUG" or cond_type == "NDEBUG": + return None + else: + return line + +############################################################################### +def convert_line(line, state): +############################################################################### + if line.strip() == "": + return line + elif line.strip().startswith("#"): + return line + else: + stripped_no_comment = line[0:line.find("#")].strip() if "#" in line else line.strip() + set_m = SET_RE.match(stripped_no_comment) + append_m = APPEND_RE.match(stripped_no_comment) + if_m = IF_RE.match(stripped_no_comment) + elseif_m = ELSEIF_RE.match(stripped_no_comment) + else_m = ELSE_RE.match(stripped_no_comment) + endif_m = ENDIF_RE.match(stripped_no_comment) + + if set_m: + var, val = set_m.groups() + return convert_set_append(line, var, val, state) + elif append_m: + var, val = append_m.groups() + return convert_set_append(line, var, val, state, is_append=True) + elif if_m: + conditional = if_m.groups()[0] + return convert_if(line, conditional, state) + elif elseif_m: + conditional = elseif_m.groups()[0] + return convert_elseif(line, conditional, state) + elif else_m: + return convert_else(line, state) + elif endif_m: + return convert_endif(line, state) + else: + assert False, f"No regexes matched, stipped line is '{stripped_no_comment}'" + + return None + +############################################################################### +def cmakeify_macro(text, macro_file): +############################################################################### + r""" + >>> test_1 = ''' + ... if (DEBUG) + ... string(APPEND CFLAGS " -g") + ... else() + ... string(APPEND CFLAGS " -O") + ... endif() + ... ''' + >>> print("\n".join(cmakeify_macro(test_1, "test1"))) + + string(APPEND CMAKE_C_FLAGS_DEBUG " -g") + string(APPEND CMAKE_C_FLAGS_RELEASE " -O") + """ + new_lines = [] + + # State we need to maintain while parsing input + state = ParseStateStruct() + + for line in text.splitlines(): + try: + new_line = convert_line(line, state) + if new_line is not None: + new_lines.append(new_line + "\n") + + except AssertionError as e: + raise SystemExit(f"Error parsing line: {line} in {macro_file}\n{str(e)}") + + return new_lines + +############################################################################### +def cmakeify_macros(macro_files): +############################################################################### + skips = ["Macros.cmake", "post_process.cmake"] + for macro_file in macro_files: + macro_file_p = pathlib.Path(macro_file) + if macro_file_p.name in skips: + continue + + assert macro_file_p.exists(), f"Macro file {macro_file} doesn't exist" + + with macro_file_p.open("r", encoding="utf-8") as fd: + new_lines = cmakeify_macro(fd.read(), macro_file) + + with macro_file_p.open("w", encoding="utf-8") as fd: + fd.writelines(new_lines) + + return True + +############################################################################### +def _main_func(description): +############################################################################### + success = cmakeify_macros(**vars(parse_command_line(sys.argv, description))) + + sys.exit(0 if success else 1) + +############################################################################### + +if (__name__ == "__main__"): + _main_func(__doc__) diff --git a/cime_config/machines/scripts/compare-flags b/cime_config/machines/scripts/compare-flags index be420714eafc..38929defb4f7 100755 --- a/cime_config/machines/scripts/compare-flags +++ b/cime_config/machines/scripts/compare-flags @@ -4,7 +4,7 @@ Compare two build trees to see if compiler or link flags have changed. """ -import argparse, sys, os, subprocess, glob +import argparse, sys, subprocess, glob from pathlib import Path ############################################################################### @@ -40,7 +40,7 @@ OR \033[1;32m# same as ^, except limit to link flags for all components \033[0m > {0} $case1dir $case2dir -u -l link.txt -""".format(os.path.basename(args[0])), +""".format(Path(args[0])), description=description, formatter_class=argparse.ArgumentDefaultsHelpFormatter ) @@ -55,6 +55,8 @@ OR parser.add_argument("-l", "--limit", dest="limits", action="append", default=[], help="Limit compared files to files containing this substring. This option can be supplied multiple times") + parser.add_argument("-b", "--build-log", action="store_true", help="Compare build log files instead of cmake files. This works best when e3sm is built with -j1") + parser.add_argument("-v", "--verbose", action="store_true", help="Print diff details") args = parser.parse_args(args[1:]) @@ -84,6 +86,38 @@ def find_files(builddir_cmake, filename, limits): else: return all_files +############################################################################### +def compare_tokens(line1, line2, unordered): +############################################################################### + tokens1 = line1.split() + tokens2 = line2.split() + + if unordered: + tokens1.sort() + tokens2.sort() + + result = True + message = "" + if tokens1 != tokens2: + result = False + + tokens1_set = set(tokens1) + tokens2_set = set(tokens2) + one_not_two = tokens1_set - tokens2_set + two_not_one = tokens2_set - tokens1_set + #message += f" For line {line1}:" + if one_not_two: + message += " Case1 had unique flags:\n" + for item in one_not_two: + message += f" {item}\n" + + if two_not_one: + message += " Case2 had unique flags:\n" + for item in two_not_one: + message += f" {item}\n" + + return result, message + ############################################################################### def compare_contents(case1, case2, file1, file2, contents1, contents2, unordered, verbose): ############################################################################### @@ -99,37 +133,15 @@ def compare_contents(case1, case2, file1, file2, contents1, contents2, unordered files_match = True for line1, line2 in zip(lines1, lines2): - tokens1 = line1.split() - tokens2 = line2.split() - - if unordered: - tokens1.sort() - tokens2.sort() - - if tokens1 != tokens2: - if files_match: - print(" did NOT match") - files_match = False - - if verbose: - tokens1_set = set(tokens1) - tokens2_set = set(tokens2) - one_not_two = tokens1_set - tokens2_set - two_not_one = tokens2_set - tokens1_set - print(f" For line {line1}:") - print(f" Case1 had unique flags:") - for item in one_not_two: - print(f" {item}") - - print(f" Case2 had unique flags:") - for item in two_not_one: - print(f" {item}") - - else: - break + result, message = compare_tokens(line1, line2, unordered) + if verbose: + print(message) + files_match &= result if files_match: - print(" MATCHED") + print("\n FILES MATCHED") + else: + print("\n FILES DID NOT MATCH") return files_match @@ -138,51 +150,143 @@ def compare_file_lists(case1, case2, files1, files2, unordered, verbose): ############################################################################### result = True for file1, file2 in zip(files1, files2): - file1p = Path(file1) - file2p = Path(file2) - - assert file1p.name == file2p.name, f"File orders did not match, {file1p.name} != {file2p.name}" + assert file1 == file2, f"File orders did not match, {file1} != {file2}" - file1c = file1p.open().read() - file2c = file2p.open().read() + file1c = Path(file1).open("r", encoding="utf8").read() + file2c = Path(file2).open("r", encoding="utf8").read() result &= compare_contents(case1, case2, file1, file2, file1c, file2c, unordered, verbose) return result ############################################################################### -def compare_flags(case1, case2, unordered, limits, verbose): +def get_log_from_blddir(builddir): +############################################################################### + logs = glob.glob(f"{builddir}/e3sm.bldlog.*") + assert len(logs) == 1, f"Expected to match exactly one log file, got {logs}" + + logf = Path(logs[0]) + assert logf.suffix != ".gz", f"Expected {logf} to be uncompressed" + + return logf + +############################################################################### +def parse_log(logf, normalize=None): +############################################################################### + log_content = logf.open("r", encoding="utf8").read() + + result = {} + for line in log_content.splitlines(): + if "e3sm_compile_wrap.py" in line: + if normalize is not None: + for repl, repl_with in normalize: + line = line.replace(repl, repl_with) + + args = line.split() + arglen = len(args) + target = None + for idx, arg in enumerate(args): + if arg == "-o" and idx + 1 < arglen: + target = args[idx + 1] + break + + if arg.startswith("lib") and arg.endswith(".a"): + if args[idx-1].endswith("ranlib"): + target = "skipme" + else: + target = arg + + if target is None: + target = line + print(f"WARNING: Failed to parse line {line}") + + if target != "skipme": + assert target not in result, f"{target} appears twice in log {logf}?\nFirst encountered: {result[target]}\n\nAnd again: {line}" + result[target] = line + + return result + +############################################################################### +def compare_logs(builddir1, builddir2, casename1, casename2, srcroot1, srcroot2, unordered, verbose): ############################################################################### result = True - assert os.path.isdir(case1), f"{case1} is not an existing directory" - assert os.path.isdir(case2), f"{case2} is not an existing directory" + log1 = get_log_from_blddir(builddir1) + log2 = get_log_from_blddir(builddir2) + + log1c = parse_log(log1) + log2c = parse_log(log2, normalize=((casename2, casename1), (srcroot2, srcroot1))) + + message_dict = {} + + for target, line1 in log1c.items(): + if target in log2c: + line2 = log2c[target] + print(f"Comparing target {target}") - builddir1 = run_cmd_no_fail("./xmlquery EXEROOT --value", from_dir=case1) - builddir2 = run_cmd_no_fail("./xmlquery EXEROOT --value", from_dir=case2) + curr_result, message = compare_tokens(line1, line2, unordered) + if verbose and not curr_result: + if message in message_dict: + print(f" Same issue as {message_dict[message]}") + else: + message_dict[message] = target + print(message) + + result &= curr_result + if curr_result: + print(f" Target has identical build") + else: + print(f" Target did not have identical build") + + else: + print(f"WARNING: target {target} is missing from case2") + result = False + + return result + +############################################################################### +def compare_flags(case1, case2, unordered, limits, build_log, verbose): +############################################################################### + result = True + + case1 = Path(case1) + case2 = Path(case2) + + assert case1.is_dir(), f"{case1} is not an existing directory" + assert case2.is_dir(), f"{case2} is not an existing directory" + + builddir1 = Path(run_cmd_no_fail("./xmlquery EXEROOT --value", from_dir=case1)) + builddir2 = Path(run_cmd_no_fail("./xmlquery EXEROOT --value", from_dir=case2)) casename1 = run_cmd_no_fail("./xmlquery CASE --value", from_dir=case1) casename2 = run_cmd_no_fail("./xmlquery CASE --value", from_dir=case2) - builddir1_cmake = os.path.join(builddir1, "cmake-bld") - builddir2_cmake = os.path.join(builddir2, "cmake-bld") + srcroot1 = run_cmd_no_fail("./xmlquery SRCROOT --value", from_dir=case1) + srcroot2 = run_cmd_no_fail("./xmlquery SRCROOT --value", from_dir=case2) + + builddir1_cmake = builddir1 / "cmake-bld" + builddir2_cmake = builddir2 / "cmake-bld" - assert os.path.isdir(builddir1_cmake), \ + assert builddir1_cmake.is_dir(), \ f"{builddir1_cmake} is not an existing directory, you need to run case.build in {case1}" - assert os.path.isdir(builddir2_cmake), \ + assert builddir2_cmake.is_dir(), \ f"{builddir2_cmake} is not an existing directory, you need to run case.build in {case2}" - flag_files1 = find_files(builddir1_cmake, "flags.make", limits) - flag_files2 = find_files(builddir2_cmake, "flags.make", limits) + if build_log: + result = compare_logs(builddir1, builddir2, casename1, casename2, srcroot1, srcroot2, unordered, verbose) + + else: + flag_files1 = find_files(builddir1_cmake, "flags.make", limits) + flag_files2 = find_files(builddir2_cmake, "flags.make", limits) - link_files1 = find_files(builddir1_cmake, "link.txt", limits) - link_files2 = find_files(builddir2_cmake, "link.txt", limits) + link_files1 = find_files(builddir1_cmake, "link.txt", limits) + link_files2 = find_files(builddir2_cmake, "link.txt", limits) - print() + print() - result &= compare_file_lists(casename1, casename2, flag_files1, flag_files2, unordered, verbose) + result &= compare_file_lists(casename1, casename2, flag_files1, flag_files2, unordered, verbose) - result &= compare_file_lists(casename1, casename2, link_files1, link_files2, unordered, verbose) + result &= compare_file_lists(casename1, casename2, link_files1, link_files2, unordered, verbose) if result: print("\nALL FILES MATCHED") diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8ebbc25b2f33..2568fabd5d08 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -30,26 +30,16 @@ function(set_compilers_e3sm) # Grab CXX compiler from CIME include(${CASEROOT}/Macros.cmake) - if (MPILIB STREQUAL "mpi-serial") - set(CC ${SCC}) - set(FC ${SFC}) - set(CXX ${SCXX}) - else() - set(CC ${MPICC}) - set(FC ${MPIFC}) - set(CXX ${MPICXX}) - endif() - - set(CMAKE_CXX_COMPILER ${CXX} CACHE STRING "The CXX compiler") - set(CMAKE_C_COMPILER ${CC} CACHE STRING "The C compiler") - set(CMAKE_Fortran_COMPILER ${FC} CACHE STRING "The Fortran compiler") - if (DEBUG) set(E3SM_DEFAULT_BUILD_TYPE "DEBUG" CACHE STRING "Default build type, inferred from ${DEBUG}") else() set(E3SM_DEFAULT_BUILD_TYPE "RELEASE" CACHE STRING "Default build type, inferred from ${DEBUG}") endif() + set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "The CXX compiler") + set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "The C compiler") + set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING "The Fortran compiler") + # USE_CUDA or USE_HIP is set through Macros.cmake # For instance: cime_config/machines/cmake_macros/gnugpu_summit.cmake # If it exists, then set parent's scope to true; otherwise to false @@ -127,19 +117,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/find_dep_packages.cmake) # Scream manages its own flags build_eamxx() -# We do want CMAKE_BUILD_TYPE to be set, but we do NOT want CMake to -# decide what optimization flags to append, based on build type, -# for components who rely on CIME for build flags, so make all the following empty. -# JGF: I think we can remove this once proper CMake names are being used in the -# macros. -set (CMAKE_C_FLAGS_RELEASE "") -set (CMAKE_CXX_FLAGS_RELEASE "") -set (CMAKE_Fortran_FLAGS_RELEASE "") - -set (CMAKE_C_FLAGS_DEBUG "") -set (CMAKE_CXX_FLAGS_DEBUG "") -set (CMAKE_Fortran_FLAGS_DEBUG "") - set(BUILDCONF ${CASEROOT}/Buildconf) build_mpas_models() diff --git a/components/cmake/build_eamxx.cmake b/components/cmake/build_eamxx.cmake index b3c8d5b8ab16..135cd640b36f 100644 --- a/components/cmake/build_eamxx.cmake +++ b/components/cmake/build_eamxx.cmake @@ -9,11 +9,6 @@ function(build_eamxx) include(${CMAKE_SOURCE_DIR}/cmake/common_setup.cmake) - # Transfer CIME-set flags into Cmake-style - set (CMAKE_C_FLAGS ${CFLAGS}) - set (CMAKE_CXX_FLAGS ${CXXFLAGS}) - set (CMAKE_Fortran_FLAGS ${FFLAGS}) - # SCREAM manages its own kokkos settings. We can think about # removing this once the cime cmake_macros aren't using obsolete # Kokkos settings like KOKKOS_OPTIONS. diff --git a/components/cmake/build_model.cmake b/components/cmake/build_model.cmake index fce7e1242662..e7e9e5b7704b 100644 --- a/components/cmake/build_model.cmake +++ b/components/cmake/build_model.cmake @@ -1,4 +1,11 @@ -function(build_model COMP_CLASS COMP_NAME) +# This function must be a macro so that it does not get its own scope. +# This way, changes to CMAKE_* vars affect the directory which is what +# we want. +macro(build_model COMP_CLASS COMP_NAME) + + # We want real variables, not macro expansions + set(COMP_CLASS ${COMP_CLASS}) + set(COMP_NAME ${COMP_NAME}) # We support component-specific configuration of flags, etc, so this setup # need to be done here. @@ -32,14 +39,6 @@ function(build_model COMP_CLASS COMP_NAME) endforeach() endif() - # Source files don't live in components/cmake/$COMP_CLASS. This path won't work for - # generated files. - if (COMP_NAME STREQUAL "csm_share") - set(SOURCE_PATH ".") - else() - set(SOURCE_PATH "../..") - endif() - #------------------------------------------------------------------------------- # Build & include dependency files #------------------------------------------------------------------------------- @@ -89,7 +88,7 @@ function(build_model COMP_CLASS COMP_NAME) set(YAKL_SYCL_FLAGS "${CPPDEFS} ${SYCL_FLAGS}") else() # For CPU C++ compilers duplicate flags are fine, the last ones win typically - set(YAKL_CXX_FLAGS "${CPPDEFS} ${CXXFLAGS}") + set(YAKL_CXX_FLAGS "${CPPDEFS} ${CMAKE_CXX_FLAGS}") set(YAKL_ARCH "") endif() message(STATUS "Building YAKL") @@ -178,30 +177,22 @@ function(build_model COMP_CLASS COMP_NAME) list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}) endforeach () - # Set compiler flags for source files + # Set special fixed/free compiler flags for non-cosp fortran files. This logic + # can maybe be replaced/reworked once we have Fortran_FORMAT property + # working foreach (SOURCE_FILE IN LISTS SOURCES) get_filename_component(SOURCE_EXT ${SOURCE_FILE} EXT) - # Set flags based on file extension. File extensions may change if the globs used by - # gather_sources changes. - if (SOURCE_EXT STREQUAL ".c") - e3sm_add_flags("${SOURCE_FILE}" "${CFLAGS}") - elseif (SOURCE_EXT STREQUAL ".cpp") - e3sm_add_flags("${SOURCE_FILE}" "${CXXFLAGS}") - else() - # This is a fortran source - e3sm_add_flags("${SOURCE_FILE}" "${FFLAGS}") - - # Cosp manages its own flags - if (NOT SOURCE_FILE IN_LIST COSP_SOURCES) - # Flags are slightly different for different fortran extensions - if (SOURCE_EXT STREQUAL ".F" OR SOURCE_EXT STREQUAL ".f") - e3sm_add_flags("${SOURCE_FILE}" "${FIXEDFLAGS}") - elseif (SOURCE_EXT STREQUAL ".f90") - e3sm_add_flags("${SOURCE_FILE}" "${FREEFLAGS}") - elseif (SOURCE_EXT STREQUAL ".F90") - e3sm_add_flags("${SOURCE_FILE}" "${FREEFLAGS} ${CONTIGUOUS_FLAG}") - endif() + # Cosp manages its own flags + if (NOT SOURCE_FILE IN_LIST COSP_SOURCES) + # Flags are slightly different for different fortran extensions + if (SOURCE_EXT STREQUAL ".F" OR SOURCE_EXT STREQUAL ".f") + e3sm_set_source_property(${SOURCE_FILE} Fortran_FORMAT FIXED FALSE) + elseif (SOURCE_EXT STREQUAL ".f90") + e3sm_set_source_property(${SOURCE_FILE} Fortran_FORMAT FREE FALSE) + elseif (SOURCE_EXT STREQUAL ".F90") + e3sm_set_source_property(${SOURCE_FILE} Fortran_FORMAT FREE FALSE) + e3sm_add_flags(${SOURCE_FILE} "${CONTIGUOUS_FLAG}") endif() endif() endforeach() @@ -226,7 +217,7 @@ function(build_model COMP_CLASS COMP_NAME) # Disable optimizations on some files that would take too long to compile, expect these to all be fortran files foreach (SOURCE_FILE IN LISTS NOOPT_FILES) - e3sm_deoptimize_file("${SOURCE_FILE}" "${FFLAGS_NOOPT}") + e3sm_deoptimize_file("${SOURCE_FILE}") endforeach() #------------------------------------------------------------------------------- @@ -237,7 +228,7 @@ function(build_model COMP_CLASS COMP_NAME) if (ITEM MATCHES "${CMAKE_BINARY_DIR}/.*") # is generated list(APPEND REAL_SOURCES ${ITEM}) else() - list(APPEND REAL_SOURCES "${SOURCE_PATH}/${ITEM}") + list(APPEND REAL_SOURCES "${PROJECT_SOURCE_DIR}/${ITEM}") endif() endforeach() @@ -261,7 +252,18 @@ function(build_model COMP_CLASS COMP_NAME) # Make sure we link blas/lapack target_link_libraries(${TARGET_NAME} BLAS::BLAS LAPACK::LAPACK) - set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE ${LD}) + if (E3SM_LINK_WITH_FORTRAN) + set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE Fortran) + + # A bit hacky, some platforms need help with the fortran linker + if (COMPILER STREQUAL "intel") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -cxxlib") + endif() + + else() + set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX) + endif() + else() set(TARGET_NAME ${COMP_CLASS}) add_library(${TARGET_NAME}) @@ -307,4 +309,4 @@ function(build_model COMP_CLASS COMP_NAME) # Set flags for target target_include_directories(${TARGET_NAME} PRIVATE ${INCLDIR}) -endfunction(build_model) +endmacro(build_model) diff --git a/components/cmake/cmake_util.cmake b/components/cmake/cmake_util.cmake index e83c63b460ab..149c13201699 100644 --- a/components/cmake/cmake_util.cmake +++ b/components/cmake/cmake_util.cmake @@ -12,7 +12,7 @@ function(gather_sources FILEPATH_DIRS_ARG CIMEROOT_ARG) set(GEN_F90_SOURCES_RESULT) foreach(DIRSEARCH ${FILEPATH_DIRS_ARG}) - file(GLOB MATCHES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_PATH}" "${DIRSEARCH}/*.[Ffc]" "${DIRSEARCH}/*.[Ff]90" "${DIRSEARCH}/*.cpp" "${DIRSEARCH}/*.F90.in") + file(GLOB MATCHES RELATIVE "${PROJECT_SOURCE_DIR}" "${DIRSEARCH}/*.[Ffc]" "${DIRSEARCH}/*.[Ff]90" "${DIRSEARCH}/*.cpp" "${DIRSEARCH}/*.F90.in") if (MATCHES) foreach (MATCH IN LISTS MATCHES) get_filename_component(BASENAME ${MATCH} NAME) @@ -43,46 +43,46 @@ function(gather_sources FILEPATH_DIRS_ARG CIMEROOT_ARG) endfunction() -# Add compile flags for a file. Expects a filepath relative to E3SM/components if it -# is not a generated file. -function(e3sm_add_flags FILE_ARG FLAGS_ARG) +function(e3sm_get_source_property FILE_ARG PROPERTY_NAME) if (FILE_ARG MATCHES "${CMAKE_BINARY_DIR}/.*") # is generated set(REAL_FILE ${FILE_ARG}) else() - if (NOT EXISTS ${PROJECT_SOURCE_DIR}/${FILE_ARG}) - message(FATAL_ERROR "Trying to set flags on non-existent source: ${FILE_ARG}, looked for ${PROJECT_SOURCE_DIR}/${FILE_ARG}") - endif() - set(REAL_FILE "${SOURCE_PATH}/${FILE_ARG}") + set(REAL_FILE "${PROJECT_SOURCE_DIR}/${FILE_ARG}") endif() - set_property(SOURCE ${REAL_FILE} APPEND_STRING PROPERTY COMPILE_FLAGS " ${FLAGS_ARG} ") + get_property(RESULT SOURCE ${REAL_FILE} PROPERTY ${PROPERTY_NAME}) + + # Return data to parent + set(PROPERTY_RESULT ${RESULT} PARENT_SCOPE) endfunction() -# Remove compile flags for a file. Expects a filepath relative to E3SM/components if it -# is not a generated file. -function(e3sm_remove_flags FILE_ARG FLAGS_ARG) +function(e3sm_set_source_property FILE_ARG PROPERTY_NAME PROPERTY_VALUE IS_APPEND) if (FILE_ARG MATCHES "${CMAKE_BINARY_DIR}/.*") # is generated set(REAL_FILE ${FILE_ARG}) else() if (NOT EXISTS ${PROJECT_SOURCE_DIR}/${FILE_ARG}) - message(FATAL_ERROR "Trying to set flags on non-existent source: ${FILE_ARG}") + message(FATAL_ERROR "Trying to set property on non-existent source: ${FILE_ARG}, looked for ${PROJECT_SOURCE_DIR}/${FILE_ARG}") endif() - set(REAL_FILE "${SOURCE_PATH}/${FILE_ARG}") + set(REAL_FILE "${PROJECT_SOURCE_DIR}/${FILE_ARG}") + endif() + if (IS_APPEND) + set_property(SOURCE ${REAL_FILE} APPEND_STRING PROPERTY ${PROPERTY_NAME} "${PROPERTY_VALUE}") + else() + set_property(SOURCE ${REAL_FILE} PROPERTY ${PROPERTY_NAME} "${PROPERTY_VALUE}") endif() - - get_property(ITEM_FLAGS SOURCE ${REAL_FILE} PROPERTY COMPILE_FLAGS) - string(REPLACE "${FLAGS_ARG}" "" ITEM_FLAGS "${ITEM_FLAGS}") - set_property(SOURCE ${REAL_FILE} PROPERTY COMPILE_FLAGS "${ITEM_FLAGS}") endfunction() -function(e3sm_deoptimize_file FILE_ARG FFLAGS_NOOPT) - if (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" OR CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") - # PGI does not support bulk-disabling of optimization by appending -O0, - # we have to remove the optimization flags first +# Add compile flags for a file. Expects a filepath relative to E3SM/components if it +# is not a generated file. +function(e3sm_add_flags FILE_ARG FLAGS_ARG) + e3sm_set_source_property(${FILE_ARG} COMPILE_FLAGS " ${FLAGS_ARG}" TRUE) +endfunction() - # Until we know which particular flags are related to optimization, we have to guess. - e3sm_remove_flags(${FILE_ARG} "-O1") - e3sm_remove_flags(${FILE_ARG} "-O2") - e3sm_remove_flags(${FILE_ARG} "-O3") +function(e3sm_deoptimize_file FILE_ARG) + e3sm_get_source_property(${FILE_ARG} LANGUAGE) + # Adding all DEBUG flags may be overkill + #e3sm_add_flags(${FILE_ARG} "${CMAKE_${PROPERTY_RESULT}_FLAGS_DEBUG}") + e3sm_add_flags(${FILE_ARG} "-O0") + if (COMPILER STREQUAL "nvidia") + e3sm_add_flags(${FILE_ARG} "-Mnofma") endif() - e3sm_add_flags(${FILE_ARG} "${FFLAGS_NOOPT}") endfunction() diff --git a/components/cmake/common_setup.cmake b/components/cmake/common_setup.cmake index ce9fd227bc40..f9f775b68546 100644 --- a/components/cmake/common_setup.cmake +++ b/components/cmake/common_setup.cmake @@ -15,14 +15,6 @@ else() set(ESMFDIR "noesmf") endif() -# Determine whether any C++ code will be included in the build; -# currently, C++ code is included if and only if we're linking to the -# trilinos library or the Albany library. -set(USE_CXX FALSE) -if (USE_TRILINOS OR USE_ALBANY OR USE_KOKKOS) - set(USE_CXX TRUE) -endif() - if (NOT MOD_SUFFIX) set(MOD_SUFFIX "mod") endif() @@ -56,11 +48,6 @@ else() set(USE_YAKL FALSE) endif() -# If YAKL is being used, then we need to enable USE_CXX -if (${USE_YAKL}) - set(USE_CXX TRUE) -endif() - #=============================================================================== # set CPP options (must use this before any flags or cflags settings) #=============================================================================== @@ -90,12 +77,6 @@ endif() if (PIO_VERSION STREQUAL "1") set(CPPDEFS "${CPPDEFS} -DPIO1") -else() - set(USE_CXX TRUE) -endif() - -if (USE_CXX AND NOT SUPPORTS_CXX) - message(FATAL_ERROR "Fatal attempt to include C++ code on a compiler/machine combo that has not been set up to support C++") endif() # Not clear how to escape commas for libraries with their own configure @@ -132,71 +113,13 @@ if (USER_INCLDIR) list(APPEND INCLDIR "${USER_INCLDIR}") endif() -#=============================================================================== -# Set compilers -#=============================================================================== - -if (MPILIB STREQUAL "mpi-serial") - set(CC ${SCC}) - set(FC ${SFC}) - set(CXX ${SCXX}) - set(MPIFC ${SFC}) - set(MPICC ${SCC}) - set(MPICXX ${SCXX}) -else() - set(CC ${MPICC}) - set(FC ${MPIFC}) - set(CXX ${MPICXX}) -endif() - #=============================================================================== # Set include paths (needed after override for any model specific builds below) #=============================================================================== list(APPEND INCLDIR "${INSTALL_SHAREDPATH}/include" "${INSTALL_SHAREDPATH}/${COMP_INTERFACE}/${ESMFDIR}/${NINST_VALUE}/include") -if (NOT GLC_DIR) - set(GLC_DIR "${EXEROOT}/glc") -endif() - -if (NOT CISM_LIBDIR) - set(CISM_LIBDIR "${GLC_DIR}/lib") -endif() - -if (NOT GLCROOT) - # Backwards compatibility - set(GLCROOT "${CIMEROOT}/../components/cism") -endif() - -list(APPEND INCLDIR "${INSTALL_SHAREDPATH}/include") - string(FIND "${CAM_CONFIG_OPTS}" "-cosp" HAS_COSP) if (NOT HAS_COSP EQUAL -1) # The following is for the COSP simulator code: set(USE_COSP TRUE) endif() - -# Add libraries and flags that we need on the link line when C++ code is included -if (USE_CXX) - if (CXX_LIBS) - set(SLIBS "${SLIBS} ${CXX_LIBS}") - endif() - - if (CXX_LDFLAGS) - set(LDFLAGS "${LDFLAGS} ${CXX_LDFLAGS}") - endif() -endif() - -# Decide whether to use a C++ or Fortran linker, based on whether we -# are using any C++ code and the compiler-dependent CXX_LINKER variable -if (USE_CXX AND CXX_LINKER STREQUAL "CXX") - set(LD "CXX") -else() - set(LD "Fortran") - # Remove arch flag if it exists, it break fortran linking - string(REGEX REPLACE "-arch[^ ]+" "" LDFLAGS "${LDFLAGS}") -endif() - -#------------------------------------------------------------------------------ -# Set key cmake vars -#------------------------------------------------------------------------------ -set(CMAKE_EXE_LINKER_FLAGS "${LDFLAGS}" PARENT_SCOPE) diff --git a/components/eam/bld/configure b/components/eam/bld/configure index ecd7561c72a0..bca36cd18da6 100755 --- a/components/eam/bld/configure +++ b/components/eam/bld/configure @@ -2318,10 +2318,6 @@ if ($cosp) { unless (-d $bld_dir or mkdirp($bld_dir)) { die "** Could not create the cosp build directory: $bld_dir\n"; } - - # Create the COSP Makefile from a template and copy it into the cosp bld directory - write_cosp_makefile("$cfgdir/../src/physics/cosp2/Makefile.cospinline.in", "$cosp_libdir/Makefile"); - if ($print) { print "creating $cosp_libdir/Makefile\n"; } } diff --git a/components/eam/src/physics/cosp2/Makefile.cospinline.in b/components/eam/src/physics/cosp2/Makefile.cospinline.in deleted file mode 100644 index 2a16566371b6..000000000000 --- a/components/eam/src/physics/cosp2/Makefile.cospinline.in +++ /dev/null @@ -1,194 +0,0 @@ -.SUFFIXES : .F .f .c .o .a .f90 .f95 -######################################################################## -# -# The Makefile for building the COSP library is created by CAM's configure -# using this template and prepending the following macros: -# COSP_PATH, ISCCP_PATH, RS_PATH, CS_PATH, MISR_PATH, MODIS_PATH, RT_PATH, -# and PARASOL_PATH. -# -# The macro CAM_BLD is also prepended. It is the build directory of the CAM -# code and it contains the abortutils.mod file. The abortutils module is -# referenced by COSP code in order to perform an abort which is appropriate -# for the CESM system. -# -# The main customization required for the library to link with CAM is to -# use autopromotion of the default real type to real*8. This is required -# in most, though not all, of the COSP files. Also, some compilers require -# special flags to specify fixed or free format source (rather than depend -# on filename extensions). Thus, the explicit rules at the end of this -# template for compiling COSP files have been modified to allow different -# sets of flags for 1) files that cannot be compiled with autopromotion, -# and 2) files that use fixed format source. -# -# The generated Makefile will be used by a sub-Make issued from CAM's Make. -# The sub-Make will inherit the macros: -# -# FC name of Fortran90 compiler -# FC_FLAGS Fortran compiler flags -# -######################################################################## - -F90 := $(FC) -F90FLAGS := $(FREEFLAGS) $(FC_FLAGS) -VPATH := $(COSP_PATH) - -OBJS = cosp_kinds.o cosp_constants.o cosp_cloudsat_interface.o cosp_config.o \ - cosp.o cosp_stats.o quickbeam.o parasol.o lidar_simulator.o icarus.o \ - cosp_calipso_interface.o cosp_isccp_interface.o cosp_misr_interface.o \ - MISR_simulator.o cosp_modis_interface.o modis_simulator.o \ - cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_parasol_interface.o \ - scops.o prec_scops.o cosp_utils.o cosp_optics.o quickbeam_optics.o \ - mo_rng.o cosp_errorHandling.o array_lib.o math_lib.o optics_lib.o \ - mrgrnk.o cosp_grLidar532_interface.o cosp_atlid_interface.o - - -libcosp.a: $(OBJS) - ar cr libcosp.a $(OBJS) - -%.o: %.f90 - $(F90) -I$(CAM_BLD) $(F90FLAGS) -c $< -%.o: %.F90 - $(F90) -I$(CAM_BLD) $(F90FLAGS) -c $< - -# Dependencies (COSP2 library) -cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o \ - cosp_rttov_interfaceSTUB.o cosp_misr_interface.o \ - cosp_isccp_interface.o cosp_calipso_interface.o \ - cosp_cloudsat_interface.o cosp_stats.o cosp_parasol_interface.o \ - cosp_rttovSTUB.o cosp_rttov_interfaceSTUB.o quickbeam.o \ - MISR_simulator.o lidar_simulator.o parasol.o icarus.o \ - cosp_grLidar532_interface.o cosp_atlid_interface.o -cosp_config.o : cosp_kinds.o -cosp_stats.o : cosp_kinds.o cosp_config.o -cosp_calipso_interface.o : cosp_kinds.o lidar_simulator.o -cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o -cosp_isccp_interface.o : cosp_kinds.o icarus.o -cosp_misr_interface.o : cosp_kinds.o -cosp_modis_interface.o : cosp_kinds.o cosp_config.o modis_simulator.o -cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o -cosp_parasol_interface.o : cosp_kinds.o -cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o -MISR_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o -modis_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o -lidar_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o -icarus.o : cosp_kinds.o cosp_constants.o cosp_stats.o -parasol.o : cosp_kinds.o cosp_config.o cosp_constants.o -quickbeam.o : cosp_kinds.o cosp_config.o cosp_stats.o -# Dependencies (for COSP interface) -mo_rng.o : cosp_kinds.o -scops.o : cosp_kinds.o mo_rng.o cosp_errorHandling.o -prec_scops.o : cosp_kinds.o cosp_config.o -cosp_optics.o : cosp_kinds.o cosp_constants.o modis_simulator.o -quickbeam_optics.o : cosp_kinds.o cosp_config.o cosp_constants.o quickbeam.o \ - cosp_errorHandling.o array_lib.o math_lib.o optics_lib.o -optics_lib.o : cosp_kinds.o cosp_errorHandling.o -array_lib.o : cosp_kinds.o cosp_errorHandling.o -math_lib.o : cosp_kinds.o array_lib.o mrgrnk.o -mrgrnk.o : cosp_kinds.o -cosp_errorHandling.o : cosp_kinds.o -cosp_utils.o : cosp_kinds.o cosp_config.o -cosp_constants.o : cosp_kinds.o - -# -clean_objs: - rm -f $(OBJS) *.mod *.o - -clean: - rm -f $(PROG) $(OBJS) *.mod *.o fort.* - -icarus.o : $(ISCCP_PATH)/icarus.F90 - $(F90) $(F90FLAGS) -c $< - -quickbeam.o: $(RS_PATH)/quickbeam.F90 - $(F90) $(F90FLAGS) -c $< - -MISR_simulator.o : $(MISR_PATH)/MISR_simulator.F90 - $(F90) $(F90FLAGS) -c $< - -modis_simulator.o : $(MODIS_PATH)/modis_simulator.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_rttov_interfaceSTUB.o : $(COSP_PATH)/src/simulator/cosp_rttov_interfaceSTUB.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_misr_interface.o : $(COSP_PATH)/src/simulator/cosp_misr_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_modis_interface.o : $(COSP_PATH)/src/simulator/cosp_modis_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_isccp_interface.o : $(COSP_PATH)/src/simulator/cosp_isccp_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_calipso_interface.o : $(COSP_PATH)/src/simulator/cosp_calipso_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_grLidar532_interface.o : $(COSP_PATH)/src/simulator/cosp_grLidar532_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_atlid_interface.o : $(COSP_PATH)/src/simulator/cosp_atlid_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_cloudsat_interface.o : $(COSP_PATH)/src/simulator/cosp_cloudsat_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_parasol_interface.o : $(COSP_PATH)/src/simulator/cosp_parasol_interface.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_rttovSTUB.o : $(RT_PATH)/cosp_rttovSTUB.F90 - $(F90) $(F90FLAGS) -c $< - -lidar_simulator.o : $(CS_PATH)/lidar_simulator.F90 - $(F90) $(F90FLAGS) -c $< - -parasol.o : $(PARASOL_PATH)/parasol.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_constants.o : $(COSP_PATH)/src/cosp_constants.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_kinds.o : $(COSP_PATH)/cosp_kinds.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_config.o : $(COSP_PATH)/src/cosp_config.F90 - $(F90) $(F90FLAGS) -c $< - -cosp.o : $(COSP_PATH)/src/cosp.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_stats.o : $(COSP_PATH)/src/cosp_stats.F90 - $(F90) $(F90FLAGS) -c $< - -# COSPv1.4 interface -mo_rng.o : $(COSP_PATH)/subcol/mo_rng.F90 - $(F90) $(F90FLAGS) -c $< - -scops.o : $(COSP_PATH)/subcol/scops.F90 - $(F90) $(F90FLAGS) -c $< - -prec_scops.o : $(COSP_PATH)/subcol/prec_scops.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_utils.o : $(COSP_PATH)/optics/cosp_utils.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_optics.o : $(COSP_PATH)/optics/cosp_optics.F90 - $(F90) $(F90FLAGS) -c $< - -quickbeam_optics.o : $(COSP_PATH)/optics/quickbeam_optics.F90 - $(F90) $(F90FLAGS) -c $< - -array_lib.o : $(COSP_PATH)/optics/array_lib.F90 - $(F90) $(F90FLAGS) -c $< - -math_lib.o : $(COSP_PATH)/optics/math_lib.F90 - $(F90) $(F90FLAGS) -c $< - -mrgrnk.o : $(COSP_PATH)/optics/mrgrnk.F90 - $(F90) $(F90FLAGS) -c $< - -optics_lib.o : $(COSP_PATH)/optics/optics_lib.F90 - $(F90) $(F90FLAGS) -c $< - -cosp_errorHandling.o : $(COSP_PATH)/cosp_errorHandling.F90 - $(F90) $(F90FLAGS) -c $< diff --git a/components/mpas-framework/src/CMakeLists.txt b/components/mpas-framework/src/CMakeLists.txt index 53fdcf1e9fde..b086b433fa8f 100644 --- a/components/mpas-framework/src/CMakeLists.txt +++ b/components/mpas-framework/src/CMakeLists.txt @@ -30,12 +30,6 @@ else() set(ESMFDIR "noesmf") endif() -set(CMAKE_C_COMPILER ${MPICC}) -set(CMAKE_CXX_COMPILER ${MPICXX}) -set(CMAKE_Fortran_COMPILER ${MPIFC}) -set(CMAKE_EXE_LINKER_FLAGS "${LDFLAGS}") -set(CMAKE_VERBOSE_MAKEFILE TRUE) - # Set up CPPDEFS set(FILE_OFFSET "-DOFFSET64BIT") if (CPPDEFS) @@ -49,18 +43,14 @@ if (compile_threaded) list(APPEND CPPDEFS "-DMPAS_OPENMP") endif() -set(INCLUDES "${INSTALL_SHAREDPATH}/include" "${INSTALL_SHAREDPATH}/${COMP_INTERFACE}/${ESMFDIR}/${NINST_VALUE}/csm_share" "${INSTALL_SHAREDPATH}/pio" "${CMAKE_CURRENT_SOURCE_DIR}/external/ezxml" "${CMAKE_BINARY_DIR}/framework" "${CMAKE_BINARY_DIR}/operators") +set(INCLUDES "${INSTALL_SHAREDPATH}/include" "${CMAKE_CURRENT_SOURCE_DIR}/external/ezxml" "${CMAKE_BINARY_DIR}/framework" "${CMAKE_BINARY_DIR}/operators") if (USE_KOKKOS) include(${INSTALL_SHAREDPATH}/kokkos_generated_settings.cmake) string (REPLACE ";" " " KOKKOS_CXXFLAGS_STR "${KOKKOS_CXXFLAGS}") - set(CXXFLAGS "${CXXFLAGS} ${KOKKOS_CXXFLAGS_STR}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KOKKOS_CXXFLAGS_STR}") endif() -set(CMAKE_Fortran_FLAGS "${FFLAGS}") -set(CMAKE_C_FLAGS "${CFLAGS}") -set(CMAKE_CXX_FLAGS "${CXXFLAGS}") - # Include custom cmake libraries used for mpas include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_utils.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/build_core.cmake) @@ -77,8 +67,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/operators/operators.cmake) add_library(common) target_compile_definitions(common PRIVATE ${CPPDEFS}) target_include_directories(common PRIVATE ${INCLUDES}) -find_package(PIO REQUIRED) -target_link_libraries(common PUBLIC spio) +target_link_libraries(common PUBLIC spio csm_share) genf90_targets("${COMMON_RAW_SOURCES}" "${INCLUDES}" "${CPPDEFS}" "" "") target_sources(common PRIVATE ${SOURCES}) diff --git a/components/mpas-framework/src/Makefile.in.E3SM b/components/mpas-framework/src/Makefile.in.E3SM deleted file mode 100644 index dabf51adacf9..000000000000 --- a/components/mpas-framework/src/Makefile.in.E3SM +++ /dev/null @@ -1,92 +0,0 @@ -# Duplicate logic from Tools/Makefile to set compile_threaded -compile_threaded = FALSE -ifeq ($(strip $(SMP)),TRUE) - compile_threaded = TRUE - THREADDIR = threads -else - ifeq ($(strip $(BUILD_THREADED)),TRUE) - compile_threaded = TRUE - THREADDIR = threads - else - THREADDIR = nothreads - endif -endif -# End duplicated logic - -include $(CASEROOT)/Macros.make -# Load machine/compiler specific settings --include $(CASEROOT)/Depends.$(COMPILER) --include $(CASEROOT)/Depends.$(MACH) --include $(CASEROOT)/Depends.$(MACH).$(COMPILER) - -ifneq ($(wildcard core_$(CORE)/build_options.mk), ) # Check for build_options.mk - include core_$(CORE)/build_options.mk -else # ELSE Use Default Options - EXE_NAME=$(CORE)_model - NAMELIST_SUFFIX=$(CORE) -endif - -# Map the ESM component corresponding to each MPAS core -ifeq "$(CORE)" "ocean" - COMPONENT=ocn -else ifeq "$(CORE)" "landice" - COMPONENT=glc -else ifeq "$(CORE)" "seaice" - COMPONENT=ice -endif - -ifeq ($(strip $(USE_ESMF_LIB)), TRUE) - ESMFDIR = esmf -else - ESMFDIR = noesmf -endif - -RM = rm -f -CPP = cpp -P -traditional -FC=$(MPIFC) -CC=$(MPICC) -CXX=$(MPICXX) -NETCDF=$(NETCDF_PATH) -PNETCDF=$(PNETCDF_PATH) -PIO=$(INSTALL_SHAREDPATH)/pio -FILE_OFFSET = -DOFFSET64BIT -override CFLAGS += -DMPAS_NO_LOG_REDIRECT -DUSE_PIO2 -DMPAS_NO_ESMF_INIT -DMPAS_ESM_SHR_CONST -DMPAS_PERF_MOD_TIMERS -override FFLAGS += -DMPAS_NO_LOG_REDIRECT -DUSE_PIO2 -DMPAS_NO_ESMF_INIT -DMPAS_ESM_SHR_CONST -DMPAS_PERF_MOD_TIMERS -override CPPFLAGS += $(CPPDEFS) $(MODEL_FORMULATION) $(FILE_OFFSET) $(ZOLTAN_DEFINE) -DMPAS_NO_LOG_REDIRECT -DUSE_PIO2 -DMPAS_NO_ESMF_INIT -DMPAS_ESM_SHR_CONST -D_MPI -DMPAS_NAMELIST_SUFFIX=$(NAMELIST_SUFFIX) -DMPAS_EXE_NAME=$(EXE_NAME) -DMPAS_PERF_MOD_TIMERS -override CPPINCLUDES += -I$(EXEROOT)/$(COMPONENT)/source/inc -I$(INSTALL_SHAREDPATH)/include -I$(INSTALL_SHAREDPATH)/$(COMP_INTERFACE)/$(ESMFDIR)/$(NINST_VALUE)/csm_share -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include -override FCINCLUDES += -I$(EXEROOT)/$(COMPONENT)/source/inc -I$(INSTALL_SHAREDPATH)/include -I$(INSTALL_SHAREDPATH)/$(COMP_INTERFACE)/$(ESMFDIR)/$(NINST_VALUE)/csm_share -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include -LIBS += -L$(PIO) -L$(PNETCDF)/lib -L$(NETCDF)/lib -L$(LIBROOT) -L$(INSTALL_SHAREDPATH)/lib -lpio -lpnetcdf -lnetcdf - -ifeq ($(DEBUG), TRUE) - override CPPFLAGS += -DMPAS_DEBUG -endif - -ifeq ($(compile_threaded), TRUE) - override CPPFLAGS += -DMPAS_OPENMP -endif - -ifeq "$(GEN_F90)" "true" - override CPPFLAGS += -Uvector -endif - -all: - @echo $(CPPINCLUDES) - @echo $(FCINCLUDES) - ( $(MAKE) mpas RM="$(RM)" CPP="$(CPP)" NETCDF="$(NETCDF)" PNETCDF="$(PNETCDF)" \ - PIO="$(PIO)" FC="$(FC)" CC="$(CC)" CXX="$(CXX)" SFC="$(SFC)" SCC="$(SCC)" \ - CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" FCINCLUDES="$(FCINCLUDES)" \ - FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ) - -mpas: externals frame ops dycore drver - ar ru lib$(COMPONENT).a framework/*.o - ar ru lib$(COMPONENT).a operators/*.o - ar ru lib$(COMPONENT).a external/ezxml/*.o - ar ru lib$(COMPONENT).a `find core_$(CORE)/ -type f -name "*.o"` # Find command finds objects in any subdirectories - ar ru lib$(COMPONENT).a $(DRIVER)/*.o - -externals: - ( cd external; $(MAKE) FC="$(FC)" SFC="$(SFC)" CC="$(CC)" CXX="$(CXX)" SCC="$(SCC)" FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" NETCDF="$(NETCDF)" CORE="$(CORE)" ezxml-lib ) - -drver: externals frame ops dycore - ( cd $(DRIVER); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" FREEFLAGS="$(FREEFLAGS)" all ) - diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index e62b58afa3b5..d00efb9cbcbb 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -20,19 +20,15 @@ function(set_compilers_e3sm) # Grab CXX compiler from CIME include(${CASEROOT}/Macros.cmake) - if (MPILIB STREQUAL "mpi-serial") - set(CC ${SCC}) - set(FC ${SFC}) - set(CXX ${SCXX}) + if (DEBUG) + set(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "build type, inferred from ${DEBUG}") else() - set(CC ${MPICC}) - set(FC ${MPIFC}) - set(CXX ${MPICXX}) + set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "build type, inferred from ${DEBUG}") endif() - set(CMAKE_CXX_COMPILER ${CXX} CACHE STRING "The CXX compiler") - set(CMAKE_C_COMPILER ${CC} CACHE STRING "The C compiler") - set(CMAKE_Fortran_COMPILER ${FC} CACHE STRING "The Fortran compiler") + set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "The CXX compiler") + set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "The C compiler") + set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING "The Fortran compiler") # USE_CUDA or USE_HIP is set through Macros.cmake # For instance: cime_config/machines/cmake_macros/gnugpu_summit.cmake @@ -82,19 +78,6 @@ list(APPEND CMAKE_MODULE_PATH ${CIMEROOT}/CIME/non_py/src/CMake) set(CMAKE_VERBOSE_MAKEFILE TRUE) -# We do want CMAKE_BUILD_TYPE to be set, but we do NOT want CMake to -# decide what optimization flags to append, based on build type, -# for components who rely on CIME for build flags, so make all the following empty. -# JGF: I think we can remove this once proper CMake names are being used in the -# macros. -set (CMAKE_C_FLAGS_RELEASE "") -set (CMAKE_CXX_FLAGS_RELEASE "") -set (CMAKE_Fortran_FLAGS_RELEASE "") - -set (CMAKE_C_FLAGS_DEBUG "") -set (CMAKE_CXX_FLAGS_DEBUG "") -set (CMAKE_Fortran_FLAGS_DEBUG "") - set(BUILDCONF ${CASEROOT}/Buildconf) # Set global targets diff --git a/share/build/buildlib.gptl b/share/build/buildlib.gptl index 0623fc2212f4..395508f0f891 100755 --- a/share/build/buildlib.gptl +++ b/share/build/buildlib.gptl @@ -2,7 +2,7 @@ from standard_script_setup import * from CIME.utils import run_bld_cmd_ensure_logging from CIME.case import Case -from CIME.build import get_standard_makefile_args +from CIME.build import get_standard_cmake_args logger = logging.getLogger(__name__) @@ -44,8 +44,9 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter ############################################################################### def buildlib(bldroot, installpath, case): ############################################################################### - caseroot = case.get_value("CASEROOT") - comp_interface = case.get_value("COMP_INTERFACE") + srcroot = case.get_value("SRCROOT") + gmake_cmd = case.get_value("GMAKE") + gmake_j = case.get_value("GMAKE_J") gptl_dir = os.environ.get("GPTL_ROOT") if gptl_dir is not None: @@ -53,17 +54,18 @@ def buildlib(bldroot, installpath, case): expect(os.path.exists(gptl_dir), f"Non-existent gptl root {gptl_dir}") return - gptl_dir = os.path.join(case.get_value("SRCROOT"), "share", "timing") - gmake_opts = "-f {gptl}/Makefile install -C {bldroot} MACFILE={macfile} COMP_NAME=gptl GPTL_DIR={gptl} GPTL_LIBDIR={bldroot}"\ - " SHAREDPATH={install} COMP_INTERFACE={comp_interface} {stdargs} "\ - .format(gptl=gptl_dir, bldroot=bldroot, macfile=os.path.join(caseroot,"Macros.make"), - install=installpath, comp_interface=comp_interface, stdargs=get_standard_makefile_args(case, shared_lib=True)) + libdir = os.path.join(bldroot, "gptl") + if not os.path.isdir(libdir): + os.makedirs(libdir) - gmake_cmd = case.get_value("GMAKE") + gptl_dir = os.path.join(srcroot, "share", "timing") + cmake_cmd = "cmake {stdargs} -DCOMP_NAME=gptl -DGPTL_DIR={gptl} -DCMAKE_INSTALL_PREFIX={install} {gptl}".format( + gptl=gptl_dir, install=installpath, stdargs=get_standard_cmake_args(case, installpath)) - # This runs the gptl make command - cmd = "{} {}".format(gmake_cmd, gmake_opts) - run_bld_cmd_ensure_logging(cmd, logger) + logger.info(f"Running in dir {libdir}") + run_bld_cmd_ensure_logging(cmake_cmd, logger, from_dir=libdir) + run_bld_cmd_ensure_logging(f"{gmake_cmd} -j {gmake_j}", logger, from_dir=libdir) + run_bld_cmd_ensure_logging(f"{gmake_cmd} install", logger, from_dir=libdir) ############################################################################### def _main(argv, documentation): diff --git a/share/build/buildlib.kokkos b/share/build/buildlib.kokkos index 177d296a581f..1b08afa3dd63 100755 --- a/share/build/buildlib.kokkos +++ b/share/build/buildlib.kokkos @@ -8,11 +8,14 @@ from CIME.utils import expect, run_bld_cmd_ensure_logging, run_cmd_no_fail, run_ from CIME.case import Case from CIME.build import get_standard_makefile_args -logger = logging.getLogger(__name__) +sys.path.append(os.path.dirname(__file__)) +from buildlib_util import extract_from_macros +logger = logging.getLogger(__name__) +############################################################################### def parse_command_line(args, description): - ############################################################################### +############################################################################### parser = argparse.ArgumentParser( usage="""\n{0} [--debug] OR @@ -44,7 +47,6 @@ OR return args.buildroot, args.installpath, args.caseroot - ############################################################################### def buildlib(bldroot, installpath, case): ############################################################################### @@ -76,26 +78,16 @@ def buildlib(bldroot, installpath, case): # We want to get the compiler and kokkos_options from Macros.make # (generated from cmake_macros), but we want to otherwise # let kokkos control flags - make_args = get_standard_makefile_args(case, shared_lib=True) - try: - output = run_cmd_no_fail("make -f Macros.make {} -p | grep KOKKOS_OPTIONS".format(make_args)) - except CIMEError: - expect(False, "No KOKKOS_OPTIONS set in your cmake_macros for this machine/compiler.") + macro_vals = extract_from_macros(case, "kokkos", extra_vars=("KOKKOS_OPTIONS",)) + cxx, kokkos_options_raw = macro_vals[2], macro_vals[-1] - kokkos_options = output.split(":=")[-1].strip() + kokkos_options = kokkos_options_raw.split(":=")[-1].strip() # We will take care of setting CMAKE_CXX_COMPILER unless user has explictly # set one in their KOKKOS_OPTIONS. - cxx = "" if "DCMAKE_CXX_COMPILER" not in kokkos_options: if "Kokkos_ENABLE_CUDA" in kokkos_options: cxx = os.path.join(kokkos_dir, "bin/nvcc_wrapper") - else: - cxx = ( - run_cmd_no_fail("make -f Macros.make {} -p | grep SCXX".format(make_args)) - .split(":=")[-1] - .strip() - ) if "/" in cxx: cxx = "-DCMAKE_CXX_COMPILER={}".format(cxx) @@ -107,12 +99,7 @@ def buildlib(bldroot, installpath, case): gmake_cmd = case.get_value("GMAKE") gmake_j = case.get_value("GMAKE_J") - gen_makefile_cmd = "cmake {kokkos_options} {cxx} -DCMAKE_INSTALL_PREFIX={installpath} {kokkos_dir}".format( - kokkos_dir=kokkos_dir, - kokkos_options=kokkos_options, - cxx=cxx, - installpath=installpath, - ) + gen_makefile_cmd = f"cmake {kokkos_options} {cxx} -DCMAKE_INSTALL_PREFIX={installpath} {kokkos_dir}" # When later we use find_package to get kokkos in CMake, the folder # install_sharedpath/kokkos (which is bldroot here) gets picked over @@ -131,12 +118,13 @@ def buildlib(bldroot, installpath, case): ) run_bld_cmd_ensure_logging("{} install".format(gmake_cmd), logger, from_dir=bldroot) - +############################################################################### def _main(argv, documentation): +############################################################################### bldroot, installpath, caseroot = parse_command_line(argv, documentation) with Case(caseroot, read_only=False) as case: buildlib(bldroot, installpath, case) - +############################################################################### if __name__ == "__main__": _main(sys.argv, __doc__) diff --git a/share/build/buildlib.mct b/share/build/buildlib.mct index 36e957a7e589..54346bc302d9 100755 --- a/share/build/buildlib.mct +++ b/share/build/buildlib.mct @@ -85,7 +85,7 @@ def buildlib(bldroot, installpath, case): # fc, cc, _, mfc, mcc, _, fflags, cflags, _, cppdefs, ldflags, ffree, config_args = \ - extract_from_macros(case, "mct", extra_vars=("FREEFLAGS", "CONFIG_ARGS")) + extract_from_macros(case, "mct", extra_vars=("CMAKE_Fortran_FORMAT_FREE_FLAG", "CONFIG_ARGS")) fflags += f" {ffree} -I{installpath}/include" cflags += f" -I{installpath}/include" diff --git a/share/build/buildlib.mpi-serial b/share/build/buildlib.mpi-serial index d8bcb223616b..b024e303f545 100755 --- a/share/build/buildlib.mpi-serial +++ b/share/build/buildlib.mpi-serial @@ -67,9 +67,8 @@ def buildlib(bldroot, installpath, case): for _file in glob.iglob(os.path.join(mpi_serial_path, "*.h")): copyifnewer(_file, os.path.join(bldroot, os.path.basename(_file))) - # Hacky way of getting stuff from Macros. fc, cc, _, _, _, _, fflags, cflags, _, cppdefs, ldflags, ffree, config_args = \ - extract_from_macros(case, "mpi-serial", extra_vars=("FREEFLAGS", "CONFIG_ARGS")) + extract_from_macros(case, "mpi-serial", extra_vars=("CMAKE_Fortran_FORMAT_FREE_FLAG", "CONFIG_ARGS")) fflags += f" {ffree}" diff --git a/share/build/buildlib.spio b/share/build/buildlib.spio index 53daa41e0b24..603b56d27e7f 100755 --- a/share/build/buildlib.spio +++ b/share/build/buildlib.spio @@ -145,9 +145,10 @@ def buildlib(bldroot, installpath, case): cmake_opts += "-DPIO_ENABLE_TESTS:BOOL=OFF -DPIO_USE_MALLOC:BOOL=ON " cmake_opts += f"-DUSER_CMAKE_MODULE_PATH:LIST={cimeroot}/CIME/non_py/src/CMake " - # Scorpio should just load the E3SM macros once are using cmake names for things - sfc, scc, scxx, mfc, mcc, mcxx, fflags, cflags, cxxflags, cppdefs, ldflags, cxx_libs, spio_cmake_opts, pio_hints = \ - extract_from_macros(case, "spio", extra_vars=("CXX_LIBS", "CMAKE_OPTS", "PIO_FILESYSTEM_HINTS")) + # Scorpio cmake system is not 100% compatible with the e3sm macros, so we have + # to pull out the items we need from the macros + sfc, scc, scxx, mfc, mcc, mcxx, fflags, cflags, cxxflags, cppdefs, ldflags, spio_cmake_opts, pio_hints = \ + extract_from_macros(case, "spio", extra_vars=("SPIO_CMAKE_OPTS", "PIO_FILESYSTEM_HINTS")) cppdefs += " -DTIMING" @@ -169,9 +170,6 @@ def buildlib(bldroot, installpath, case): if spio_cmake_opts: cmake_opts += spio_cmake_opts + " " - if cxx_libs: - ldflags += " " + cxx_libs - if pio_hints: cmake_opts += f"-DPIO_FILESYSTEM_HINTS:STRING='$(PIO_FILESYSTEM_HINTS)' " diff --git a/share/build/buildlib_util.py b/share/build/buildlib_util.py index 4916dc802cfc..2609bb198d99 100644 --- a/share/build/buildlib_util.py +++ b/share/build/buildlib_util.py @@ -24,8 +24,8 @@ def extract_from_macros(case, comp_name, extra_vars=()): """ standard_vars = ["SFC", "SCC", "SCXX", "MPIFC", "MPICC", "MPICXX", - "FFLAGS", "CFLAGS", "CXXFLAGS", - "CPPDEFS", "LDFLAGS"] + "CMAKE_Fortran_FLAGS", "CMAKE_C_FLAGS", "CMAKE_CXX_FLAGS", + "CPPDEFS", "CMAKE_EXE_LINKER_FLAGS"] all_vars = standard_vars + list(extra_vars) make_args = get_standard_makefile_args(case, shared_lib=True) diff --git a/share/timing/CMakeLists.txt b/share/timing/CMakeLists.txt index f882ded14dd8..d62fec6bc9e4 100644 --- a/share/timing/CMakeLists.txt +++ b/share/timing/CMakeLists.txt @@ -1,24 +1,74 @@ -INCLUDE(FortranCInterface) +cmake_minimum_required(VERSION 3.18) + +# Needs to happen before project call +function(set_compilers_e3sm) + # Grab CXX compiler from CIME + include(${CASEROOT}/Macros.cmake) + + set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "The CXX compiler") + set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "The C compiler") + set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING "The Fortran compiler") + +endfunction() +set_compilers_e3sm() + +include(${CASEROOT}/Macros.cmake) + +project(GPTL C Fortran) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +include(${CASEROOT}/Macros.cmake) + +include(FortranCInterface) FortranCInterface_HEADER(cmake_fortran_c_interface.h - MACRO_NAMESPACE "FCI_") + MACRO_NAMESPACE "FCI_") + +# Just assume all files are free +set(CMAKE_Fortran_FORMAT FREE) + +set(SRCS_C + GPTLget_memusage.c + GPTLprint_memusage.c + GPTLutil.c + f_wrappers.c + gptl.c + gptl_papi.c) + +set(SRCS_F90 + perf_mod.F90 + perf_utils.F90) -ADD_DEFINITIONS(${PIO_DEFINITIONS}) +set(TIMING_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${GPTL_DIR} + ${INSTALL_SHAREDPATH}/include) -SET(TIMING_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - CACHE STRING "") -INCLUDE_DIRECTORIES(${TIMING_INCLUDE_DIRS}) +set(TIMING_CPPDEFS "-DINCLUDE_CMAKE_FCI") +if (NOT MPILIB STREQUAL "mpi-serial") + string(APPEND TIMING_CPPDEFS " -DHAVE_MPI") +endif() +if (compile_threaded) + string(APPEND TIMING_CPPDEFS " -DTHREADED_OMP") +endif() +string(TOUPPER COMP_INTERFACE UPVAR) +string(APPEND TIMING_CPPDEFS " -D${UPVAR}_INTERFACE") +if (DEBUG) + string(APPEND TIMING_CPPDEFS " -DDEBUG") +endif() -ADD_DEFINITIONS(-DINCLUDE_CMAKE_FCI -DHAVE_MPI) +if (CPRE) + # Not sure what to do here or if this is really needed +endif() -SET(SRCS_C GPTLget_memusage.c - GPTLprint_memusage.c - GPTLutil.c - f_wrappers.c - gptl.c - gptl_papi.c) +set(CPPDEFS "${CPPDEFS} ${TIMING_CPPDEFS}") +separate_arguments(CPPDEFS_LIST UNIX_COMMAND "${CPPDEFS}") -SET(SRCS_F90 perf_mod.F90 - perf_utils.F90) +add_library(gptl ${SRCS_F90} ${SRCS_C}) +target_include_directories(gptl PRIVATE ${TIMING_INCLUDE_DIRS}) +target_compile_definitions(gptl PRIVATE ${CPPDEFS_LIST}) +set_target_properties(gptl PROPERTIES PUBLIC_HEADER "gptl.h;${CMAKE_BINARY_DIR}/perf_mod.mod;${CMAKE_BINARY_DIR}/perf_utils.mod;") -ADD_LIBRARY(timing ${SRCS_F90} ${SRCS_C}) +install(TARGETS gptl + PUBLIC_HEADER DESTINATION include) diff --git a/share/timing/Makefile b/share/timing/Makefile deleted file mode 100644 index 89f3b4a7bed0..000000000000 --- a/share/timing/Makefile +++ /dev/null @@ -1,108 +0,0 @@ -.SUFFIXES: -.SUFFIXES: .F90 .o .c .f90 -# name of macros file - but default this is generic - -VPATH := $(GPTL_DIR) - -ifndef MOD_SUFFIX - MOD_SUFFIX := mod -endif -ifeq ($(strip $(SMP)),TRUE) - CPPDEFS += -DTHREADED_OMP - compile_threaded=TRUE -endif - -ifeq ($(strip $(MACFILE)),) - MACFILE := Macros.make -endif - -# Machine specific macros file -# This must be included before any settings are overwritten -# But must be AFTER any definitions it uses are defined. -# So be careful if moving this either earlier or later in the makefile!!! -include $(MACFILE) -ifdef COMP_INTERFACE - UPVAR := $(shell echo $(COMP_INTERFACE) | tr a-z A-Z) - CPPDEFS+=-D$(UPVAR)_INTERFACE - ifeq ("$(COMP_INTERFACE)", "nuopc") - # Set esmf.mk location with ESMF_LIBDIR having precedence over ESMFMKFILE - CIME_ESMFMKFILE := undefined_ESMFMKFILE - ifdef ESMFMKFILE - CIME_ESMFMKFILE := $(ESMFMKFILE) - endif - ifdef ESMF_LIBDIR - CIME_ESMFMKFILE := $(ESMF_LIBDIR)/esmf.mk - endif - -include $(CIME_ESMFMKFILE) - FFLAGS += $(ESMF_F90COMPILEPATHS) - endif -endif -ifdef DEBUG - ifeq ("$(DEBUG)", "TRUE") - CPPDEFS+=-DDEBUG - endif -endif -ifdef GPTL_CPPDEFS - CPPDEFS+=$(GPTL_CPPDEFS) -D$(OS) -DCPR$(shell echo $(COMPILER) | tr a-z A-z) -endif -INCLDIR += -I$(GPTL_DIR) - -ifeq ($(strip $(MPILIB)), mpi-serial) - CC := $(SCC) - FC := $(SFC) - MPIFC := $(SFC) - MPICC := $(SCC) - INCLDIR += -I$(GPTL_LIBDIR)/../mct/mpi-serial -else - CC := $(MPICC) - FC := $(MPIFC) - CPPDEFS += -DHAVE_MPI -endif -ifdef CPRE - FPPDEFS := $(patsubst -D%,$(CPRE)%,$(CPPDEFS)) -else - FPPDEFS := $(CPPDEFS) -endif - - - -OBJS = gptl.o GPTLutil.o GPTLget_memusage.o GPTLprint_memusage.o \ - gptl_papi.o f_wrappers.o perf_mod.o perf_utils.o - -AR ?= ar -ARFLAGS ?= ruv - -libgptl.a: $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) - - - -.c.o: - $(CC) -c $(INCLDIR) $(INCS) $(CFLAGS) $(CPPDEFS) $< -.F.o: - $(FC) -c $(INCLDIR) $(INCS) $(FFLAGS) $(FPPDEFS) $(FIXEDFLAGS) $< -.f90.o: - $(FC) -c $(INCLDIR) $(INCS) $(FFLAGS) $(FREEFLAGS) $< -.F90.o: - $(FC) -c $(INCLDIR) $(INCS) $(FFLAGS) $(FPPDEFS) $(FREEFLAGS) $< - -mostlyclean: - $(RM) -f *.f *.f90 - -clean: - $(RM) -f *.f *.f90 *.d *.$(MOD_SUFFIX) $(OBJS) - - -install: libgptl.a - cp -p $(GPTL_DIR)/gptl.h $(SHAREDPATH)/include - cp -p *.$(MOD_SUFFIX) $(SHAREDPATH)/include - cp -p libgptl.a $(SHAREDPATH)/lib - - -perf_mod.o: perf_utils.o -f_wrappers.o: gptl.h private.h -f_wrappers_pmpi.o: gptl.h private.h -gptl.o: gptl.h private.h -util.o: gptl.h private.h -gptl_papi.o: gptl.h private.h -pmpi.o: gptl.h private.h