Ensign
Low-rank framework for multi-core CPUs and GPUs
Loading...
Searching...
No Matches
netcdf.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <generic/common.hpp>
9#include <map>
10#include <cstdlib>
11
12#define ERRCODE 2
13#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
14
15namespace Ensign {
16
18struct nc_writer {
19
20 nc_writer(string filename, vector<long> extensions, vector<string> d_names);
22
23 void add_var(string name, vector<string> dims);
24
26 void write(string name, const double* data);
27
28private:
29 int ncid;
30 std::map<string,int> dim_ids;
31 std::map<string,int> var_ids;
32};
33
34#define NETCDF_CHECK(e) \
35 { \
36 int res = e; \
37 if (res != NC_NOERR) { \
38 std::cout << "NetCDF Error " << __FILE__ << ":" << __LINE__ << ": " \
39 << nc_strerror(res) << std::endl; \
40 exit(EXIT_FAILURE); \
41 } \
42 }
43
44} // namespace Ensign
Provides shared types, platform headers, and basic definitions.
Core namespace for Ensign's numerical algorithms and data structures.
Definition common.hpp:96
Writes simulation variables and dimension metadata to a NetCDF file.
Definition netcdf.hpp:18
void add_var(string name, vector< string > dims)
nc_writer(string filename, vector< long > extensions, vector< string > d_names)
void write(string name, const double *data)