8#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
9#include <doctest/doctest.h>
17const std::string filename =
"example.nc";
18const std::string stateFilename =
"modelState.nc";
22TEST_CASE(
"Write out a ModelState-based DevGrid restart file")
25 grid.setIO(
new DevGridIO(grid));
28 size_t nx = DevGrid::nx;
29 size_t ny = DevGrid::nx;
30 double yFactor = 0.01;
31 double xFactor = 0.0001;
36 HField fractional(ModelArray::Type::H,
"");
37 for (
int j = 0; j < ny; ++j) {
38 for (
int i = 0; i < nx; ++i) {
39 fractional(i, j) = j * yFactor + i * xFactor;
43 HField hice = fractional + 1;
44 HField cice = fractional + 2;
45 HField sst = fractional + 3;
46 HField sss = fractional + 4;
47 HField hsnow = fractional + 5;
49 HField ticeValue = -(fractional + 1);
50 ZField tice = ModelArray::ZField(
"tice");
51 tice.setData(ticeValue);
62 grid.dumpModelState(state, stateFilename);
63 WARN(
"File written to " << stateFilename);
66TEST_CASE(
"Read the ModelState example file, if it exists")
74 grid.setIO(
new DevGridIO(grid));
75 ModelState ms = grid.getModelState(stateFilename);
79 REQUIRE(ms.at(
"hice")(targetX, targetY) != 0);
80 REQUIRE(ms.at(
"hice")(targetX, targetY) > 1);
81 REQUIRE(ms.at(
"hice")(targetX, targetY) < 2);
82 REQUIRE(ms.at(
"hice")(targetX, targetY) == 1.0703);
const MultiDim & dimensions() const
Returns a vector<size_t> of the size of each dimension of this type of ModelArray.
static void setDimensions(Type, const MultiDim &)
Sets the number and size of the dimensions of a specified type of ModelArray.