47 nc_read_from_file (
const int ncid,
51 nrows = nc_get_dim (ncid,
"nrows");
52 ncols = nc_get_dim (ncid,
"ncols");
55 nc_get_data_double (ncid,
"Matrix", m.
get_c_array());
65 nc_write_to_file (
const int ncid,
70 if ((retval = nc_def_dim (ncid,
"nrows", m.
nrows(), &ncdims[0])))
71 ncerror (retval,
"nc_def_dim");
72 if ((retval = nc_def_dim (ncid,
"ncols", m.
ncols(), &ncdims[1])))
73 ncerror (retval,
"nc_def_dim");
74 if ((retval = nc_def_var (ncid,
"Matrix", NC_DOUBLE, 2, &ncdims[0], &varid)))
75 ncerror (retval,
"nc_def_var");
76 if ((retval = nc_enddef (ncid))) ncerror (retval,
"nc_enddef");
77 if ((retval = nc_put_var_double (ncid, varid, m.
get_c_array())))
78 ncerror (retval,
"nc_put_var");
89 nc_read_from_file (
const int ncid,
92 Index npages, nrows, ncols;
93 npages = nc_get_dim (ncid,
"npages");
94 nrows = nc_get_dim (ncid,
"nrows");
95 ncols = nc_get_dim (ncid,
"ncols");
97 t.
resize(npages, nrows, ncols);
98 nc_get_data_double (ncid,
"Tensor3", t.
get_c_array());
108 nc_write_to_file (
const int ncid,
112 int ncdims[3], varid;
113 if ((retval = nc_def_dim (ncid,
"npages", t.
npages(), &ncdims[0])))
114 ncerror (retval,
"nc_def_dim");
115 if ((retval = nc_def_dim (ncid,
"nrows", t.
nrows(), &ncdims[1])))
116 ncerror (retval,
"nc_def_dim");
117 if ((retval = nc_def_dim (ncid,
"ncols", t.
ncols(), &ncdims[2])))
118 ncerror (retval,
"nc_def_dim");
119 if ((retval = nc_def_var (ncid,
"Tensor3", NC_DOUBLE, 3, &ncdims[0], &varid)))
120 ncerror (retval,
"nc_def_var");
121 if ((retval = nc_enddef (ncid))) ncerror (retval,
"nc_enddef");
122 if ((retval = nc_put_var_double (ncid, varid, t.
get_c_array())))
123 ncerror (retval,
"nc_put_var");
134 nc_read_from_file (
const int ncid,
137 Index nbooks, npages, nrows, ncols;
138 nbooks = nc_get_dim (ncid,
"nbooks");
139 npages = nc_get_dim (ncid,
"npages");
140 nrows = nc_get_dim (ncid,
"nrows");
141 ncols = nc_get_dim (ncid,
"ncols");
143 t.
resize(nbooks, npages, nrows, ncols);
144 nc_get_data_double (ncid,
"Tensor4", t.
get_c_array());
154 nc_write_to_file (
const int ncid,
158 int ncdims[4], varid;
159 if ((retval = nc_def_dim (ncid,
"nbooks", t.
nbooks(), &ncdims[0])))
160 ncerror (retval,
"nc_def_dim");
161 if ((retval = nc_def_dim (ncid,
"npages", t.
npages(), &ncdims[1])))
162 ncerror (retval,
"nc_def_dim");
163 if ((retval = nc_def_dim (ncid,
"nrows", t.
nrows(), &ncdims[2])))
164 ncerror (retval,
"nc_def_dim");
165 if ((retval = nc_def_dim (ncid,
"ncols", t.
ncols(), &ncdims[3])))
166 ncerror (retval,
"nc_def_dim");
167 if ((retval = nc_def_var (ncid,
"Tensor4", NC_DOUBLE, 4, &ncdims[0], &varid)))
168 ncerror (retval,
"nc_def_var");
169 if ((retval = nc_enddef (ncid))) ncerror (retval,
"nc_enddef");
170 if ((retval = nc_put_var_double (ncid, varid, t.
get_c_array())))
171 ncerror (retval,
"nc_put_var");
182 nc_read_from_file (
const int ncid,
185 Index nshelves, nbooks, npages, nrows, ncols;
186 nshelves = nc_get_dim (ncid,
"nshelves");
187 nbooks = nc_get_dim (ncid,
"nbooks");
188 npages = nc_get_dim (ncid,
"npages");
189 nrows = nc_get_dim (ncid,
"nrows");
190 ncols = nc_get_dim (ncid,
"ncols");
192 t.
resize(nshelves, nbooks, npages, nrows, ncols);
193 nc_get_data_double (ncid,
"Tensor5", t.
get_c_array());
203 nc_write_to_file (
const int ncid,
207 int ncdims[5], varid;
208 if ((retval = nc_def_dim (ncid,
"nshelves", t.
nshelves(), &ncdims[0])))
209 ncerror (retval,
"nc_def_dim");
210 if ((retval = nc_def_dim (ncid,
"nbooks", t.
nbooks(), &ncdims[1])))
211 ncerror (retval,
"nc_def_dim");
212 if ((retval = nc_def_dim (ncid,
"npages", t.
npages(), &ncdims[2])))
213 ncerror (retval,
"nc_def_dim");
214 if ((retval = nc_def_dim (ncid,
"nrows", t.
nrows(), &ncdims[3])))
215 ncerror (retval,
"nc_def_dim");
216 if ((retval = nc_def_dim (ncid,
"ncols", t.
ncols(), &ncdims[4])))
217 ncerror (retval,
"nc_def_dim");
218 if ((retval = nc_def_var (ncid,
"Tensor5", NC_DOUBLE, 5, &ncdims[0], &varid)))
219 ncerror (retval,
"nc_def_var");
220 if ((retval = nc_enddef (ncid))) ncerror (retval,
"nc_enddef");
221 if ((retval = nc_put_var_double (ncid, varid, t.
get_c_array())))
222 ncerror (retval,
"nc_put_var");
234 nc_read_from_file (
const int ncid,
238 nelem = nc_get_dim (ncid,
"nelem");
241 nc_get_data_double (ncid,
"Vector", v.
get_c_array());
251 nc_write_to_file (
const int ncid,
256 if ((retval = nc_def_dim (ncid,
"nelem", v.
nelem(), &ncdim)))
257 ncerror (retval,
"nc_def_dim");
258 if ((retval = nc_def_var (ncid,
"Vector", NC_DOUBLE, 1, &ncdim, &varid)))
259 ncerror (retval,
"nc_def_var");
260 if ((retval = nc_enddef (ncid))) ncerror (retval,
"nc_enddef");
261 if ((retval = nc_put_var_double (ncid, varid, v.
get_c_array())))
262 ncerror (retval,
"nc_put_var");
270 #define TMPL_NC_READ_WRITE_FILE_DUMMY(what) \
271 void nc_write_to_file (const int, const what&) \
273 throw runtime_error ("NetCDF support not yet implemented for this type!"); \
275 void nc_read_from_file (const int, what&) \
277 throw runtime_error ("NetCDF support not yet implemented for this type!"); \
282 TMPL_NC_READ_WRITE_FILE_DUMMY(
Index )
283 TMPL_NC_READ_WRITE_FILE_DUMMY(
Numeric )
284 TMPL_NC_READ_WRITE_FILE_DUMMY(
Sparse )
285 TMPL_NC_READ_WRITE_FILE_DUMMY(
String )
286 TMPL_NC_READ_WRITE_FILE_DUMMY(
Tensor6 )
287 TMPL_NC_READ_WRITE_FILE_DUMMY(
Tensor7 )
288 TMPL_NC_READ_WRITE_FILE_DUMMY(
Timer )
293 #undef TMPL_NC_READ_WRITE_FILE_DUMMY