From 592e1a9f8f3a151c69d48961c83b68d73404fe15 Mon Sep 17 00:00:00 2001 From: Steven Brus Date: Fri, 25 Oct 2024 19:58:44 -0400 Subject: [PATCH] Fix linting issues --- components/omega/src/ocn/OceanState.cpp | 22 ++++----- components/omega/src/ocn/OceanState.h | 3 +- components/omega/src/ocn/Tracers.cpp | 2 +- components/omega/test/ocn/StateTest.cpp | 46 +++++++++++++------ .../test/timeStepping/TimeStepperTest.cpp | 4 +- 5 files changed, 47 insertions(+), 30 deletions(-) diff --git a/components/omega/src/ocn/OceanState.cpp b/components/omega/src/ocn/OceanState.cpp index be4db3309053..da02e742c07f 100644 --- a/components/omega/src/ocn/OceanState.cpp +++ b/components/omega/src/ocn/OceanState.cpp @@ -93,7 +93,6 @@ OceanState::OceanState( LayerThicknessH.resize(NTimeLevels); NormalVelocityH.resize(NTimeLevels); - for (int I = 0; I < NTimeLevels; I++) { LayerThicknessH[I] = HostArray2DR8("LayerThickness" + std::to_string(I), NCellsSize, NVertLevels); @@ -315,13 +314,11 @@ void OceanState::defineFields() { // Associate Field with data I4 TimeIndex = getTimeIndex(0); - Err = NormalVelocityField->attachData( - NormalVelocity[TimeIndex]); + Err = NormalVelocityField->attachData(NormalVelocity[TimeIndex]); if (Err != 0) LOG_ERROR("Error attaching data array to field {}", NormalVelocityFldName); - Err = LayerThicknessField->attachData( - LayerThickness[TimeIndex]); + Err = LayerThicknessField->attachData(LayerThickness[TimeIndex]); if (Err != 0) LOG_ERROR("Error attaching data array to field {}", LayerThicknessFldName); @@ -352,9 +349,10 @@ void OceanState::read(int StateFileID, I4 CellDecompR8, I4 EdgeDecompR8) { I4 Err; + I4 TimeIndex = getTimeIndex(0); + // Read LayerThickness int LayerThicknessID; - I4 TimeIndex = getTimeIndex(0); Err = IO::readArray(LayerThicknessH[TimeIndex].data(), NCellsAll, "layerThickness", StateFileID, CellDecompR8, LayerThicknessID); @@ -373,7 +371,8 @@ void OceanState::read(int StateFileID, I4 CellDecompR8, I4 EdgeDecompR8) { //------------------------------------------------------------------------------ // Get layer thickness device array -I4 OceanState::getLayerThickness(Array2DReal &LayerThick, const I4 TimeLevel) const { +I4 OceanState::getLayerThickness(Array2DReal &LayerThick, + const I4 TimeLevel) const { I4 Err = 0; I4 TimeIndex = getTimeIndex(TimeLevel); @@ -396,7 +395,8 @@ I4 OceanState::getLayerThicknessH(HostArray2DReal &LayerThickH, //------------------------------------------------------------------------------ // Get normal velocity device array -I4 OceanState::getNormalVelocity(Array2DReal &NormVel, const I4 TimeLevel) const { +I4 OceanState::getNormalVelocity(Array2DReal &NormVel, + const I4 TimeLevel) const { I4 Err = 0; @@ -451,8 +451,7 @@ I4 OceanState::exchangeHalo(const I4 TimeLevel) { copyToHost(TimeLevel); - - I4 TimeIndex = getTimeIndex(TimeLevel); + I4 TimeIndex = getTimeIndex(TimeLevel); MeshHalo->exchangeFullArrayHalo(LayerThicknessH[TimeIndex], OnCell); MeshHalo->exchangeFullArrayHalo(NormalVelocityH[TimeIndex], OnEdge); @@ -526,7 +525,8 @@ I4 OceanState::getTimeIndex(const I4 TimeLevel) const { // Check if time level is valid if (TimeLevel > 1 || (TimeLevel + NTimeLevels) <= 1) { - LOG_ERROR("OceanState: Time level {} is out of range {}", TimeLevel, NTimeLevels); + LOG_ERROR("OceanState: Time level {} is out of range {}", TimeLevel, + NTimeLevels); return -1; } diff --git a/components/omega/src/ocn/OceanState.h b/components/omega/src/ocn/OceanState.h index 06c967ef6556..8e340f849d8b 100644 --- a/components/omega/src/ocn/OceanState.h +++ b/components/omega/src/ocn/OceanState.h @@ -122,7 +122,8 @@ class OceanState { I4 getLayerThickness(Array2DReal &LayerThick, const I4 TimeLevel) const; /// Get layer thickness host array at given time level - I4 getLayerThicknessH(HostArray2DReal &LayerThickH, const I4 TimeLevel) const; + I4 getLayerThicknessH(HostArray2DReal &LayerThickH, + const I4 TimeLevel) const; /// Get normal velocity device array at given time level I4 getNormalVelocity(Array2DReal &NormVel, const I4 TimeLevel) const; diff --git a/components/omega/src/ocn/Tracers.cpp b/components/omega/src/ocn/Tracers.cpp index c3c66227110e..f59596ce7627 100644 --- a/components/omega/src/ocn/Tracers.cpp +++ b/components/omega/src/ocn/Tracers.cpp @@ -499,7 +499,7 @@ I4 Tracers::updateTimeLevels() { } //--------------------------------------------------------------------------- -// get index for time level +// get index for time level // TimeLevel == [1:new, 0:current, -1:previous, -2:two times ago, ...] //--------------------------------------------------------------------------- I4 Tracers::getTimeIndex(const I4 TimeLevel) { diff --git a/components/omega/test/ocn/StateTest.cpp b/components/omega/test/ocn/StateTest.cpp index a7531319701d..0df02095ea07 100644 --- a/components/omega/test/ocn/StateTest.cpp +++ b/components/omega/test/ocn/StateTest.cpp @@ -80,7 +80,8 @@ int initStateTest() { } // Check for differences between layer thickness and normal velocity host arrays -int checkHost(OMEGA::OceanState* DefState, OMEGA::OceanState* TestState, int DefLevel, int TestLevel) { +int checkHost(OMEGA::OceanState *DefState, OMEGA::OceanState *TestState, + int DefLevel, int TestLevel) { int count = 0; OMEGA::HostArray2DReal LayerThicknessH_def; @@ -112,8 +113,10 @@ int checkHost(OMEGA::OceanState* DefState, OMEGA::OceanState* TestState, int Def return count; } -// Check for differences between layer thickness and normal velocity device arrays -int checkDevice(OMEGA::OceanState* DefState, OMEGA::OceanState* TestState, int DefLevel, int TestLevel) { +// Check for differences between layer thickness and normal velocity device +// arrays +int checkDevice(OMEGA::OceanState *DefState, OMEGA::OceanState *TestState, + int DefLevel, int TestLevel) { int count1; OMEGA::Array2DReal LayerThickness_def; @@ -205,10 +208,12 @@ int main(int argc, char *argv[]) { // Test retrieval of the default state OMEGA::OceanState *DefState = OMEGA::OceanState::get("Default"); if (DefState) { // true if non-null ptr - LOG_INFO("State: Default state retrieval (NTimeLevels={}) PASS", NTimeLevels); + LOG_INFO("State: Default state retrieval (NTimeLevels={}) PASS", + NTimeLevels); } else { RetVal += 1; - LOG_INFO("State: Default state retrieval (NTimeLevels={}) FAIL", NTimeLevels); + LOG_INFO("State: Default state retrieval (NTimeLevels={}) FAIL", + NTimeLevels); } // Create "test" state @@ -218,10 +223,12 @@ int main(int argc, char *argv[]) { OMEGA::OceanState *TestState = OMEGA::OceanState::get("Test"); if (TestState) { // true if non-null ptr - LOG_INFO("State: Test state retrieval (NTimeLevels={}) PASS", NTimeLevels); + LOG_INFO("State: Test state retrieval (NTimeLevels={}) PASS", + NTimeLevels); } else { RetVal += 1; - LOG_INFO("State: Test state retrieval (NTimeLevels={}) FAIL", NTimeLevels); + LOG_INFO("State: Test state retrieval (NTimeLevels={}) FAIL", + NTimeLevels); } // Initially fill test state with the same values as the default state @@ -273,10 +280,14 @@ int main(int argc, char *argv[]) { int count2 = checkDevice(DefState, TestState, CurLevel, CurLevel); if (count1 + count2 == 0) { - LOG_INFO("State: Default test state comparison (NTimeLevels={}) PASS", NTimeLevels); + LOG_INFO( + "State: Default test state comparison (NTimeLevels={}) PASS", + NTimeLevels); } else { RetVal += 1; - LOG_INFO("State: Default test state comparison (NTimeLevels={}) FAIL", NTimeLevels); + LOG_INFO( + "State: Default test state comparison (NTimeLevels={}) FAIL", + NTimeLevels); } // Perform time level update. @@ -288,14 +299,18 @@ int main(int argc, char *argv[]) { count2 = checkDevice(DefState, TestState, CurLevel, CurLevel); if (count1 + count2 != 0) { - LOG_INFO("State: time levels different after single update (NTimeLevels={}) PASS", NTimeLevels); + LOG_INFO("State: time levels different after single update " + "(NTimeLevels={}) PASS", + NTimeLevels); } else { RetVal += 1; - LOG_INFO("State: time levels different after single update (NTimeLevels={}) FAIL", NTimeLevels); + LOG_INFO("State: time levels different after single update " + "(NTimeLevels={}) FAIL", + NTimeLevels); } // Perform time level updates to cycle back to inital index - for (int i = 0; i < NTimeLevels-1; i++) { + for (int i = 0; i < NTimeLevels - 1; i++) { DefState->updateTimeLevels(); } @@ -305,13 +320,14 @@ int main(int argc, char *argv[]) { count2 = checkDevice(DefState, TestState, CurLevel, CurLevel); if (count1 + count2 == 0) { - LOG_INFO("State: time level update (NTimeLevels={}) PASS", NTimeLevels); + LOG_INFO("State: time level update (NTimeLevels={}) PASS", + NTimeLevels); } else { RetVal += 1; - LOG_INFO("State: time level update (NTimeLevels={}) FAIL", NTimeLevels); + LOG_INFO("State: time level update (NTimeLevels={}) FAIL", + NTimeLevels); } - OMEGA::OceanState::clear(); } diff --git a/components/omega/test/timeStepping/TimeStepperTest.cpp b/components/omega/test/timeStepping/TimeStepperTest.cpp index 0bc2ee7601ed..62fb596f1352 100644 --- a/components/omega/test/timeStepping/TimeStepperTest.cpp +++ b/components/omega/test/timeStepping/TimeStepperTest.cpp @@ -55,8 +55,8 @@ struct DecayVelocityTendency { const AuxiliaryState *AuxState, int ThickTimeLevel, int VelTimeLevel, TimeInstant Time) const { - auto *Mesh = HorzMesh::getDefault(); - auto NVertLevels = NormalVelTend.extent_int(1); + auto *Mesh = HorzMesh::getDefault(); + auto NVertLevels = NormalVelTend.extent_int(1); Array2DReal NormalVelEdge; State->getNormalVelocity(NormalVelEdge, VelTimeLevel);