From 7db30247319882c6002cd1e84ec8c2d41b34b35b Mon Sep 17 00:00:00 2001 From: loganchen39 Date: Mon, 21 Sep 2020 13:37:56 -0500 Subject: [PATCH 1/4] ctest passed for Geometry class --- src/oisst/Geometry/Geometry.cc | 49 +++++++++++++++++++++++----------- src/oisst/Geometry/Geometry.h | 23 +++++++++++----- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/oisst/Geometry/Geometry.cc b/src/oisst/Geometry/Geometry.cc index 2b84639..5390840 100644 --- a/src/oisst/Geometry/Geometry.cc +++ b/src/oisst/Geometry/Geometry.cc @@ -9,42 +9,59 @@ #include "eckit/config/Configuration.h" +#include "atlas/grid.h" + #include "oops/util/abor1_cpp.h" namespace oisst { // ---------------------------------------------------------------------------- - Geometry::Geometry(const eckit::Configuration & conf, - const eckit::mpi::Comm & comm) - : comm_(comm) { - util::abor1_cpp("Geometry::Geometry() needs to be implemented.", - __FILE__, __LINE__); + Geometry::Geometry(const eckit::Configuration & conf, const eckit::mpi::Comm & comm) : comm_(comm) { + //util::abor1_cpp("Geometry::Geometry() needs to be implemented.", __FILE__, __LINE__); + + atlas::RegularLonLatGrid atlasRllGrid("Slat360x180"); + atlasFunctionSpace_.reset(new atlas::functionspace::StructuredColumns(atlasRllGrid, + atlas::option::halo(0))); + + atlasFieldSet_.reset(new atlas::FieldSet()); } // ---------------------------------------------------------------------------- - Geometry::Geometry(const Geometry & other) - : comm_(other.comm_) { - util::abor1_cpp("Geometry::Geometry() needs to be implemented.", - __FILE__, __LINE__); + Geometry::Geometry(const Geometry & other) : comm_(other.comm_) { + //util::abor1_cpp("Geometry::Geometry() needs to be implemented.", __FILE__, __LINE__); + + atlasFunctionSpace_.reset(new atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(), + atlas::option::halo(0))); + + atlasFieldSet_.reset(new atlas::FieldSet()); + for (int ifield = 0; ifield < other.atlasFieldSet_->size(); ifield++) { + atlas::Field atlasField = other.atlasFieldSet_->field(ifield); + atlasFieldSet_->add(atlasField); + } } // ---------------------------------------------------------------------------- Geometry::~Geometry() { - util::abor1_cpp("Geometry::~Geometry() needs to be implemented.", - __FILE__, __LINE__); + //util::abor1_cpp("Geometry::~Geometry() needs to be implemented.", __FILE__, __LINE__); + + } // ---------------------------------------------------------------------------- void Geometry::print(std::ostream & os) const { - util::abor1_cpp("Geometry::print() needs to be implemented.", - __FILE__, __LINE__); - os << "Geometry: " - << "(TODO, print diagnostic info about the geometry here)" - << std::endl; + //util::abor1_cpp("Geometry::print() needs to be implemented.", __FILE__, __LINE__); + os << "Geometry: " << "(TODO, print diagnostic info about the geometry here)" << std::endl; + + int nx, ny; + //double dx, dy; + ny = int(atlasFunctionSpace()->grid().ny()); + nx = int(((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx()); + + os << "Geometry: nx = " << nx << ", ny = " << ny << std::endl; } // ---------------------------------------------------------------------------- diff --git a/src/oisst/Geometry/Geometry.h b/src/oisst/Geometry/Geometry.h index 36cf198..0e12bf1 100644 --- a/src/oisst/Geometry/Geometry.h +++ b/src/oisst/Geometry/Geometry.h @@ -11,8 +11,12 @@ #include #include -#include "eckit/mpi/Comm.h" +#include + +#include "atlas/functionspace.h" +#include "atlas/field.h" +#include "eckit/mpi/Comm.h" #include "oops/util/ObjectCounter.h" #include "oops/util/Printable.h" @@ -27,11 +31,9 @@ namespace oisst { // ---------------------------------------------------------------------------- namespace oisst { - // Geometry class - class Geometry : public util::Printable, - private util::ObjectCounter { - public: + class Geometry : public util::Printable, private util::ObjectCounter { + public: static const std::string classname() {return "oisst::Geometry";} // constructors and destructor @@ -46,10 +48,17 @@ namespace oisst { // TODO(template_impl) GeometryIterator begin() const; // TODO(template_impl) GeometryIterator end() const; - private: - void print(std::ostream &) const; +// atlas::FunctionSpace* atlasFunctionSpace() const { return atlasFunctionSpace_.get(); } + atlas::functionspace::StructuredColumns* atlasFunctionSpace() const { return atlasFunctionSpace_.get(); } + atlas::FieldSet* atlasFieldSet() const { return atlasFieldSet_.get(); } + private: + void print(std::ostream &) const; const eckit::mpi::Comm & comm_; + + + std::unique_ptr atlasFunctionSpace_; + std::unique_ptr atlasFieldSet_; }; } // namespace oisst From 8444628700ad2df4b28422aac33c0736fa3bb394 Mon Sep 17 00:00:00 2001 From: loganchen39 Date: Tue, 22 Sep 2020 14:04:53 -0500 Subject: [PATCH 2/4] Modified test CMakeLists.txt --- test/CMakeLists.txt | 10 +++--- test/CMakeLists.txt_org | 80 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 test/CMakeLists.txt_org diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 70b04a7..fe26812 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,11 +25,11 @@ endforeach() # TODO: uncomment all of these tests as the appropriate interfaces are implemented #================================================================================ -# ecbuild_add_test( -# TARGET test_oisst_geometry -# SOURCES executables/TestGeometry.cc -# ARGS testinput/geometry.yml -# LIBS oisst ) + ecbuild_add_test( + TARGET test_oisst_geometry + SOURCES executables/TestGeometry.cc + ARGS testinput/geometry.yml + LIBS oisst ) # ecbuild_add_test( # TARGET test_oisst_state diff --git a/test/CMakeLists.txt_org b/test/CMakeLists.txt_org new file mode 100644 index 0000000..70b04a7 --- /dev/null +++ b/test/CMakeLists.txt_org @@ -0,0 +1,80 @@ +list( APPEND oisst_test_input + testinput/geometry.yml + testinput/errorcovariance.yml + testinput/getvalues.yml + testinput/lineargetvalues.yml + testinput/linearmodel.yml + testinput/increment.yml + testinput/model.yml + testinput/modelaux.yml + testinput/state.yml + ) + + +# link the input files for the tests +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testinput) +foreach(FILENAME ${oisst_test_input}) + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME} + ${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} ) +endforeach() + + +#================================================================================ +# Tests of class interfaces +# TODO: uncomment all of these tests as the appropriate interfaces are implemented +#================================================================================ + +# ecbuild_add_test( +# TARGET test_oisst_geometry +# SOURCES executables/TestGeometry.cc +# ARGS testinput/geometry.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_state +# SOURCES executables/TestState.cc +# ARGS testinput/state.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_increment +# SOURCES executables/TestIncrement.cc +# ARGS testinput/increment.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_modelauxcontrol +# SOURCES executables/TestModelAuxControl.cc +# ARGS testinput/modelaux.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_getvalues +# SOURCES executables/TestGetValues.cc +# ARGS testinput/getvalues.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_lineargetvalues +# SOURCES executables/TestLinearGetValues.cc +# ARGS testinput/lineargetvalues.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_errorcovariance +# SOURCES executables/TestErrorCovariance.cc +# ARGS testinput/errorcovariance.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_modelauxcovariance +# SOURCES executables/TestModelAuxCovariance.cc +# ARGS testinput/modelaux.yml +# LIBS oisst ) + +# ecbuild_add_test( +# TARGET test_oisst_modelauxincrement +# SOURCES executables/TestModelAuxIncrement.cc +# ARGS testinput/modelaux.yml +# LIBS oisst ) From e4ca6e858228cca24f87764efcde67ba736ec9a7 Mon Sep 17 00:00:00 2001 From: loganchen39 Date: Wed, 23 Sep 2020 14:27:00 -0500 Subject: [PATCH 3/4] Travis's suggested changes completed by Ligang --- src/oisst/Geometry/Geometry.cc | 39 +++++++---------- src/oisst/Geometry/Geometry.h | 13 +++--- test/CMakeLists.txt_org | 80 ---------------------------------- test/testinput/geometry.yml | 2 +- 4 files changed, 24 insertions(+), 110 deletions(-) delete mode 100644 test/CMakeLists.txt_org diff --git a/src/oisst/Geometry/Geometry.cc b/src/oisst/Geometry/Geometry.cc index 5390840..b576b71 100644 --- a/src/oisst/Geometry/Geometry.cc +++ b/src/oisst/Geometry/Geometry.cc @@ -17,23 +17,22 @@ namespace oisst { // ---------------------------------------------------------------------------- - Geometry::Geometry(const eckit::Configuration & conf, const eckit::mpi::Comm & comm) : comm_(comm) { - //util::abor1_cpp("Geometry::Geometry() needs to be implemented.", __FILE__, __LINE__); - - atlas::RegularLonLatGrid atlasRllGrid("Slat360x180"); - atlasFunctionSpace_.reset(new atlas::functionspace::StructuredColumns(atlasRllGrid, - atlas::option::halo(0))); - + Geometry::Geometry(const eckit::Configuration & conf, + const eckit::mpi::Comm & comm) : comm_(comm) { + atlas::RegularLonLatGrid atlasRllGrid(conf.getString("grid")); + atlasFunctionSpace_.reset( + new atlas::functionspace::StructuredColumns(atlasRllGrid, + atlas::option::halo(0))); + atlasFieldSet_.reset(new atlas::FieldSet()); } // ---------------------------------------------------------------------------- Geometry::Geometry(const Geometry & other) : comm_(other.comm_) { - //util::abor1_cpp("Geometry::Geometry() needs to be implemented.", __FILE__, __LINE__); - - atlasFunctionSpace_.reset(new atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(), - atlas::option::halo(0))); + atlasFunctionSpace_.reset( + new atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(), + atlas::option::halo(0))); atlasFieldSet_.reset(new atlas::FieldSet()); for (int ifield = 0; ifield < other.atlasFieldSet_->size(); ifield++) { @@ -44,24 +43,16 @@ namespace oisst { // ---------------------------------------------------------------------------- - Geometry::~Geometry() { - //util::abor1_cpp("Geometry::~Geometry() needs to be implemented.", __FILE__, __LINE__); - - - } + Geometry::~Geometry() {} // ---------------------------------------------------------------------------- void Geometry::print(std::ostream & os) const { - //util::abor1_cpp("Geometry::print() needs to be implemented.", __FILE__, __LINE__); - os << "Geometry: " << "(TODO, print diagnostic info about the geometry here)" << std::endl; - int nx, ny; - //double dx, dy; - ny = int(atlasFunctionSpace()->grid().ny()); - nx = int(((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx()); - - os << "Geometry: nx = " << nx << ", ny = " << ny << std::endl; + ny = static_cast(atlasFunctionSpace()->grid().ny()); + nx = static_cast(((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx()); + + os << "Geometry: nx = " << nx << ", ny = " << ny << std::endl; } // ---------------------------------------------------------------------------- diff --git a/src/oisst/Geometry/Geometry.h b/src/oisst/Geometry/Geometry.h index 0e12bf1..6b8b323 100644 --- a/src/oisst/Geometry/Geometry.h +++ b/src/oisst/Geometry/Geometry.h @@ -32,7 +32,8 @@ namespace oisst { namespace oisst { // Geometry class - class Geometry : public util::Printable, private util::ObjectCounter { + class Geometry : public util::Printable, + private util::ObjectCounter { public: static const std::string classname() {return "oisst::Geometry";} @@ -48,15 +49,17 @@ namespace oisst { // TODO(template_impl) GeometryIterator begin() const; // TODO(template_impl) GeometryIterator end() const; -// atlas::FunctionSpace* atlasFunctionSpace() const { return atlasFunctionSpace_.get(); } - atlas::functionspace::StructuredColumns* atlasFunctionSpace() const { return atlasFunctionSpace_.get(); } - atlas::FieldSet* atlasFieldSet() const { return atlasFieldSet_.get(); } + atlas::functionspace::StructuredColumns* atlasFunctionSpace() const { + return atlasFunctionSpace_.get(); + } + atlas::FieldSet* atlasFieldSet() const { + return atlasFieldSet_.get(); + } private: void print(std::ostream &) const; const eckit::mpi::Comm & comm_; - std::unique_ptr atlasFunctionSpace_; std::unique_ptr atlasFieldSet_; }; diff --git a/test/CMakeLists.txt_org b/test/CMakeLists.txt_org deleted file mode 100644 index 70b04a7..0000000 --- a/test/CMakeLists.txt_org +++ /dev/null @@ -1,80 +0,0 @@ -list( APPEND oisst_test_input - testinput/geometry.yml - testinput/errorcovariance.yml - testinput/getvalues.yml - testinput/lineargetvalues.yml - testinput/linearmodel.yml - testinput/increment.yml - testinput/model.yml - testinput/modelaux.yml - testinput/state.yml - ) - - -# link the input files for the tests -file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testinput) -foreach(FILENAME ${oisst_test_input}) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME} - ${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} ) -endforeach() - - -#================================================================================ -# Tests of class interfaces -# TODO: uncomment all of these tests as the appropriate interfaces are implemented -#================================================================================ - -# ecbuild_add_test( -# TARGET test_oisst_geometry -# SOURCES executables/TestGeometry.cc -# ARGS testinput/geometry.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_state -# SOURCES executables/TestState.cc -# ARGS testinput/state.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_increment -# SOURCES executables/TestIncrement.cc -# ARGS testinput/increment.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_modelauxcontrol -# SOURCES executables/TestModelAuxControl.cc -# ARGS testinput/modelaux.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_getvalues -# SOURCES executables/TestGetValues.cc -# ARGS testinput/getvalues.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_lineargetvalues -# SOURCES executables/TestLinearGetValues.cc -# ARGS testinput/lineargetvalues.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_errorcovariance -# SOURCES executables/TestErrorCovariance.cc -# ARGS testinput/errorcovariance.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_modelauxcovariance -# SOURCES executables/TestModelAuxCovariance.cc -# ARGS testinput/modelaux.yml -# LIBS oisst ) - -# ecbuild_add_test( -# TARGET test_oisst_modelauxincrement -# SOURCES executables/TestModelAuxIncrement.cc -# ARGS testinput/modelaux.yml -# LIBS oisst ) diff --git a/test/testinput/geometry.yml b/test/testinput/geometry.yml index e14c921..c9a9632 100644 --- a/test/testinput/geometry.yml +++ b/test/testinput/geometry.yml @@ -1,2 +1,2 @@ geometry: - # insert other model specific things here \ No newline at end of file + grid: Slat360x180 From 9b4ada2efa6c13bc6b7de0870ea665f82a8e03ac Mon Sep 17 00:00:00 2001 From: loganchen39 Date: Wed, 23 Sep 2020 15:58:27 -0500 Subject: [PATCH 4/4] Travis's suggested changes completed by Ligang --- src/oisst/Geometry/Geometry.cc | 7 ++++--- src/oisst/Geometry/Geometry.h | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/oisst/Geometry/Geometry.cc b/src/oisst/Geometry/Geometry.cc index b576b71..1cec87c 100644 --- a/src/oisst/Geometry/Geometry.cc +++ b/src/oisst/Geometry/Geometry.cc @@ -30,8 +30,8 @@ namespace oisst { // ---------------------------------------------------------------------------- Geometry::Geometry(const Geometry & other) : comm_(other.comm_) { - atlasFunctionSpace_.reset( - new atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(), + atlasFunctionSpace_.reset(new + atlas::functionspace::StructuredColumns(other.atlasFunctionSpace_->grid(), atlas::option::halo(0))); atlasFieldSet_.reset(new atlas::FieldSet()); @@ -50,7 +50,8 @@ namespace oisst { void Geometry::print(std::ostream & os) const { int nx, ny; ny = static_cast(atlasFunctionSpace()->grid().ny()); - nx = static_cast(((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx()); + nx = static_cast( + ((atlas::RegularLonLatGrid&)(atlasFunctionSpace()->grid())).nx() ); os << "Geometry: nx = " << nx << ", ny = " << ny << std::endl; } diff --git a/src/oisst/Geometry/Geometry.h b/src/oisst/Geometry/Geometry.h index 6b8b323..0a4c80d 100644 --- a/src/oisst/Geometry/Geometry.h +++ b/src/oisst/Geometry/Geometry.h @@ -34,7 +34,7 @@ namespace oisst { // Geometry class class Geometry : public util::Printable, private util::ObjectCounter { - public: + public: static const std::string classname() {return "oisst::Geometry";} // constructors and destructor @@ -56,11 +56,12 @@ namespace oisst { return atlasFieldSet_.get(); } - private: + private: void print(std::ostream &) const; const eckit::mpi::Comm & comm_; - std::unique_ptr atlasFunctionSpace_; + std::unique_ptr + atlasFunctionSpace_; std::unique_ptr atlasFieldSet_; }; } // namespace oisst