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

Method GetNcVars

IO/NetCDF/vtkMPASReader.cxx:1382–1473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1380//------------------------------------------------------------------------------
1381
1382int vtkMPASReader::GetNcVars(const char* cellDimName, const char* pointDimName)
1383{
1384 this->Internals->pointArrays.clear();
1385 this->Internals->pointVars.clear();
1386 this->Internals->cellArrays.clear();
1387 this->Internals->cellVars.clear();
1388
1389 int numVars;
1390 int vars[NC_MAX_VARS];
1391 if (this->Internals->nc_err(nc_inq_varids(this->Internals->ncFile, &numVars, vars)))
1392 {
1393 return 0;
1394 }
1395 for (int i = 0; i < numVars; i++)
1396 {
1397 // Variables must have the following dimension specification:
1398 // [Time, ] (nCells | nVertices), [arbitraryDim1, [arbitraryDim2, [...]]]
1399
1400 bool isPointData = false;
1401 bool isCellData = false;
1402 int numDims;
1403 if (this->Internals->nc_err(nc_inq_varndims(this->Internals->ncFile, vars[i], &numDims)))
1404 {
1405 continue;
1406 }
1407
1408 if (numDims < 1)
1409 {
1410 char name[NC_MAX_NAME + 1];
1411 if (this->Internals->nc_err(nc_inq_varname(this->Internals->ncFile, vars[i], name)))
1412 {
1413 continue;
1414 }
1415 vtkWarningMacro(<< "Variable '" << name << "' has invalid number of dimensions: " << numDims);
1416 continue;
1417 }
1418 int dims[NC_MAX_VAR_DIMS];
1419 if (this->Internals->nc_err(nc_inq_vardimid(this->Internals->ncFile, vars[i], dims)))
1420 {
1421 continue;
1422 }
1423
1424 std::vector<std::string> dimNames;
1425 bool ok = true;
1426 for (int dim = 0; dim < std::min(numDims, 2); ++dim)
1427 {
1428 char name[NC_MAX_NAME + 1];
1429 if (this->Internals->nc_err(nc_inq_dimname(this->Internals->ncFile, dims[dim], name)))
1430 {
1431 ok = false;
1432 break;
1433 }
1434 dimNames.emplace_back(name);
1435 }
1436 if (!ok)
1437 {
1438 continue;
1439 }

Callers

nothing calls this directly

Calls 11

nc_inq_varidsFunction · 0.85
nc_inq_varndimsFunction · 0.85
nc_inq_varnameFunction · 0.85
nc_inq_vardimidFunction · 0.85
nc_inq_dimnameFunction · 0.85
minFunction · 0.50
clearMethod · 0.45
nc_errMethod · 0.45
emplace_backMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected