File: grids.cc

package info (click to toggle)
metview 5.26.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 614,356 kB
  • sloc: cpp: 560,586; ansic: 44,641; xml: 19,933; f90: 17,984; sh: 7,454; python: 5,565; yacc: 2,318; lex: 1,372; perl: 701; makefile: 88
file content (73 lines) | stat: -rw-r--r-- 2,181 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * (C) Copyright 1996- ECMWF.
 *
 * This software is licensed under the terms of the Apache Licence Version 2.0
 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * In applying this licence, ECMWF does not waive the privileges and immunities
 * granted to it by virtue of its status as an intergovernmental organisation nor
 * does it submit to any jurisdiction.
 */


#include "eckit/testing/Test.h"
#include "eckit/utils/RLE.h"

#include "mir/api/mir_config.h"
#include "mir/util/Atlas.h"
#include "mir/util/Log.h"


namespace mir::tests::unit {


void grid(const atlas::GaussianGrid& grid) {

    const auto& pl = grid.nx();
    EXPECT(!pl.empty());

    std::vector<int> points_per_latitudes(pl.size());
    EXPECT(pl.size() == points_per_latitudes.size());

    size_t half = points_per_latitudes.size() / 2;
    EXPECT(half > 0);

    std::vector<int> diff;
    diff.reserve(half);
    eckit::DIFFencode(points_per_latitudes.begin(), points_per_latitudes.begin() + static_cast<long>(half),
                      std::back_inserter(diff));

    std::vector<int> rle;
    eckit::RLEencode2(diff.begin(), diff.end(), std::back_inserter(rle), 1000);

    const atlas::Grid& g = grid;

    Log::info() << "uid " << g.uid() << " rle ";
    eckit::RLEprint(Log::info(), rle.begin(), rle.end());
    Log::info() << std::endl;
}


CASE("atlas::ReducedGaussianGrid") {
    if constexpr (MIR_HAVE_ATLAS) {
        for (const auto* name :
             {"N16",  "N24",  "N32",  "N48",  "N64",  "N80",   "N96",   "N128",  "N160",  "N200",  "N256", "N320",
              "N400", "N512", "N576", "N640", "N800", "N1024", "N1280", "N1600", "N2000", "N4000", "N8000"}) {
            grid(atlas::ReducedGaussianGrid(name));
        }
    }

    for (const auto* name :
         {"O16",  "O24",  "O32",  "O48",  "O64",  "O80",   "O96",   "O128",  "O160",  "O200",  "O256", "O320",
          "O400", "O512", "O576", "O640", "O800", "O1024", "O1280", "O1600", "O2000", "O4000", "O8000"}) {
        grid(atlas::ReducedGaussianGrid(name));
    }
}


}  // namespace mir::tests::unit


int main(int argc, char** argv) {
    return eckit::testing::run_tests(argc, argv);
}