FV3 Bundle
test/lorenz95/GomL95.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 <boost/scoped_ptr.hpp>
12 #include <boost/test/unit_test.hpp>
13 
14 #include "./TestConfig.h"
15 #include "eckit/config/LocalConfiguration.h"
16 #include "lorenz95/GomL95.h"
17 #include "lorenz95/LocsL95.h"
19 #include "lorenz95/ObsTable.h"
20 #include "oops/base/Variables.h"
21 #include "oops/util/DateTime.h"
22 #include "test/TestFixture.h"
23 
24 namespace test {
25 
26 // -----------------------------------------------------------------------------
28  public:
30  const eckit::LocalConfiguration conf(TestConfig::config(), "Observations");
31  const util::DateTime bgn(conf.getString("window_begin"));
32  const util::DateTime end(conf.getString("window_end"));
33  const eckit::LocalConfiguration otconf(conf, "Observation");
34  lorenz95::ObsTable ot(otconf, bgn, end);
35  util::DateTime t1("2010-01-01T03:00:00Z");
36  util::DateTime t2("2010-01-02T06:00:00Z");
37  locs_.reset(ot.locations(t1, t2));
38  eckit::LocalConfiguration vconf;
39  conf.get("Variables", vconf);
40  novar_.reset(new oops::Variables(vconf));
41  }
43  boost::scoped_ptr<lorenz95::LocsL95> locs_;
44  boost::scoped_ptr<oops::Variables> novar_;
45 };
46 // -----------------------------------------------------------------------------
47 
48 // -----------------------------------------------------------------------------
49 BOOST_FIXTURE_TEST_SUITE(test_GomL95, GomTestFixture)
50 // -----------------------------------------------------------------------------
51  BOOST_AUTO_TEST_CASE(test_GomL95_constructor) {
52  boost::scoped_ptr<lorenz95::GomL95> gom(new lorenz95::GomL95(*locs_, *novar_));
53  BOOST_CHECK(gom.get() != NULL);
54  }
55 // -----------------------------------------------------------------------------
56  BOOST_AUTO_TEST_CASE(test_GomL95_nobs) {
57  boost::scoped_ptr<lorenz95::GomL95> gom(new lorenz95::GomL95(*locs_, *novar_));
58  size_t ref = 160;
59  BOOST_CHECK_EQUAL(gom->size(), ref);
60  }
61 // -----------------------------------------------------------------------------
62  BOOST_AUTO_TEST_CASE(test_gomL95_classname) {
63  boost::scoped_ptr<lorenz95::GomL95> gom(new lorenz95::GomL95(*locs_, *novar_));
64  BOOST_CHECK_EQUAL(gom->classname(), "lorenz95::GomL95");
65  }
66 // -----------------------------------------------------------------------------
67  BOOST_AUTO_TEST_CASE(test_gomL95_zero) {
68  boost::scoped_ptr<lorenz95::GomL95> gom(new lorenz95::GomL95(*locs_, *novar_));
69  gom->zero();
70  for (size_t i = 0; i < gom->size(); ++i) {
71  BOOST_CHECK_EQUAL((*gom)[i], 0.0);
72  }
73  }
74 // -----------------------------------------------------------------------------
75  BOOST_AUTO_TEST_CASE(test_gomL95_dot_product_with) {
76  boost::scoped_ptr<lorenz95::GomL95> gom1(new lorenz95::GomL95(*locs_, *novar_));
77  gom1->zero();
78  boost::scoped_ptr<lorenz95::GomL95> gom2(new lorenz95::GomL95(*locs_, *novar_));
79  gom2->zero();
80 
81  double zz = gom1->dot_product_with(*gom2);
82  BOOST_CHECK_EQUAL(zz, 0.0);
83  }
84 // -----------------------------------------------------------------------------
85  BOOST_AUTO_TEST_CASE(test_gomL95_operator) {
86  boost::scoped_ptr<lorenz95::GomL95> gom1(new lorenz95::GomL95(*locs_, *novar_));
87  gom1->zero();
88  boost::scoped_ptr<lorenz95::GomL95> gom2(new lorenz95::GomL95(*locs_, *novar_));
89  gom2->zero();
90 
91  (*gom1)[1] = 1.0;
92  (*gom2)[3] = 1.0;
93  double zz = gom1->dot_product_with(*gom2);
94  BOOST_CHECK_EQUAL(zz, 0.0);
95 
96  (*gom1)[3] = 1.0;
97  zz = gom1->dot_product_with(*gom2);
98  BOOST_CHECK_EQUAL(zz, 1.0);
99  }
100 // -----------------------------------------------------------------------------
101 BOOST_AUTO_TEST_SUITE_END()
102 // -----------------------------------------------------------------------------
103 
104 } // namespace test
GomL95 class to handle locations for L95 model.
Definition: GomL95.h:32
l_size ! loop over number of fields ke do je do i
boost::scoped_ptr< lorenz95::LocsL95 > locs_
************************************************************************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
Definition: conf.py:1
*f90 *************************************************************************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:! ***********************************************************************! this routine is used to retrieve scalar boundary data for symmetric domain. subroutine MPP_GET_BOUNDARY_2D_(field, domain, ebuffer, sbuffer, wbuffer, nbuffer, flags, &position, complete, tile_count) type(domain2D), intent(in) ::domain MPP_TYPE_, intent(in) ::field(:,:) MPP_TYPE_, intent(inout), optional ::ebuffer(:), sbuffer(:), wbuffer(:), nbuffer(:) integer, intent(in), optional ::flags, position, tile_count logical, intent(in), optional ::complete MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) MPP_TYPE_, allocatable, dimension(:,:) ::ebuffer2D, sbuffer2D, wbuffer2D, nbuffer2D integer ::xcount, ycount integer ::ntile logical ::need_ebuffer, need_sbuffer, need_wbuffer, need_nbuffer integer(LONG_KIND), dimension(MAX_DOMAIN_FIELDS, MAX_TILES), save ::f_addrs=-9999 integer(LONG_KIND), dimension(4, MAX_DOMAIN_FIELDS, MAX_TILES), save ::b_addrs=-9999 integer, save ::bsize(4)=0, isize=0, jsize=0, ksize=0, pos, list=0, l_size=0, upflags integer ::buffer_size(4) integer ::max_ntile, tile, update_position, ishift, jshift logical ::do_update, is_complete, set_mismatch character(len=3) ::text MPP_TYPE_ ::d_type type(overlapSpec), pointer ::bound=> NULL() ntile
real, parameter t2
LocsL95 * locations(const util::DateTime &t1, const util::DateTime &t2) const
real, parameter t1
boost::scoped_ptr< oops::Variables > novar_
A Simple Observation Data Handler.
Definition: ObsTable.h:39
BOOST_AUTO_TEST_CASE(test_GomL95_constructor)
static const eckit::Configuration & config()
Definition: TestConfig.h:30