| 1380 | //------------------------------------------------------------------------------ |
| 1381 | |
| 1382 | int 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 | } |
nothing calls this directly
no test coverage detected