From be7905d2b0a3e179c8e66a100d83239dc3ceeb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20=C3=96rn=20=C3=93lason?= Date: Tue, 27 Aug 2024 13:26:40 +0200 Subject: [PATCH] Minor cleaning Just sorting out and gathering some output strings. --- CMakeLists.txt | 2 +- physics/src/include/OASISCoupled.hpp | 2 ++ .../OceanBoundaryModule/OASISCoupledOcean.cpp | 16 +++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18c4694e5..ac7067b5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ if (ENABLE_OASIS) target_link_libraries(nextsimlib PUBLIC oasis.cbind mct mpeu psmile.MPI1 scrip netcdff) target_include_directories(nextsimlib PRIVATE ${OASIS_INCLUDES}) else () - message(FATAL_ERROR "Not building with OASIS support, because MPI is not enabled" .) + message(FATAL_ERROR "Cannot build with OASIS support, because MPI is not enabled" .) endif () endif () diff --git a/physics/src/include/OASISCoupled.hpp b/physics/src/include/OASISCoupled.hpp index 8363974e6..1ac041e5d 100644 --- a/physics/src/include/OASISCoupled.hpp +++ b/physics/src/include/OASISCoupled.hpp @@ -21,6 +21,8 @@ class OASISCoupled { ~OASISCoupled() { OASIS_CHECK_ERR(!oasis_c_terminate()); } #else ~OASISCoupled() { } + const std::string OASISError + = "Cannot access OASIS interface, as OASIS support was not activated at compile time.\n"; #endif virtual std::string getName() const { return "OASISCoupled"; } diff --git a/physics/src/modules/OceanBoundaryModule/OASISCoupledOcean.cpp b/physics/src/modules/OceanBoundaryModule/OASISCoupledOcean.cpp index a8dd75ee1..cb73e98a5 100644 --- a/physics/src/modules/OceanBoundaryModule/OASISCoupledOcean.cpp +++ b/physics/src/modules/OceanBoundaryModule/OASISCoupledOcean.cpp @@ -1,7 +1,7 @@ /*! * @file OASISCoupledOcean.cpp * - * @date Sep 26, 2022 + * @date 27 Aug 2024 * @author Tim Spain * @author Einar Ólason */ @@ -40,8 +40,7 @@ void OASISCoupledOcean::setMetadata(const ModelMetadata& metadata) // OASIS finalising definition OASIS_CHECK_ERR(oasis_c_enddef()); #else - std::string message = __func__ + std::string(": OASIS support not compiled in.\n"); - throw std::runtime_error(message); + throw std::runtime_error(std::string(__func__) + ": " + OASISError); #endif } @@ -87,8 +86,7 @@ void OASISCoupledOcean::updateBefore(const TimestepTime& tst) Module::getImplementation().update(tst); #else - std::string message = __func__ + std::string(": OASIS support not compiled in.\n"); - throw std::runtime_error(message); + throw std::runtime_error(std::string(__func__) + ": " + OASISError); #endif } @@ -110,7 +108,7 @@ void OASISCoupledOcean::updateAfter(const TimestepTime& tst) OASIS_DOUBLE, OASIS_COL_MAJOR, &dummy[0], OASIS_No_Restart, &kinfo)); OASIS_CHECK_ERR(oasis_c_put(couplingId.at(EMPKey), OASISTime, dimension0, dimension1, 1, - OASIS_DOUBLE, OASIS_COL_MAJOR, &dummy[0], OASIS_No_Restart, &kinfo)); + OASIS_DOUBLE, OASIS_COL_MAJOR, &emp[0], OASIS_No_Restart, &kinfo)); OASIS_CHECK_ERR(oasis_c_put(couplingId.at(QSWKey), OASISTime, dimension0, dimension1, 1, OASIS_DOUBLE, OASIS_COL_MAJOR, &dummy[0], OASIS_No_Restart, &kinfo)); @@ -130,8 +128,7 @@ void OASISCoupledOcean::updateAfter(const TimestepTime& tst) // Increment the "OASIS" time by the number of seconds in the time step updateOASISTime(tst); #else - std::string message = __func__ + std::string(": OASIS support not compiled in.\n"); - throw std::runtime_error(message); + throw std::runtime_error(std::string(__func__) + ": " + OASISError); #endif } @@ -177,7 +174,8 @@ OASISCoupledOcean::HelpMap& OASISCoupledOcean::getHelpText(HelpMap& map, bool ge { SSHConfigKey, ConfigType::STRING, {}, SSHKeyDefault, "", "The field name for sea surface height used in namcouple" }, { MLDConfigKey, ConfigType::STRING, {}, MLDKeyDefault, "", - "The field name for the thickness of the first ocean layer in namcouple (if that's defined)." }, + "The field name for the thickness of the first ocean layer in namcouple (if that's " + "defined)." }, { TauXConfigKey, ConfigType::STRING, {}, TauXKeyDefault, "", "The field name for the x-component of ice-ocean stress in namcouple." }, { TauYConfigKey, ConfigType::STRING, {}, TauYKeyDefault, "",