Go to the documentation of this file.
17 #include "atlas/field.h"
19 #include "eckit/exception/Exceptions.h"
21 #include "oops/util/abor1_cpp.h"
22 #include "oops/util/DateTime.h"
23 #include "oops/util/dot_product.h"
24 #include "oops/util/Duration.h"
25 #include "oops/util/Logger.h"
26 #include "oops/util/stringFunctions.h"
38 namespace sf = util::stringfunctions;
46 const util::DateTime & vt)
47 : fld_(resol), time_(vt)
50 oops::Log::trace() <<
"IncrementL95::IncrementL95 created." << std::endl;
54 : fld_(resol), time_(dx.time_)
57 oops::Log::trace() <<
"IncrementL95::IncrementL95 created by interpolation." << std::endl;
61 : fld_(dx.fld_, copy), time_(dx.time_)
63 oops::Log::trace() <<
"IncrementL95::IncrementL95 copy-created." << std::endl;
67 oops::Log::trace() <<
"IncrementL95::~IncrementL95 destructed" << std::endl;
125 double zz = dot_product(
fld_, other.
fld_);
144 std::string filename(config.getString(
"filename"));
145 sf::swapNameMember(config, filename);
146 oops::Log::trace() <<
"IncrementL95::read opening " << filename << std::endl;
147 std::ifstream fin(filename.c_str());
148 if (!fin.is_open()) ABORT(
"IncrementL95::read: Error opening file: " + filename);
156 const util::DateTime tt(stime);
157 const util::DateTime tc(config.getString(
"date"));
159 ABORT(
"IncrementL95::read: date and data file inconsistent.");
166 oops::Log::trace() <<
"IncrementL95::read: file closed." << std::endl;
170 std::string dir = config.getString(
"datadir");
171 std::string exp = config.getString(
"exp");
172 std::string type = config.getString(
"type");
173 std::string filename = dir+
"/"+exp+
"."+type;
175 const util::DateTime antime(config.getString(
"date"));
176 filename +=
"."+antime.toString();
177 const util::Duration step =
time_ - antime;
178 filename +=
"."+step.toString();
179 sf::swapNameMember(config, filename);
181 oops::Log::trace() <<
"IncrementL95::write opening " << filename << std::endl;
182 std::ofstream fout(filename.c_str());
183 if (!fout.is_open()) ABORT(
"IncrementL95::write: Error opening file: " + filename);
186 fout <<
time_ << std::endl;
191 oops::Log::trace() <<
"IncrementL95::write file closed." << std::endl;
195 os << std::endl <<
" Valid time: " <<
time_;
196 os << std::endl <<
fld_;
200 std::vector<std::string> vars;
202 std::vector<double> vals;
204 std::vector<int> varlens;
205 varlens.push_back(1);
210 std::vector<double> vals;
218 ABORT(
"FieldL95 setAtlas not implemented");
222 ABORT(
"FieldL95 toAtlas not implemented");
226 ABORT(
"FieldL95 fromAtlas not implemented");
234 nn +=
time_.serialSize();
239 vect.push_back(1000.0);
241 vect.push_back(2000.0);
242 time_.serialize(vect);
243 vect.push_back(3000.0);
248 ASSERT(vect.at(index) == 1000.0);
251 ASSERT(vect.at(index) == 2000.0);
253 time_.deserialize(vect, index);
254 ASSERT(vect.at(index) == 3000.0);
double dot_product_with(const IncrementL95 &) const
The namespace for the main oops code.
void print(std::ostream &) const override
size_t serialSize() const override
Serialize and deserialize.
void fromAtlas(atlas::FieldSet *)
void setAtlas(atlas::FieldSet *) const
ATLAS.
void deserialize(const std::vector< double > &, size_t &) override
void read(const eckit::Configuration &)
Utilities.
void write(const eckit::Configuration &) const
void deserialize(const std::vector< double > &, size_t &) override
void schur_product_with(const IncrementL95 &)
IncrementL95 & operator*=(const double &)
void schur(const FieldL95 &)
size_t serialSize() const override
Serialize and deserialize.
void dirac(const eckit::Configuration &)
void serialize(std::vector< double > &) const override
const util::DateTime & validTime() const
Increment Class: Difference between two states.
void serialize(std::vector< double > &) const override
oops::LocalIncrement getLocal(const Iterator &) const
IncrementL95(const Resolution &, const oops::Variables &, const util::DateTime &)
Constructor, destructor.
const FieldL95 & getField() const
IncrementL95 & operator-=(const IncrementL95 &)
void write(std::ofstream &) const
void axpy(const double &, const FieldL95 &)
void axpy(const double &, const IncrementL95 &, const bool check=true)
void setLocal(const oops::LocalIncrement &, const Iterator &)
void zero()
Linear algebra.
void accumul(const double &, const StateL95 &)
IncrementL95 & operator=(const IncrementL95 &)
void diff(const StateL95 &, const StateL95 &)
Basic operators.
void toAtlas(atlas::FieldSet *) const
IncrementL95 & operator+=(const IncrementL95 &)
void diff(const FieldL95 &, const FieldL95 &)
const std::vector< double > & getVals() const
const int & resol() const
Set and get.
The namespace for the L95 model.
void read(std::ifstream &)
Utilities.
void dirac(const eckit::Configuration &)