diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4fc9a64a5..ed7e56e94 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -6,3 +6,4 @@ find_package(atlas REQUIRED) find_package(soca REQUIRED) add_subdirectory(soca) +add_subdirectory(ioda_example) diff --git a/utils/ioda_example/CMakeLists.txt b/utils/ioda_example/CMakeLists.txt new file mode 100644 index 000000000..5e957569f --- /dev/null +++ b/utils/ioda_example/CMakeLists.txt @@ -0,0 +1,6 @@ +ecbuild_add_executable( TARGET gdas_dumpioda.x + SOURCES gdas_dumpioda.cc ) + +target_compile_features( gdas_dumpioda.x PUBLIC cxx_std_17) +target_link_libraries( gdas_dumpioda.x PUBLIC oops ioda) + diff --git a/utils/ioda_example/gdas_dumpioda.cc b/utils/ioda_example/gdas_dumpioda.cc new file mode 100644 index 000000000..a505eeee9 --- /dev/null +++ b/utils/ioda_example/gdas_dumpioda.cc @@ -0,0 +1,12 @@ +#include "gdas_dumpioda.h" +#include "oops/runs/Run.h" + +// this is an example application that +// will use IODA to read a file and print something +// it is intended to be very bare bones + +int main(int argc, char ** argv) { + oops::Run run(argc, argv); + gdasapp::IodaExample iodaexample; + return run.execute(iodaexample); +} diff --git a/utils/ioda_example/gdas_dumpioda.h b/utils/ioda_example/gdas_dumpioda.h new file mode 100644 index 000000000..d5ff8b680 --- /dev/null +++ b/utils/ioda_example/gdas_dumpioda.h @@ -0,0 +1,48 @@ +#include +#include "eckit/config/LocalConfiguration.h" +#include "ioda/Group.h" +#include "ioda/ObsSpace.h" +#include "ioda/ObsVector.h" +#include "oops/base/PostProcessor.h" +#include "oops/mpi/mpi.h" +#include "oops/runs/Application.h" +#include "oops/util/DateTime.h" +#include "oops/util/Duration.h" +#include "oops/util/Logger.h" + +namespace gdasapp { + + class IodaExample : public oops::Application { + public: + explicit IodaExample(const eckit::mpi::Comm & comm = oops::mpi::world()) + : Application(comm) {} + static const std::string classname() {return "gdasapp::IodaExample";} + + int execute(const eckit::Configuration & fullConfig, bool /*validate*/) const { + + // get the obs space configuration + const eckit::LocalConfiguration obsConfig(fullConfig, "obs space"); + ioda::ObsTopLevelParameters obsparams; + obsparams.validateAndDeserialize(obsConfig); + oops::Log::info() << "obs space: " << std::endl << obsConfig << std::endl; + + // read the obs space + std::string winbegin; + std::string winend; + fullConfig.get("window begin", winbegin); + fullConfig.get("window end", winend); + ioda::ObsSpace ospace(obsparams, oops::mpi::world(), util::DateTime(winbegin), util::DateTime(winend), oops::mpi::myself()); + const size_t nlocs = ospace.nlocs(); + oops::Log::info() << "nlocs =" << nlocs << std::endl; + + return 0; + } + // ----------------------------------------------------------------------------- + private: + std::string appname() const { + return "gdasapp::IodaExample"; + } + // ----------------------------------------------------------------------------- + }; + +} // namespace gdasapp