Skip to content

Commit

Permalink
Merge pull request E3SM-Project#168 from climatemodeling/sarats/pacer…
Browse files Browse the repository at this point in the history
…-integration

Pacer integration into Omega standalone driver
  • Loading branch information
philipwjones authored Dec 4, 2024
2 parents da87361 + 8032375 commit 8f008c7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
25 changes: 25 additions & 0 deletions components/omega/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ if (NOT TARGET pioc)
)
endif()

# Add E3SM GPTL library
if (NOT TARGET gptl)
add_subdirectory(
${E3SM_ROOT}/share/timing
${CMAKE_CURRENT_BINARY_DIR}/gptl
)
endif()

# Add the Pacer library
if (NOT TARGET pacer)
add_library(pacer ${E3SM_ROOT}/share/pacer/Pacer.cpp)

target_include_directories(
pacer
PRIVATE
${E3SM_ROOT}/share/timing
)

target_link_libraries(
pacer
PUBLIC
gptl
)
endif()

# Add the parmetis and related libraries

if(Parmetis_FOUND)
Expand Down
4 changes: 4 additions & 0 deletions components/omega/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ target_include_directories(
${OMEGA_SOURCE_DIR}/src/infra
${OMEGA_SOURCE_DIR}/src/ocn
${OMEGA_SOURCE_DIR}/src/timeStepping
${E3SM_ROOT}/share/timing
${E3SM_ROOT}/share/pacer
${PIOC_SOURCE_DIR}
${PIOC_BINARY_DIR}
${Parmetis_INCLUDE_DIRS}
Expand Down Expand Up @@ -44,6 +46,8 @@ target_link_libraries(
yaml-cpp
parmetis
metis
gptl
pacer
)

if(GKlib_FOUND)
Expand Down
14 changes: 13 additions & 1 deletion components/omega/src/drivers/standalone/OceanDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include "TimeMgr.h"
#include "TimeStepper.h"

#include "mpi.h"
#include "Pacer.h"
#include <mpi.h>

#include <iostream>

Expand All @@ -22,28 +23,36 @@ int main(int argc, char **argv) {

MPI_Init(&argc, &argv); // initialize MPI
Kokkos::initialize(); // initialize Kokkos
Pacer::initialize(MPI_COMM_WORLD);
Pacer::setPrefix("Omega:");

Pacer::start("Init");
ErrCurr = OMEGA::ocnInit(MPI_COMM_WORLD);
if (ErrCurr != 0)
LOG_ERROR("Error initializing OMEGA");
Pacer::stop("Init");

// Get time information
OMEGA::TimeStepper *DefStepper = OMEGA::TimeStepper::getDefault();
OMEGA::Alarm *EndAlarm = DefStepper->getEndAlarm();
OMEGA::Clock *ModelClock = DefStepper->getClock();
OMEGA::TimeInstant CurrTime = ModelClock->getCurrentTime();

Pacer::start("RunLoop");
while (ErrCurr == 0 && !(EndAlarm->isRinging())) {

ErrCurr = OMEGA::ocnRun(CurrTime);

if (ErrCurr != 0)
LOG_ERROR("Error advancing Omega run interval");
}
Pacer::stop("RunLoop");

Pacer::start("Finalize");
ErrFinalize = OMEGA::ocnFinalize(CurrTime);
if (ErrFinalize != 0)
LOG_ERROR("Error finalizing OMEGA");
Pacer::stop("Finalize");

ErrAll = abs(ErrCurr) + abs(ErrFinalize);
if (ErrAll == 0) {
Expand All @@ -52,6 +61,9 @@ int main(int argc, char **argv) {
LOG_ERROR("OMEGA terminating due to error");
}

Pacer::print("omega");
Pacer::finalize();

Kokkos::finalize();
MPI_Finalize();

Expand Down
14 changes: 13 additions & 1 deletion components/omega/test/drivers/StandaloneDriverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#include "TimeMgr.h"
#include "TimeStepper.h"

#include "mpi.h"
#include "Pacer.h"
#include <mpi.h>

//------------------------------------------------------------------------------
// The test driver for the standalone driver
Expand All @@ -29,20 +30,25 @@ int main(int argc, char *argv[]) {

MPI_Init(&argc, &argv); // initialize MPI
Kokkos::initialize(); // initialize Kokkos
Pacer::initialize(MPI_COMM_WORLD);
Pacer::setPrefix("Omega:");

Pacer::start("Init");
ErrCurr = OMEGA::ocnInit(MPI_COMM_WORLD);
if (ErrCurr == 0) {
LOG_INFO("DriverTest: Omega initialize PASS");
} else {
LOG_INFO("DriverTest: Omega initialize FAIL");
}
Pacer::stop("Init");

// Time management objects
OMEGA::TimeStepper *DefStepper = OMEGA::TimeStepper::getDefault();
OMEGA::Clock *ModelClock = DefStepper->getClock();
OMEGA::Alarm *EndAlarm = DefStepper->getEndAlarm();
OMEGA::TimeInstant CurrTime = ModelClock->getCurrentTime();

Pacer::start("RunLoop");
if (ErrCurr == 0) {
ErrCurr = OMEGA::ocnRun(CurrTime);
}
Expand All @@ -51,19 +57,25 @@ int main(int argc, char *argv[]) {
} else {
LOG_INFO("DriverTest: Omega model run FAIL");
}
Pacer::stop("RunLoop");

Pacer::start("Finalize");
ErrFinalize = OMEGA::ocnFinalize(CurrTime);
if (ErrFinalize == 0) {
LOG_INFO("DriverTest: Omega finalize PASS");
} else {
LOG_INFO("DriverTest: Omega finalize FAIL");
}
Pacer::stop("Finalize");

ErrAll = abs(ErrCurr) + abs(ErrFinalize);
if (ErrAll == 0) {
LOG_INFO("DriverTest: Successful completion");
}

Pacer::print("omega_driver_test");
Pacer::finalize();

Kokkos::finalize();
MPI_Finalize();

Expand Down

0 comments on commit 8f008c7

Please sign in to comment.