MCPcopy Create free account
hub / github.com/Kitware/VTK / dimensionedArrayName

Method dimensionedArrayName

IO/NetCDF/vtkMPASReader.cxx:241–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241std::string vtkMPASReader::Internal::dimensionedArrayName(int nc_var) const
242{
243 char name[NC_MAX_NAME + 1];
244 if (nc_err(nc_inq_varname(ncFile, nc_var, name)))
245 {
246 return "";
247 }
248
249 int ndims;
250 if (nc_err(nc_inq_varndims(ncFile, nc_var, &ndims)))
251 {
252 return "";
253 }
254 int dims[NC_MAX_VAR_DIMS];
255 if (nc_err(nc_inq_vardimid(ncFile, nc_var, dims)))
256 {
257 return "";
258 }
259
260 std::ostringstream out;
261 out << name << "(";
262
263 for (int dim = 0; dim < ndims; ++dim)
264 {
265 if (dim != 0)
266 {
267 out << ", ";
268 }
269
270 if (nc_err(nc_inq_dimname(ncFile, dims[dim], name)))
271 {
272 return "";
273 }
274 out << name;
275 }
276 out << ")";
277 return out.str();
278}
279
280//------------------------------------------------------------------------------
281// Returns true if the dimensions in var match the expected args, or prints a

Callers 1

BuildVarArraysMethod · 0.80

Calls 5

nc_inq_varnameFunction · 0.85
nc_inq_varndimsFunction · 0.85
nc_inq_vardimidFunction · 0.85
nc_inq_dimnameFunction · 0.85
strMethod · 0.45

Tested by

no test coverage detected