FV3 Bundle
Run.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #include "oops/runs/Run.h"
12 
13 #include <mpi.h>
14 #include <string>
15 #include <boost/scoped_ptr.hpp>
16 
17 #include "eckit/config/LocalConfiguration.h"
18 #include "eckit/config/YAMLConfiguration.h"
19 #include "eckit/exception/Exceptions.h"
20 
21 #include "oops/parallel/mpi/mpi.h"
22 #include "oops/runs/Application.h"
23 #include "oops/util/LibOOPS.h"
24 #include "oops/util/Logger.h"
25 #include "oops/util/ObjectCountHelper.h"
26 #include "oops/util/TimerHelper.h"
27 
28 namespace oops {
29 
30 // -----------------------------------------------------------------------------
31 
32 Run::Run(int argc, char** argv) : eckit::Main(argc, argv, "OOPS_HOME"), config_(), timer_() {
33 // Initialize MPI
34  oops::mpi::comm().communicator();
35 
36 // Get configuration file from command line
37  ASSERT(argc >= 2);
38  eckit::PathName configfile = argv[argc - 1];
39 
40 // Read configuration
41  config_.reset(new eckit::YAMLConfiguration(configfile));
42 
43  Log::info() << "Configuration input file is: " << configfile << std::endl;
44  Log::info() << "Full configuration is:" << *config_ << std::endl;
45 
46 // Start measuring performance
49 }
50 
51 // -----------------------------------------------------------------------------
52 
54  LibOOPS::instance().finalise();
55 }
56 
57 // -----------------------------------------------------------------------------
58 
59 void Run::execute(const Application & app) {
60  int status = 1;
61  Log::info() << "Run: Starting " << app << std::endl;
62  try {
63  status = app.execute(*config_);
64  }
65  catch(const eckit::Exception & e) {
66  status = 1;
67  Log::error() << e.what() << " caught in " << Here() << std::endl;
68  Log::error() << "Exception: " << app << " terminating..." << std::endl;
69  eckit::Exception::exceptionStack(eckit::Log::error(), true);
70  }
71  catch(const std::exception & e) {
72  status = 1;
73  Log::error() << "Exception: " << e.what() << std::endl;
74  Log::error() << "Exception: " << app << " terminating..." << std::endl;
75  }
76  catch(...) {
77  status = 1;
78  Log::error() << "Unknown exception: " << app << " terminating..." << std::endl;
79  }
80  Log::info() << "Run: Finishing " << app << std::endl;
81 
82 // Performance diagnostics
83  util::ObjectCountHelper::stop();
84  util::TimerHelper::stop();
85 
86  Log::info() << "Run: Finishing " << app << " with status = " << status << std::endl;
87  if (status) ::exit(status);
88 }
89 
90 // -----------------------------------------------------------------------------
91 
92 } // namespace oops
Run(int argc, char **argv)
Definition: Run.cc:32
The namespace for the main oops code.
void execute(const Application &)
Definition: Run.cc:59
real(fp), parameter, public e
boost::scoped_ptr< const eckit::YAMLConfiguration > config_
Definition: Run.h:39
************************************************************************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:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE start
subroutine, public info(self)
integer error
Definition: mpp.F90:1310
const eckit::mpi::Comm & comm()
Definition: mpi.cc:16
virtual ~Run()
Definition: Run.cc:53
character(len=32) configfile
Definition: mpp.F90:1307
virtual int execute(const eckit::Configuration &) const =0