14 #include <boost/lexical_cast.hpp> 15 #include <boost/scoped_ptr.hpp> 16 #include <boost/test/unit_test.hpp> 19 #include "eckit/config/LocalConfiguration.h" 28 class ModBiasTestFixture : TestFixture {
34 nobias_.reset(
new eckit::LocalConfiguration());
40 boost::scoped_ptr<lorenz95::Resolution>
resol_;
41 boost::scoped_ptr<const eckit::LocalConfiguration>
conf_;
42 boost::scoped_ptr<const eckit::LocalConfiguration>
nobias_;
53 boost::scoped_ptr<lorenz95::ModelBiasCorrection> dx(
55 BOOST_CHECK(dx.get() !=
NULL);
59 boost::scoped_ptr<lorenz95::ModelBiasCorrection> dx(
61 BOOST_CHECK(dx.get() !=
NULL);
70 BOOST_CHECK_EQUAL(dx2.
bias(), bias1_);
82 BOOST_CHECK_EQUAL(dx2.
bias(), 0.0);
94 BOOST_CHECK_EQUAL(dx2.
bias(), 0.0);
106 BOOST_CHECK_EQUAL(dx2.
bias(), 0.0);
115 BOOST_CHECK_EQUAL(dx2.
bias(), bias1_);
126 BOOST_CHECK_EQUAL(dx2.
bias(), 0.0);
139 BOOST_CHECK_EQUAL(dx.
bias(), bias1_ - bias2_);
153 BOOST_CHECK_EQUAL(dx.
bias(), 0.0);
162 BOOST_CHECK_EQUAL(dx.
bias(), 0.0);
174 BOOST_CHECK_EQUAL(dx1.
bias(), bias2_);
187 BOOST_CHECK_EQUAL(dx1.
bias(), 0.0);
198 BOOST_CHECK_EQUAL(dx1.
bias(), bias1_ + bias2_);
210 BOOST_CHECK_EQUAL(dx1.
bias(), bias1_);
221 BOOST_CHECK_EQUAL(dx1.
bias(), bias1_ - bias2_);
233 BOOST_CHECK_EQUAL(dx1.
bias(), bias1_);
242 BOOST_CHECK_EQUAL(dx.
bias(), bias1_ * fact_);
252 BOOST_CHECK_EQUAL(dx.
bias(), bias1_);
261 dx1.
axpy(fact_, dx2);
263 BOOST_CHECK_EQUAL(dx1.
bias(), (bias1_ + fact_ * bias2_));
272 dx1.
axpy(fact_, dx2);
275 BOOST_CHECK_EQUAL(dx1.
bias(), bias1_);
286 BOOST_CHECK_EQUAL(dpwResult, bias1_ * bias2_);
298 BOOST_CHECK_EQUAL(dpwResult, 0.0);
315 std::string filename(
"ModelBiasCorrectionTest.txt");
317 std::ostream os(&fb);
322 std::string inputString;
323 std::string inputBias;
324 double testBias = bias1_;
326 int biasStartPos = 22;
327 std::ifstream inputFile(filename.c_str());
328 if (inputFile.is_open()) {
329 getline(inputFile, inputString);
330 getline(inputFile, inputString);
332 inputBias = inputString.substr(biasStartPos);
335 bias = boost::lexical_cast<
double>(inputBias);
337 catch(boost::bad_lexical_cast
const&) {
338 BOOST_ERROR(
"operator<< incorrectly output a non-double");
341 BOOST_CHECK_CLOSE(testBias, bias, 0.0001);
345 BOOST_ERROR(
"operator<< functionality cannot be determined");
355 BOOST_CHECK_EQUAL(dx.
bias(), bias1_);
359 BOOST_AUTO_TEST_SUITE_END()
boost::scoped_ptr< const eckit::LocalConfiguration > conf_
void diff(const ModelBias &, const ModelBias &)
Linear algebra operators.
*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
boost::scoped_ptr< lorenz95::Resolution > resol_
boost::scoped_ptr< const eckit::LocalConfiguration > nobias_
double dot_product_with(const ModelBiasCorrection &) const
const double & bias() const
Model error for Lorenz 95 model.
BOOST_AUTO_TEST_CASE(test_GomL95_constructor)
static const eckit::Configuration & config()
void axpy(const double, const ModelBiasCorrection &)