19 #include "eckit/config/Configuration.h" 22 #include "oops/util/abor1_cpp.h" 23 #include "oops/util/Logger.h" 33 : size_(0), iobs_(), locval_(), current_(0)
35 oops::Log::trace() <<
"GomL95::GomL95 starting " << std::endl;
40 for (
size_t jj = 0; jj <
size_; ++jj)
locval_[jj] = locs[jj];
45 : size_(0), iobs_(), locval_(), current_(0)
51 : size_(other.size_), iobs_(other.iobs_), locval_(other.locval_), current_(0)
53 oops::Log::trace() <<
"GomL95::GomL95 copied" << std::endl;
92 return sqrt(xnorm/static_cast<double>(
size_));
96 static std::mt19937 generator(5);
97 static std::normal_distribution<double> distribution(0.0, 1.0);
98 for (
size_t jj = 0; jj <
size_; ++jj)
locval_[jj] = distribution(generator);
108 const std::string filename(
conf.getString(
"filename"));
109 oops::Log::trace() <<
"GomL95::read opening " << filename << std::endl;
110 std::ifstream fin(filename.c_str());
111 if (!fin.is_open()) ABORT(
"GomL95::read: Error opening file");
122 for (
size_t jj = 0; jj < size_; ++jj) fin >>
iobs_[jj];
123 for (
size_t jj = 0; jj < size_; ++jj) fin >>
locval_[jj];
126 oops::Log::trace() <<
"GomL95::read: file closed." << std::endl;
130 const std::string filename(
conf.getString(
"filename"));
131 oops::Log::trace() <<
"GomL95::write opening " << filename << std::endl;
132 std::ofstream fout(filename.c_str());
133 if (!fout.is_open()) ABORT(
"GomL95::write: Error opening file");
135 fout <<
size_ << std::endl;
136 for (
size_t jj = 0; jj <
size_; ++jj) fout <<
iobs_[jj] <<
" ";
138 fout.precision(std::numeric_limits<double>::digits10);
139 for (
size_t jj = 0; jj <
size_; ++jj) fout <<
locval_[jj] <<
" ";
143 oops::Log::trace() <<
"GomL95::write file closed." << std::endl;
150 oops::Log::trace() <<
"GomL95::GomL95 analytic init " << std::endl;
153 for (
size_t jj = 0; jj <
size_; ++jj)
locval_[jj] = 0.0;
154 if (
conf.has(
"mean")) {
155 const double zz =
conf.getDouble(
"mean");
158 if (
conf.has(
"sinus")) {
159 const double zz =
conf.getDouble(
"sinus");
160 const double pi = std::acos(-1.0);
161 for (
size_t jj = 0; jj <
size_; ++jj)
162 locval_[jj] += zz * std::sin(2.0*
pi*locs[jj]);
164 oops::Log::trace() <<
"GomL95::GomL95 analytic init finished" << std::endl;
172 for (
size_t jj = 0; jj <
size_; ++jj) {
181 os <<
size_ <<
"values, Min=" << zmin <<
", Max=" << zmax <<
", Average=" << zavg;
188 oops::Log::debug() << std::endl <<
"GomL95: Maximum Value = " << std::setprecision(4)
189 << zmax <<
" at location = " << jmax << std::endl;
const int & globalIndex(const size_t ii) const
GomL95 class to handle locations for L95 model.
GomL95 & operator*=(const double &)
void print(std::ostream &) const
LocsL95 class to handle locations for L95 model.
GomL95(const LocsL95 &, const oops::Variables &)
The namespace for the main oops code.
void analytic_init(const LocsL95 &, const eckit::Configuration &)
GomL95 analytic initialization.
GomL95 & operator-=(const GomL95 &)
The namespace for the L95 model.
void read(const eckit::Configuration &)
std::vector< double > locval_
double dot_product_with(const GomL95 &) const
void write(const eckit::Configuration &) const
GomL95 & operator/=(const GomL95 &)
GomL95 & operator+=(const GomL95 &)