From 5ac630fd61a10110f6a18426f48a372ab7caca5e Mon Sep 17 00:00:00 2001 From: Guillaume Vernieres Date: Mon, 17 Jul 2023 18:37:28 +0000 Subject: [PATCH] ... --- utils/socahybridweights.cc | 8 --- utils/socahybridweights.h | 86 ---------------------------- utils/socaincr2mom6.cc | 8 --- utils/socaincr2mom6.h | 112 ------------------------------------- 4 files changed, 214 deletions(-) delete mode 100644 utils/socahybridweights.cc delete mode 100644 utils/socahybridweights.h delete mode 100644 utils/socaincr2mom6.cc delete mode 100644 utils/socaincr2mom6.h diff --git a/utils/socahybridweights.cc b/utils/socahybridweights.cc deleted file mode 100644 index 5869a090d..000000000 --- a/utils/socahybridweights.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "socahybridweights.h" -#include "oops/runs/Run.h" - -int main(int argc, char ** argv) { - oops::Run run(argc, argv); - gdasapp::SocaHybridWeights socahybridweights; - return run.execute(socahybridweights); -} diff --git a/utils/socahybridweights.h b/utils/socahybridweights.h deleted file mode 100644 index d6a52c357..000000000 --- a/utils/socahybridweights.h +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include - -#include "eckit/config/LocalConfiguration.h" - -#include "atlas/field.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" - -#include "soca/State/State.h" -#include "soca/Geometry/Geometry.h" -#include "soca/Increment/Increment.h" - -namespace gdasapp { - - class SocaHybridWeights : public oops::Application { - public: - explicit SocaHybridWeights(const eckit::mpi::Comm & comm = oops::mpi::world()) - : Application(comm) {} - static const std::string classname() {return "gdasapp::SocaHybridWeights";} - - int execute(const eckit::Configuration & fullConfig, bool /*validate*/) const { - - /// Setup the soca geometry - const eckit::LocalConfiguration geomConfig(fullConfig, "geometry"); - oops::Log::info() << "geometry: " << std::endl << geomConfig << std::endl; - const soca::Geometry geom(geomConfig, this->getComm()); - - /// Get the date - std::string strdt; - fullConfig.get("date", strdt); - util::DateTime dt = util::DateTime(strdt); - - /// Get the list of variables - oops::Variables socaOcnVars(fullConfig, "variables.ocean"); - oops::Variables socaIceVars(fullConfig, "variables.ice"); - oops::Variables socaVars(socaIceVars); - socaVars += socaOcnVars; - - /// Read the background - // TODO: Use the ice extent to set the weights ... no clue if this is - // possible at this level - soca::State socaBkg(geom, socaVars, dt); - const eckit::LocalConfiguration socaBkgConfig(fullConfig, "background"); - socaBkg.read(socaBkgConfig); - oops::Log::info() << "socaBkg: " << std::endl << socaBkg << std::endl; - - /// Read weights - const eckit::LocalConfiguration socaHWConfig(fullConfig, "weights"); - double wIce = socaHWConfig.getDouble("ice"); - double wOcean = socaHWConfig.getDouble("ocean"); - oops::Log::info() << "wIce: " << wIce << std::endl; - oops::Log::info() << "wOcean: " << wOcean << std::endl; - - /// Create fields of weights for seaice - soca::Increment socaIceHW(geom, socaVars, dt); // ocean field is mandatory for writting - socaIceHW.ones(); - socaIceHW *= wIce; - oops::Log::info() << "socaIceHW: " << std::endl << socaIceHW << std::endl; - const eckit::LocalConfiguration socaHWOutConfig(fullConfig, "output"); - socaIceHW.write(socaHWOutConfig); - - /// Create fields of weights for the ocean - soca::Increment socaOcnHW(geom, socaOcnVars, dt); - socaOcnHW.ones(); - socaOcnHW *= wOcean; - oops::Log::info() << "socaOcnHW: " << std::endl << socaOcnHW << std::endl; - socaOcnHW.write(socaHWOutConfig); - - return 0; - } - // ----------------------------------------------------------------------------- - private: - std::string appname() const { - return "gdasapp::SocaHybridWeights"; - } - // ----------------------------------------------------------------------------- - }; - -} // namespace gdasapp diff --git a/utils/socaincr2mom6.cc b/utils/socaincr2mom6.cc deleted file mode 100644 index d8fa7c788..000000000 --- a/utils/socaincr2mom6.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "socaincr2mom6.h" -#include "oops/runs/Run.h" - -int main(int argc, char ** argv) { - oops::Run run(argc, argv); - gdasapp::SocaIncr2Mom6 socaincr2mom6; - return run.execute(socaincr2mom6); -} diff --git a/utils/socaincr2mom6.h b/utils/socaincr2mom6.h deleted file mode 100644 index c644b4c01..000000000 --- a/utils/socaincr2mom6.h +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include - -#include "eckit/config/LocalConfiguration.h" - -#include "atlas/field.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" - -#include "soca/Geometry/Geometry.h" -#include "soca/Increment/Increment.h" - -namespace gdasapp { - - class SocaIncr2Mom6 : public oops::Application { - public: - explicit SocaIncr2Mom6(const eckit::mpi::Comm & comm = oops::mpi::world()) - : Application(comm) {} - static const std::string classname() {return "gdasapp::SocaIncr2Mom6";} - - int execute(const eckit::Configuration & fullConfig, bool /*validate*/) const { - - /// Setup the soca geometry - const eckit::LocalConfiguration geomConfig(fullConfig, "geometry"); - oops::Log::info() << "geometry: " << std::endl << geomConfig << std::endl; - const soca::Geometry geom(geomConfig, this->getComm()); - - /// Setup the vertical geometry from the background (layer thicknesses) - // get date - std::string strdt; - fullConfig.get("date", strdt); - util::DateTime dt = util::DateTime(strdt); - - // get layer thickness variable name - oops::Variables layerVar(fullConfig, "layers variable"); - ASSERT(layerVar.size() == 1); - - // read layer thicknesses from the relevant background - soca::Increment layerThick(geom, layerVar, dt); - const eckit::LocalConfiguration vertGeomConfig(fullConfig, "vertical geometry"); - layerThick.read(vertGeomConfig); - oops::Log::info() << "layerThick: " << std::endl << layerThick << std::endl; - - // Setup the soca increment - // get the increment variables - oops::Variables socaIncrVar(fullConfig, "increment variables"); - ASSERT(socaIncrVar.size() >= 1); - - // read the soca increment - soca::Increment socaIncr(geom, socaIncrVar, dt); - const eckit::LocalConfiguration socaIncrConfig(fullConfig, "soca increment"); - socaIncr.read(socaIncrConfig); - oops::Log::info() << "socaIncr: " << std::endl << socaIncr << std::endl; - - /// Create the MOM6 IAU increment - // concatenate variables - oops::Variables mom6IauVar(socaIncrVar); - mom6IauVar += layerVar; - oops::Log::info() << "mom6IauVar: " << std::endl << mom6IauVar << std::endl; - - // append layer variable to soca increment - atlas::FieldSet socaIncrFs; - socaIncr.toFieldSet(socaIncrFs); - socaIncr.updateFields(mom6IauVar); - oops::Log::info() << "MOM6 incr: " << std::endl << socaIncr << std::endl; - - // pad layer increment with zeros - atlas::FieldSet socaLayerThickFs; - layerThick.toFieldSet(socaLayerThickFs); - layerThick.updateFields(mom6IauVar); - oops::Log::info() << "h: " << std::endl << layerThick << std::endl; - - // append layer thinckness to increment - socaIncr += layerThick; - oops::Log::info() << "MOM6 IAU increment: " << std::endl << socaIncr << std::endl; - - // Save MOM6 IAU Increment - const eckit::LocalConfiguration mom6IauConfig(fullConfig, "mom6 iau increment"); - socaIncr.write(mom6IauConfig); - - // TODO: the "checkpoint" script expects the ocean increment output to - // be in "inc.nc". Remove what's below, eventually - std::string datadir; - mom6IauConfig.get("datadir", datadir); - std::filesystem::path pathToResolve = datadir; - std::string exp; - mom6IauConfig.get("exp", exp); - std::string outputType; - mom6IauConfig.get("type", outputType); - std::string incrFname = std::filesystem::canonical(pathToResolve); - incrFname += "/ocn." + exp + "." + outputType + "." + dt.toString() + ".nc"; - const char* charPtr = incrFname.c_str(); - oops::Log::info() << "rename: " << incrFname << " to " << "inc.nc" << std::endl; - int result = std::rename(charPtr, "inc.nc"); - - return result; - } - // ----------------------------------------------------------------------------- - private: - std::string appname() const { - return "gdasapp::SocaIncr2Mom6"; - } - // ----------------------------------------------------------------------------- - }; - -} // namespace gdasapp