|
Tsunami Project Lab
|
#include "NetCdf.h"#include <catch2/catch.hpp>#include <cstdio>#include <netcdf.h>#include <string>#include <vector>
Functions | |
| std::string | getAttr (int i_nc, int i_var, char const *i_name) |
| TEST_CASE ("io::NetCdf write + round-trip", "[NetCdfWrite]") | |
| TEST_CASE ("io::NetCdf checkpoint write + restart round-trip", "[NetCdfCheckpoint]") | |
| TEST_CASE ("io::NetCdf coarse output (k > 1) averages k x k blocks", "[NetCdfCoarse]") | |
| void | writeSpecFile (std::string const &i_path, tsunami_lab::t_real const *i_x, tsunami_lab::t_idx i_nx, tsunami_lab::t_real const *i_y, tsunami_lab::t_idx i_ny, tsunami_lab::t_real const *i_z, bool i_transpose=false) |
| TEST_CASE ("io::NetCdf read: parses a (y, x)-laid-out spec file", "[NetCdfRead]") | |
| TEST_CASE ("io::NetCdf read: transposes (x, y)-laid-out z to canonical (y, x)", "[NetCdfRead]") | |
| std::string getAttr | ( | int | i_nc, |
| int | i_var, | ||
| char const * | i_name ) |
Unit tests for io::NetCdf (assignment 5.1). The output side is checked end-to-end: write a tiny domain with a couple of time steps, then re-open the file via the netCDF C API and verify dimensions, attributes and the per-record data slabs. Reads a string attribute from an open netCDF file. Trims any trailing NUL bytes so REQUIRE-comparisons don't trip on them.
| TEST_CASE | ( | "io::NetCdf checkpoint write + restart round-trip" | , |
| "" | [NetCdfCheckpoint] ) |
| TEST_CASE | ( | "io::NetCdf coarse output (k > 1) averages k x k blocks" | , |
| "" | [NetCdfCoarse] ) |
| TEST_CASE | ( | "io::NetCdf read: parses a (y, x)-laid-out spec file" | , |
| "" | [NetCdfRead] ) |
| TEST_CASE | ( | "io::NetCdf read: transposes (x, y)-laid-out z to canonical (y, x)" | , |
| "" | [NetCdfRead] ) |
| TEST_CASE | ( | "io::NetCdf write + round-trip" | , |
| "" | [NetCdfWrite] ) |
| void writeSpecFile | ( | std::string const & | i_path, |
| tsunami_lab::t_real const * | i_x, | ||
| tsunami_lab::t_idx | i_nx, | ||
| tsunami_lab::t_real const * | i_y, | ||
| tsunami_lab::t_idx | i_ny, | ||
| tsunami_lab::t_real const * | i_z, | ||
| bool | i_transpose = false ) |
Writes a small (x, y, z) netCDF file using the C API directly, so the read-side tests don't depend on the writer half. The variable z is laid out as (y, x) by default, or as (x, y) when i_transpose is true (covers both file conventions).