22 #include "eckit/config/LocalConfiguration.h" 25 #include "oops/util/abor1_cpp.h" 26 #include "oops/util/DateTime.h" 27 #include "oops/util/Duration.h" 28 #include "oops/util/Logger.h" 35 const util::DateTime & bgn,
const util::DateTime &
end)
36 :
oops::ObsSpaceBase(config, bgn,
end), winbgn_(bgn), winend_(
end)
40 if (
config.has(
"ObsData")) {
41 const eckit::LocalConfiguration dataConfig(
config,
"ObsData");
42 if (dataConfig.has(
"ObsDataIn")) {
43 nameIn_ = dataConfig.getString(
"ObsDataIn.filename");
46 if (dataConfig.has(
"ObsDataOut")) {
47 nameOut_ = dataConfig.getString(
"ObsDataOut.filename");
50 oops::Log::trace() <<
"ObsTable::ObsTable created" << std::endl;
59 oops::Log::trace() <<
"ObsTable::ObsTable destructed" << std::endl;
64 void ObsTable::putdb(
const std::string & col,
const std::vector<double> & vec)
const {
65 ASSERT(vec.size() ==
nobs());
67 data_.insert(std::pair<std::string, std::vector<double> >(col, vec));
73 std::map<std::string, std::vector<double> >::const_iterator ic =
data_.find(col);
74 ASSERT(ic !=
data_.end());
76 for (
unsigned int jobs = 0; jobs <
nobs(); ++jobs) {
77 vec[jobs] = ic->second[jobs];
85 const int nobs = olist.size();
86 std::vector<double> locs(
nobs);
87 for (
int jobs = 0; jobs <
nobs; ++jobs) locs[jobs]=
locations_[olist[jobs]];
88 return new LocsL95(olist, locs);
94 const util::DateTime &
t2)
const {
95 std::vector<int> mask;
96 for (
unsigned int jobs = 0; jobs <
nobs(); ++jobs)
104 oops::Log::trace() <<
"ObsTable::generateDistribution starting" << std::endl;
106 util::Duration first(
config.getString(
"begin"));
109 last = util::Duration(
config.getString(
"end"));
111 util::Duration
freq(
config.getString(
"obs_frequency"));
114 util::Duration
step(first);
120 const unsigned int nobs_locations =
config.getInt(
"obs_density");
121 const unsigned int nobs = nobs_locations*nobstimes;
122 double dx = 1.0/
static_cast<double>(nobs_locations);
127 unsigned int iobs = 0;
132 for (
unsigned int jobs = 0; jobs < nobs_locations; ++jobs) {
133 double xpos = jobs*dx;
140 ASSERT(iobs ==
nobs);
143 const double err =
config.getDouble(
"obs_error");
144 std::vector<double> obserr(
nobs);
145 for (
unsigned int jj = 0; jj <
nobs; ++jj) {
148 this->
putdb(
"ObsErr", obserr);
150 oops::Log::trace() <<
"ObsTable::generateDistribution done" << std::endl;
164 oops::Log::trace() <<
"ObsTable::ot_read starting" << std::endl;
165 std::ifstream fin(filename.c_str());
166 if (!fin.is_open()) ABORT(
"ObsTable::otOpen: Error opening file");
171 std::vector<std::string> colnames;
172 for (
int jc = 0; jc < ncol; ++jc) {
175 colnames.push_back(col);
180 std::vector<double> newcol(
nobs);
181 for (
int jc = 0; jc < ncol; ++jc) {
182 ASSERT(
data_.find(colnames[jc]) ==
data_.end());
183 data_.insert(std::pair<std::string, std::vector<double> >(colnames[jc], newcol));
188 for (
int jobs = 0; jobs <
nobs; ++jobs) {
193 util::DateTime ttt(sss);
196 for (std::map<std::string, std::vector<double> >::iterator jo =
data_.begin();
197 jo !=
data_.end(); ++jo)
198 fin >> jo->second[jobs];
202 oops::Log::trace() <<
"ObsTable::ot_read done" << std::endl;
208 oops::Log::trace() <<
"ObsTable::otWrite writing " << filename << std::endl;
209 std::ofstream fout(filename.c_str());
210 if (!fout.is_open()) ABORT(
"ObsTable::otWrite: Error opening file");
212 int ncol =
data_.size();
213 fout << ncol << std::endl;
215 for (std::map<std::string, std::vector<double> >::const_iterator jo =
data_.begin();
216 jo !=
data_.end(); ++jo)
217 fout << jo->first << std::endl;
220 fout <<
nobs << std::endl;
221 for (
int jobs = 0; jobs <
nobs; ++jobs) {
223 fout <<
" " <<
times_[jobs];
225 for (std::map<std::string, std::vector<double> >::const_iterator jo =
data_.begin();
226 jo !=
data_.end(); ++jo)
227 fout <<
" " << jo->second[jobs];
232 oops::Log::trace() <<
"ObsTable::otWrite done" << std::endl;
238 os <<
"ObsTable: assimilation window = " <<
winbgn_ <<
" to " <<
winend_ << std::endl;
239 os <<
"ObsTable: file in = " <<
nameIn_ <<
", file out = " <<
nameOut_ << std::endl;
void otWrite(const std::string &) const
std::map< std::string, std::vector< double > > data_
std::vector< util::DateTime > times_
std::vector< int > timeSelect(const util::DateTime &, const util::DateTime &) const
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT end
void putdb(const std::string &, const std::vector< double > &) const
void print(std::ostream &) const
LocsL95 * locations(const util::DateTime &t1, const util::DateTime &t2) const
LocsL95 class to handle locations for L95 model.
The namespace for the main oops code.
Vector in observation space.
void getdb(const std::string &, std::vector< double > &) const
const util::DateTime winbgn_
void otOpen(const std::string &)
std::vector< double > locations_
unsigned int nobs() const
subroutine, public info(self)
The namespace for the L95 model.
subroutine, public step(x, g)
void printJo(const ObsVec1D &, const ObsVec1D &)
type(tms), dimension(nblks), private last
const eckit::Configuration & config() const
Access information.
void generateDistribution(const eckit::Configuration &)
Pure virtual methods.
ObsTable(const eckit::Configuration &, const util::DateTime &, const util::DateTime &)
const util::DateTime winend_