diff --git a/bundle/CMakeLists.txt b/bundle/CMakeLists.txt index 9559db59..ff11b5a2 100644 --- a/bundle/CMakeLists.txt +++ b/bundle/CMakeLists.txt @@ -107,6 +107,9 @@ endif() ecbuild_bundle( PROJECT iodaconv SOURCE "../sorc/iodaconv" ) endif() +# rdas mega executable + ecbuild_bundle( PROJECT rdas SOURCE "../mains" ) + # ioda, ufo, fv3-jedi, and saber test data #--------------------------------- if(CLONE_JCSDADATA) @@ -140,6 +143,7 @@ endif() ecbuild_bundle( PROJECT rrfs-test SOURCE "../rrfs-test" ) endif(CLONE_RRFSDATA) + endif(BUILD_RDASBUNDLE) # Finalize bundle diff --git a/mains/CMakeLists.txt b/mains/CMakeLists.txt new file mode 100644 index 00000000..8f01690f --- /dev/null +++ b/mains/CMakeLists.txt @@ -0,0 +1,35 @@ +# Build the big rdas executable used for all generic JEDI applications +# -------------------------------------------------------------------- + +#--------------------------------- + +# Standard compiler flags +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_FORTRAN_STANDARD 08) +set(CMAKE_FORTRAN_STANDARD_REQUIRED ON) +set(CMAKE_FORTRAN_EXTENSIONS OFF) + +if ( FV3_DYCORE ) + + find_package( fv3jedi REQUIRED ) + ecbuild_add_executable( TARGET rdas_fv3jedi.x + SOURCES rdas_fv3jedi.cc + LIBS fv3jedi + ) + +endif() + +if ( MPAS_DYCORE ) + + find_package( mpasjedi REQUIRED ) + ecbuild_add_executable( TARGET rdas_mpasjedi.x + SOURCES rdas_mpasjedi.cc + LIBS mpasjedi + ) + +endif() diff --git a/mains/rdas_fv3jedi.cc b/mains/rdas_fv3jedi.cc new file mode 100644 index 00000000..2150dd9d --- /dev/null +++ b/mains/rdas_fv3jedi.cc @@ -0,0 +1,108 @@ +// ------------------------------------------------------------------------------------------------- + +#include +#include + +#include "fv3jedi/ObsLocalization/instantiateObsLocFactory.h" +#include "fv3jedi/Utilities/Traits.h" + +#include "oops/generic/instantiateModelFactory.h" +#include "saber/oops/instantiateCovarFactory.h" +#include "saber/oops/ErrorCovarianceToolbox.h" +#include "ufo/instantiateObsErrorFactory.h" +#include "ufo/instantiateObsFilterFactory.h" +#include "ufo/ObsTraits.h" + +#include "oops/runs/ConvertState.h" +#include "oops/runs/HofX4D.h" +#include "oops/runs/LocalEnsembleDA.h" +#include "oops/runs/Run.h" +#include "oops/runs/Variational.h" + +// ------------------------------------------------------------------------------------------------- + +template +int runApp(int argc, char** argv, const std::string appName) { + + // Create the Run object + oops::Run run(argc, argv); + + // Instantiate oops factories + oops::instantiateModelFactory(); + + // Instantiate saber factories + saber::instantiateCovarFactory(); + + // Intantiate ufo factories + ufo::instantiateObsErrorFactory(); + ufo::instantiateObsFilterFactory(); + + // Localization for ensemble DA + if (appName == "localensembleda") { + fv3jedi::instantiateObsLocFactory(); + } + + // Application pointer + std::unique_ptr app; + + // Define a map from app names to lambda functions that create unique_ptr to Applications + std::map()>> apps; + + apps["convertstate"] = []() { + return std::make_unique>(); + }; + apps["bump"] = []() { + return std::make_unique>(); + }; + apps["hofx4d"] = []() { + return std::make_unique>(); + }; + apps["localensembleda"] = []() { + return std::make_unique>(); + }; + apps["variational"] = []() { + return std::make_unique>(); + }; + + // Create application object and point to it + auto it = apps.find(appName); + + // Run the application + return run.execute(*(it->second())); +} + +// ------------------------------------------------------------------------------------------------- + +int main(int argc, char ** argv) { + // Check that the number of arguments is correct + // ---------------------------------------------- + ASSERT_MSG(argc >= 2, "Usage: " + std::string(argv[0]) + " "); + + // Get the application to be run + std::string app = argv[1]; + for (char &c : app) {c = std::tolower(c);} + + // Check that the application is recognized + // ---------------------------------------- + const std::set validApps = { + "convertstate", + "bump", + "hofx4d", + "localensembleda", + "variational" + }; + ASSERT_MSG(validApps.find(app) != validApps.end(), "Application not recognized: " + app); + + // Remove program from argc and argv + // -------------------------------------------- + argv[1] = argv[0]; // Move executable name to second position + argv += 1; // Move pointer up two + argc -= 1; // Remove 1 from count + + // Call application specific main functions + // ---------------------------------------- + fv3jedi::instantiateObsLocFactory(); + return runApp(argc, argv, app); +} + +// ------------------------------------------------------------------------------------------------- diff --git a/mains/rdas_mpasjedi.cc b/mains/rdas_mpasjedi.cc new file mode 100644 index 00000000..1fdb22ba --- /dev/null +++ b/mains/rdas_mpasjedi.cc @@ -0,0 +1,116 @@ +// ------------------------------------------------------------------------------------------------- + +#include +#include + +#include "oops/generic/instantiateModelFactory.h" +#include "saber/oops/instantiateCovarFactory.h" +#include "saber/oops/ErrorCovarianceToolbox.h" +#include "saber/oops/instantiateLocalizationFactory.h" +#include "ufo/instantiateObsErrorFactory.h" +#include "ufo/instantiateObsFilterFactory.h" +#include "ufo/instantiateObsLocFactory.h" +#include "ufo/ObsTraits.h" + +#include "oops/runs/ConvertState.h" +#include "oops/runs/HofX4D.h" +#include "oops/runs/LocalEnsembleDA.h" +#include "oops/runs/Run.h" +#include "oops/runs/Variational.h" +#include "mpasjedi/Traits.h" + +// ------------------------------------------------------------------------------------------------- + +template +int runApp(int argc, char** argv, const std::string appName) { + + // Create the Run object + oops::Run run(argc, argv); + + // Instantiate oops factories + oops::instantiateModelFactory(); + + // Instantiate saber factories + saber::instantiateCovarFactory(); + + // Intantiate ufo factories + ufo::instantiateObsErrorFactory(); + ufo::instantiateObsFilterFactory(); + + // Localization for ensemble DA + if (appName == "localensembleda") { + ufo::instantiateObsLocFactory(); + } + + // Localization for variational DA + if (appName == "variational") { + saber::instantiateLocalizationFactory(); + } + + // Intantiate ufo factories + ufo::instantiateObsErrorFactory(); + ufo::instantiateObsFilterFactory(); + + // Application pointer + std::unique_ptr app; + + // Define a map from app names to lambda functions that create unique_ptr to Applications + std::map()>> apps; + + apps["convertstate"] = []() { + return std::make_unique>(); + }; + apps["bump"] = []() { + return std::make_unique>(); + }; + apps["hofx4d"] = []() { + return std::make_unique>(); + }; + apps["localensembleda"] = []() { + return std::make_unique>(); + }; + apps["variational"] = []() { + return std::make_unique>(); + }; + + // Create application object and point to it + auto it = apps.find(appName); + + // Run the application + return run.execute(*(it->second())); +} + +// ------------------------------------------------------------------------------------------------- + +int main(int argc, char ** argv) { + // Check that the number of arguments is correct + // ---------------------------------------------- + ASSERT_MSG(argc >= 2, "Usage: " + std::string(argv[0]) + " "); + + // Get the application to be run + std::string app = argv[1]; + for (char &c : app) {c = std::tolower(c);} + + // Check that the application is recognized + // ---------------------------------------- + const std::set validApps = { + "convertstate", + "bump", + "hofx4d", + "localensembleda", + "variational" + }; + ASSERT_MSG(validApps.find(app) != validApps.end(), "Application not recognized: " + app); + + // Remove program from argc and argv + // -------------------------------------------- + argv[1] = argv[0]; // Move executable name to second position + argv += 1; // Move pointer up two + argc -= 1; // Remove 1 from count + + // Call application specific main functions + // ---------------------------------------- + return runApp(argc, argv, app); +} + +// ------------------------------------------------------------------------------------------------- diff --git a/rrfs-test/CMakeLists.txt b/rrfs-test/CMakeLists.txt index 5294f134..e5659d06 100644 --- a/rrfs-test/CMakeLists.txt +++ b/rrfs-test/CMakeLists.txt @@ -73,6 +73,7 @@ if (CLONE_RRFSDATA) set(RESTORE_MPI_ARGS ${MPI_ARGS}) set(MPI_ARGS "${MPI_ARGS} --exclusive") endif() + set(MPI_ARGS "${MPI_ARGS} --ntasks-per-node=18") get_all_keys(rrfs_mpasjedi_tests caselist) foreach(case ${caselist})