Skip to content

Commit

Permalink
print out nlocs
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMartin-NOAA committed Aug 7, 2023
1 parent 00cfdc5 commit 072b63d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ find_package(atlas REQUIRED)
find_package(soca REQUIRED)

add_subdirectory(soca)
add_subdirectory(ioda_example)
6 changes: 6 additions & 0 deletions utils/ioda_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

12 changes: 12 additions & 0 deletions utils/ioda_example/gdas_dumpioda.cc
Original file line number Diff line number Diff line change
@@ -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);
}
48 changes: 48 additions & 0 deletions utils/ioda_example/gdas_dumpioda.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <iostream>
#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

0 comments on commit 072b63d

Please sign in to comment.