11 #ifndef OOPS_INTERFACE_LINEARMODEL_H_ 12 #define OOPS_INTERFACE_LINEARMODEL_H_ 16 #include <boost/noncopyable.hpp> 17 #include <boost/scoped_ptr.hpp> 27 #include "oops/util/Duration.h" 28 #include "oops/util/Logger.h" 29 #include "oops/util/ObjectCounter.h" 30 #include "oops/util/Printable.h" 31 #include "oops/util/Timer.h" 48 template <
typename MODEL>
50 private boost::noncopyable,
51 private util::ObjectCounter<LinearModel<MODEL> > {
60 static const std::string
classname() {
return "oops::LinearModel";}
69 const bool idmodel =
false)
const;
75 const bool idmodel =
false)
const;
97 void print(std::ostream &)
const;
99 boost::scoped_ptr<LinearModelBase_>
tlm_;
104 template<
typename MODEL>
108 Log::trace() <<
"LinearModel<MODEL>::LinearModel starting" << std::endl;
109 util::Timer timer(
classname(),
"LinearModel");
112 Log::trace() <<
"LinearModel<MODEL>::LinearModel done" << std::endl;
117 template<
typename MODEL>
119 Log::trace() <<
"LinearModel<MODEL>::~LinearModel starting" << std::endl;
120 util::Timer timer(classname(),
"~LinearModel");
122 Log::trace() <<
"LinearModel<MODEL>::~LinearModel done" << std::endl;
131 template<
typename MODEL>
133 const util::Duration &
len,
136 const bool idmodel)
const {
137 Log::trace() <<
"LinearModel<MODEL>::forecastTL starting" << std::endl;
138 util::Timer timer(classname(),
"forecastTL");
141 const util::Duration tstep(tlm_->timeResolution());
142 Log::info() <<
"LinearModel<MODEL>::forecastTL: Starting " << dx << std::endl;
143 this->initializeTL(dx);
156 this->stepTL(dx, mctl);
163 this->finalizeTL(dx);
164 Log::info() <<
"LinearModel<MODEL>::forecastTL: Finished " << dx << std::endl;
167 Log::trace() <<
"LinearModel<MODEL>::forecastTL done" << std::endl;
172 template<
typename MODEL>
174 const util::Duration &
len,
177 const bool idmodel)
const {
178 Log::trace() <<
"LinearModel<MODEL>::forecastAD starting" << std::endl;
179 util::Timer timer(classname(),
"forecastAD");
182 const util::Duration tstep(tlm_->timeResolution());
183 Log::info() <<
"LinearModel<MODEL>::forecastAD: Starting " << dx << std::endl;
184 this->initializeAD(dx);
196 this->stepAD(dx, mctl);
204 this->finalizeAD(dx);
205 Log::info() <<
"LinearModel<MODEL>::forecastAD: Finished " << dx << std::endl;
208 Log::trace() <<
"LinearModel<MODEL>::forecastAD done" << std::endl;
213 template<
typename MODEL>
216 Log::trace() <<
"LinearModel<MODEL>::setTrajectory starting" << std::endl;
217 util::Timer timer(classname(),
"setTrajectory");
218 tlm_->setTrajectory(xx, xlr, maux);
219 Log::trace() <<
"LinearModel<MODEL>::setTrajectory done" << std::endl;
224 template<
typename MODEL>
226 Log::trace() <<
"LinearModel<MODEL>::initializeTL starting" << std::endl;
227 util::Timer timer(classname(),
"initializeTL");
228 tlm_->initializeTL(dx);
229 Log::trace() <<
"LinearModel<MODEL>::initializeTL done" << std::endl;
234 template<
typename MODEL>
236 Log::trace() <<
"LinearModel<MODEL>::stepTL starting" << std::endl;
237 util::Timer timer(classname(),
"stepTL");
238 tlm_->stepTL(dx, merr);
239 Log::trace() <<
"LinearModel<MODEL>::stepTL done" << std::endl;
244 template<
typename MODEL>
246 Log::trace() <<
"LinearModel<MODEL>::finalizeTL starting" << std::endl;
247 util::Timer timer(classname(),
"finalizeTL");
248 tlm_->finalizeTL(dx);
249 Log::trace() <<
"LinearModel<MODEL>::finalizeTL done" << std::endl;
254 template<
typename MODEL>
256 Log::trace() <<
"LinearModel<MODEL>::initializeAD starting" << std::endl;
257 util::Timer timer(classname(),
"initializeAD");
258 tlm_->initializeAD(dx);
259 Log::trace() <<
"LinearModel<MODEL>::initializeAD done" << std::endl;
264 template<
typename MODEL>
266 Log::trace() <<
"LinearModel<MODEL>::stepAD starting" << std::endl;
267 util::Timer timer(classname(),
"stepAD");
268 tlm_->stepAD(dx, merr);
269 Log::trace() <<
"LinearModel<MODEL>::stepAD done" << std::endl;
274 template<
typename MODEL>
276 Log::trace() <<
"LinearModel<MODEL>::finalizeAD starting" << std::endl;
277 util::Timer timer(classname(),
"finalizeAD");
278 tlm_->finalizeAD(dx);
279 Log::trace() <<
"LinearModel<MODEL>::finalizeAD done" << std::endl;
284 template<
typename MODEL>
286 Log::trace() <<
"LinearModel<MODEL>::print starting" << std::endl;
287 util::Timer timer(classname(),
"print");
289 Log::trace() <<
"LinearModel<MODEL>::print done" << std::endl;
296 #endif // OOPS_INTERFACE_LINEARMODEL_H_ Increment< MODEL > Increment_
void initializeAD(Increment_ &dx, const util::DateTime &bgn, const util::Duration &step)
Adjoint methods.
void finalizeAD(Increment_ &) const
static const std::string classname()
************************************************************************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 stepAD(Increment_ &, ModelAuxIncr_ &) const
const oops::Variables & variables() const
const util::DateTime validTime() const
Time.
void stepTL(Increment_ &, const ModelAuxIncr_ &) const
Encapsulates the model state.
void finalizeTL(const Increment_ &dx)
void finalizeAD(Increment_ &dx)
boost::scoped_ptr< LinearModelBase_ > tlm_
LinearModelBase< MODEL > LinearModelBase_
ModelAuxControl< MODEL > ModelAux_
void updateTime(const util::Duration &dt)
The namespace for the main oops code.
void processTL(const Increment_ &dx)
subroutine, public info(self)
void processAD(Increment_ &dx)
void finalizeTL(Increment_ &) const
void finalize(const FLDS &xx)
Control model post processing.
void setTrajectory(const State_ &, State_ &, const ModelAux_ &)
void process(const FLDS &xx)
Base class for encapsulation of the linear forecast model.
LinearModelFactory Factory.
const util::Duration & timeResolution() const
Increment Class: Difference between two states.
void initializeTL(const Increment_ &dx, const util::DateTime &end, const util::Duration &step)
Tangent linear methods.
void forecastAD(Increment_ &, ModelAuxIncr_ &, const util::Duration &, PostProcessor< Increment_ > post=PostProcessor< Increment_ >(), PostProcessorTLAD< MODEL > cost=PostProcessorTLAD< MODEL >(), const bool idmodel=false) const
Run the adjoint forecast.
void forecastTL(Increment_ &, const ModelAuxIncr_ &, const util::Duration &, PostProcessor< Increment_ > post=PostProcessor< Increment_ >(), PostProcessorTLAD< MODEL > cost=PostProcessorTLAD< MODEL >(), const bool idmodel=false) const
Run the tangent linear forecast.
Control model post processing.
Geometry< MODEL > Geometry_
LinearModel(const Geometry_ &, const eckit::Configuration &)
void initialize(const FLDS &xx, const util::DateTime &end, const util::Duration &step)
Encapsulates the linear forecast model.
void initializeAD(Increment_ &) const
void initializeTL(Increment_ &) const
ModelAuxIncrement< MODEL > ModelAuxIncr_
void print(std::ostream &) const