diff --git a/components/omega/CMakeLists.txt b/components/omega/CMakeLists.txt index 1f4e1d666d99..3d0c487d4992 100644 --- a/components/omega/CMakeLists.txt +++ b/components/omega/CMakeLists.txt @@ -38,7 +38,7 @@ if (NOT DEFINED PROJECT_NAME) # Collect machine and compiler info from CIME init_standalone_build() - set(CMAKE_CXX_STANDARD 17) # used in E3SM + set(CMAKE_CXX_STANDARD 20) # used in E3SM set(CMAKE_CXX_STANDARD_REQUIRED ON) project(${OMEGA_PROJECT_NAME} diff --git a/components/omega/external/CMakeLists.txt b/components/omega/external/CMakeLists.txt index 46e1ca7c19b9..45d1441e34dc 100644 --- a/components/omega/external/CMakeLists.txt +++ b/components/omega/external/CMakeLists.txt @@ -135,9 +135,10 @@ endif() # Add the cpptrace library if (NOT TARGET cpptrace::cpptrace) - option(CPPTRACE_INHERIT_HOST_STANDARD "" ON) - add_subdirectory( - ${OMEGA_SOURCE_DIR}/external/cpptrace - ${CMAKE_CURRENT_BINARY_DIR}/external/cpptrace - ) + option(CPPTRACE_INHERIT_HOST_STANDARD "" ON) + option(CPPTRACE_DISABLE_CXX_20_MODULES "" ON) + add_subdirectory( + ${OMEGA_SOURCE_DIR}/external/cpptrace + ${CMAKE_CURRENT_BINARY_DIR}/external/cpptrace + ) endif() diff --git a/components/omega/src/infra/LogFormatters.h b/components/omega/src/infra/LogFormatters.h index 411a5e457c52..164ae8991a60 100644 --- a/components/omega/src/infra/LogFormatters.h +++ b/components/omega/src/infra/LogFormatters.h @@ -18,20 +18,20 @@ struct fmt::formatter \ : fmt::formatter { \ auto format(OMEGA::ARR##DIM##TYPE my, \ - format_context &ctx) -> decltype(ctx.out()) { \ + format_context &ctx) const -> decltype(ctx.out()) { \ return fmt::format_to(ctx.out(), "{}({}D:{})", my.label(), my.rank(), \ my.size()); \ } \ }; #else -#define GENERATE_FORMATTER(ARR, DIM, TYPE) \ - template <> \ - struct fmt::formatter \ - : fmt::formatter { \ - auto format(OMEGA::ARR##DIM##TYPE my, \ - format_context &ctx) -> decltype(ctx.out()) { \ - return fmt::format_to(ctx.out(), "{}", my.label()); \ - } \ +#define GENERATE_FORMATTER(ARR, DIM, TYPE) \ + template <> \ + struct fmt::formatter \ + : fmt::formatter { \ + auto format(OMEGA::ARR##DIM##TYPE my, \ + format_context &ctx) const -> decltype(ctx.out()) { \ + return fmt::format_to(ctx.out(), "{}", my.label()); \ + } \ }; #endif diff --git a/components/omega/src/infra/Logging.cpp b/components/omega/src/infra/Logging.cpp index 5cf4a0c6cb7b..be007d53ff40 100644 --- a/components/omega/src/infra/Logging.cpp +++ b/components/omega/src/infra/Logging.cpp @@ -21,7 +21,7 @@ namespace OMEGA { //------------------------------------------------------------------------------ // Utility function to create a log message with prefix -std::string +fmt::runtime_format_string<> _PackLogMsg(const char *file, //[in] file from where log called (cpp __FILE__) int line, //[in] src code line where called (cpp __LINE__) const std::string &msg //[in] message text @@ -31,11 +31,11 @@ _PackLogMsg(const char *file, //[in] file from where log called (cpp __FILE__) std::string path(file); size_t pos = path.find_last_of("\\/"); if (pos != std::string::npos) { - return "[" + path.substr(pos + 1) + ":" + std::to_string(line) + "] " + - msg; + return fmt::runtime("[" + path.substr(pos + 1) + ":" + + std::to_string(line) + "] " + msg); } // add prefix of form [file:line] to message string - return "[" + path + ":" + std::to_string(line) + "] " + msg; + return fmt::runtime("[" + path + ":" + std::to_string(line) + "] " + msg); } //------------------------------------------------------------------------------ diff --git a/components/omega/src/infra/Logging.h b/components/omega/src/infra/Logging.h index c2599a54c366..b1a5635a1dc7 100644 --- a/components/omega/src/infra/Logging.h +++ b/components/omega/src/infra/Logging.h @@ -165,7 +165,7 @@ int initLogging( ); /// Utility function to create a log message with prefix -std::string +fmt::runtime_format_string<> _PackLogMsg(const char *file, ///< [in] file where log called (cpp __FILE__) int line, ///< [in] src code line where log (cpp __LINE__) const std::string &msg ///< [in] message text diff --git a/components/omega/src/infra/OmegaKokkos.h b/components/omega/src/infra/OmegaKokkos.h index a7ab8bca89da..a89fa525df16 100644 --- a/components/omega/src/infra/OmegaKokkos.h +++ b/components/omega/src/infra/OmegaKokkos.h @@ -52,9 +52,10 @@ template constexpr ArrayDataType checkArrayType() { // determine ArrayMemLoc from Kokkos array type template constexpr ArrayMemLoc findArrayMemLoc() { - if (std::is_same_v) { + if constexpr (std::is_same_v) { return ArrayMemLoc::Both; - } else if (T::is_hostspace) { + } else if constexpr (std::is_same_v) { return ArrayMemLoc::Host; } else { return ArrayMemLoc::Device;