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

Method BuildVarArray

IO/NetCDF/vtkNetCDFCAMReader.cxx:383–470  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

381
382//------------------------------------------------------------------------------
383void vtkNetCDFCAMReader::BuildVarArray()
384{
385 std::vector<std::set<std::string>> varsnames(VERTICAL_DIMENSION_COUNT);
386 int nvars;
387 int vars[NC_MAX_VARS];
388 if (this->Internals->nc_err(nc_inq_varids(this->Internals->nc_points, &nvars, vars)))
389 {
390 return;
391 }
392 for (int i = 0; i < nvars; i++)
393 {
394 bool showVar = false;
395 enum VerticalDimension verticalDimension = VERTICAL_DIMENSION_SINGLE_LAYER;
396 int ndims;
397 if (this->Internals->nc_err(nc_inq_varndims(this->Internals->nc_points, vars[i], &ndims)))
398 {
399 continue;
400 }
401 int dims[NC_MAX_VAR_DIMS];
402 if (this->Internals->nc_err(nc_inq_vardimid(this->Internals->nc_points, vars[i], dims)))
403 {
404 continue;
405 }
406 if (ndims == 3)
407 {
408 bool ok = true;
409 char name[NC_MAX_NAME + 1];
410 if (this->Internals->nc_err(nc_inq_dimname(this->Internals->nc_points, dims[0], name)))
411 {
412 continue;
413 }
414 ok = ok && (strcmp(name, "time") == 0);
415
416 if (this->Internals->nc_err(nc_inq_dimname(this->Internals->nc_points, dims[1], name)))
417 {
418 continue;
419 }
420 ok = ok && (strcmp(name, "lev") == 0 || strcmp(name, "ilev") == 0);
421 verticalDimension = (strcmp(name, "lev") == 0) ? VERTICAL_DIMENSION_MIDPOINT_LAYERS
422 : VERTICAL_DIMENSION_INTERFACE_LAYERS;
423
424 if (this->Internals->nc_err(nc_inq_dimname(this->Internals->nc_points, dims[2], name)))
425 {
426 continue;
427 }
428 ok = ok && (strcmp(name, "ncol") == 0);
429
430 if (ok)
431 {
432 showVar = true;
433 }
434 }
435 else if (ndims == 2)
436 {
437 bool ok = true;
438 char name[NC_MAX_NAME + 1];
439 if (this->Internals->nc_err(nc_inq_dimname(this->Internals->nc_points, dims[0], name)))
440 {

Callers 1

RequestInformationMethod · 0.95

Calls 11

nc_inq_varidsFunction · 0.85
nc_inq_varndimsFunction · 0.85
nc_inq_vardimidFunction · 0.85
nc_inq_dimnameFunction · 0.85
GetNameDimensionMethod · 0.80
EnableArrayMethod · 0.80
nc_errMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected