-
Notifications
You must be signed in to change notification settings - Fork 50
Executable to rule them all #1075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
759fd7e
jedi builds within gdas
danholdaway d1fc395
collapse to single executable
danholdaway b5aded7
Make only one exectuable
danholdaway 45c8142
remove rogue print
danholdaway 2bf319f
fix snow and soca test failures
danholdaway 6a9ae4f
Merge branch 'develop' into feature/build_jedi_exe
danholdaway b6bd748
Add fv3jediErrorCovarianceToolbox
danholdaway 5d9991e
Merge branch 'develop' into feature/build_jedi_exe
CoryMartin-NOAA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Build the big gdas executable used for all generic JEDI applications | ||
| # -------------------------------------------------------------------- | ||
| ecbuild_add_executable( TARGET gdas.x | ||
| SOURCES gdas.cc | ||
| LIBS fv3jedi soca | ||
| ) | ||
|
|
||
| # Build the soca executables that are not OOPS-based | ||
| # -------------------------------------------------- | ||
| ecbuild_add_executable( TARGET gdas_soca_gridgen.x | ||
| SOURCES ${CMAKE_SOURCE_DIR}/soca/src/mains/GridGen.cc | ||
| LIBS soca | ||
| ) | ||
|
|
||
| ecbuild_add_executable( TARGET gdas_soca_error_covariance_toolbox.x | ||
| SOURCES ${CMAKE_SOURCE_DIR}/soca/src/mains/ErrorCovarianceToolbox.cc | ||
| LIBS soca saber | ||
| ) | ||
|
|
||
| ecbuild_add_executable( TARGET gdas_soca_setcorscales.x | ||
| SOURCES ${CMAKE_SOURCE_DIR}/soca/src/mains/SetCorScales.cc | ||
| LIBS soca | ||
| ) | ||
|
|
||
| ecbuild_add_executable( TARGET gdas_fv3jedi_error_covariance_toolbox.x | ||
| SOURCES ${CMAKE_SOURCE_DIR}/fv3-jedi/src/mains/fv3jediErrorCovarianceToolbox.cc | ||
| LIBS fv3jedi saber | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| // ------------------------------------------------------------------------------------------------- | ||
|
|
||
| #include <functional> | ||
| #include <map> | ||
|
|
||
| #include "fv3jedi/ObsLocalization/instantiateObsLocFactory.h" | ||
| #include "fv3jedi/Utilities/Traits.h" | ||
|
|
||
| #include "soca/Traits.h" | ||
|
|
||
| #include "oops/generic/instantiateModelFactory.h" | ||
| #include "saber/oops/instantiateCovarFactory.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<typename Traits> | ||
| int runApp(int argc, char** argv, const std::string traits, const std::string appName) { | ||
| // Create the Run object | ||
| oops::Run run(argc, argv); | ||
|
|
||
| // Instantiate oops factories | ||
| oops::instantiateModelFactory<Traits>(); | ||
|
|
||
| // Instantiate saber factories | ||
| saber::instantiateCovarFactory<Traits>(); | ||
|
|
||
| // Intantiate ufo factories | ||
| ufo::instantiateObsErrorFactory(); | ||
| ufo::instantiateObsFilterFactory(); | ||
|
|
||
| // Localization for ensemble DA | ||
| if (appName == "localensembleda") { | ||
| if (traits == "fv3jedi") { | ||
| fv3jedi::instantiateObsLocFactory(); | ||
| } else if (traits == "soca") { | ||
| ufo::instantiateObsLocFactory<soca::Traits>(); | ||
| } | ||
| } | ||
|
|
||
| // Application pointer | ||
| std::unique_ptr<oops::Application> app; | ||
|
|
||
| // Define a map from app names to lambda functions that create unique_ptr to Applications | ||
| std::map<std::string, std::function<std::unique_ptr<oops::Application>()>> apps; | ||
|
|
||
| apps["convertstate"] = []() { | ||
| return std::make_unique<oops::ConvertState<Traits>>(); | ||
| }; | ||
| apps["hofx4d"] = []() { | ||
| return std::make_unique<oops::HofX4D<Traits, ufo::ObsTraits>>(); | ||
| }; | ||
| apps["localensembleda"] = []() { | ||
| return std::make_unique<oops::LocalEnsembleDA<fv3jedi::Traits, ufo::ObsTraits>>(); | ||
| }; | ||
| apps["variational"] = []() { | ||
| return std::make_unique<oops::Variational<Traits, ufo::ObsTraits>>(); | ||
| }; | ||
|
|
||
| // 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 >= 3, "Usage: " + std::string(argv[0]) + " <traits> <application> <options>"); | ||
|
|
||
| // Get traits from second argument passed to executable | ||
| // ---------------------------------------------------- | ||
| std::string traits = argv[1]; | ||
| for (char &c : traits) {c = std::tolower(c);} | ||
|
|
||
| // Get the application to be run | ||
| std::string app = argv[2]; | ||
| for (char &c : app) {c = std::tolower(c);} | ||
|
|
||
| // Check that the traits are recognized | ||
| // ------------------------------------ | ||
| const std::set<std::string> validTraits = {"fv3jedi", "soca"}; | ||
| ASSERT_MSG(validTraits.find(traits) != validTraits.end(), "Traits not recognized: " + traits); | ||
|
|
||
| // Check that the application is recognized | ||
| // ---------------------------------------- | ||
| const std::set<std::string> validApps = { | ||
| "convertstate", | ||
| "hofx4d", | ||
| "localensembleda", | ||
| "variational" | ||
| }; | ||
| ASSERT_MSG(validApps.find(app) != validApps.end(), "Application not recognized: " + app); | ||
|
|
||
| // Remove traits and program from argc and argv | ||
| // -------------------------------------------- | ||
| argv[2] = argv[0]; // Move executable name to third position | ||
| argv += 2; // Move pointer up two | ||
| argc -= 2; // Remove 2 from count | ||
|
|
||
| // Call application specific main functions | ||
| // ---------------------------------------- | ||
| if (traits == "fv3jedi") { | ||
| fv3jedi::instantiateObsLocFactory(); | ||
| return runApp<fv3jedi::Traits>(argc, argv, traits, app); | ||
| } else if (traits == "soca") { | ||
| return runApp<soca::Traits>(argc, argv, traits, app); | ||
| } | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.