------------------------------------------------------------------------------ RequestInformation supplies global meta information This should return the reality of what the reader is going to supply. This retrieve the extents for the rectilinear grid NC_MAX_VAR_DIMS comes from the nc library
| 150 | // This retrieve the extents for the rectilinear grid |
| 151 | // NC_MAX_VAR_DIMS comes from the nc library |
| 152 | int vtkPNetCDFPOPReader::RequestInformation(vtkInformation* vtkNotUsed(request), |
| 153 | vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) |
| 154 | { |
| 155 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 156 | if (this->FileName == nullptr) |
| 157 | { |
| 158 | vtkErrorMacro("FileName not set."); |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | // every rank that is a reader process needs to open the file |
| 163 | if (this->IsReaderRank()) |
| 164 | { |
| 165 | |
| 166 | if (this->OpenedFileName) |
| 167 | { |
| 168 | nc_close(this->NCDFFD); |
| 169 | } |
| 170 | int retval = nc_open(this->FileName, NC_NOWRITE, &this->NCDFFD); // read file |
| 171 | if (retval != NC_NOERR) // checks if read file error |
| 172 | { |
| 173 | vtkErrorMacro(<< "Can't read file " << nc_strerror(retval)); |
| 174 | this->SetOpenedFileName(nullptr); |
| 175 | return 0; |
| 176 | } |
| 177 | this->SetOpenedFileName(this->FileName); |
| 178 | } |
| 179 | // first reader reads the metadata and broadcasts it to everyone else |
| 180 | int extent[6]; |
| 181 | char variableName[NC_MAX_NAME + 1]; |
| 182 | if (this->IsFirstReaderRank()) |
| 183 | { |
| 184 | // get number of variables from file |
| 185 | int numberOfVariables; |
| 186 | nc_inq_nvars(this->NCDFFD, &numberOfVariables); |
| 187 | int dimidsp[NC_MAX_VAR_DIMS]; |
| 188 | int dataDimension; |
| 189 | size_t dimensions[4]; // dimension value |
| 190 | this->Internals->VariableMap.resize(numberOfVariables); |
| 191 | int actualVariableCounter = 0; |
| 192 | // For every variable in the file |
| 193 | for (int i = 0; i < numberOfVariables; i++) |
| 194 | { |
| 195 | this->Internals->VariableMap[i] = -1; |
| 196 | // get number of dimensions |
| 197 | CALL_NETCDF_INT(nc_inq_varndims(this->NCDFFD, i, &dataDimension)); |
| 198 | // Variable Dimension ID's containing x,y,z coords for the rectilinear |
| 199 | // grid spacing |
| 200 | CALL_NETCDF_INT(nc_inq_vardimid(this->NCDFFD, i, dimidsp)); |
| 201 | if (dataDimension == 3) |
| 202 | { |
| 203 | this->Internals->VariableMap[i] = actualVariableCounter++; |
| 204 | // get variable name |
| 205 | CALL_NETCDF_INT(nc_inq_varname(this->NCDFFD, i, variableName)); |
| 206 | this->Internals->VariableArraySelection->AddArray(variableName); |
| 207 | for (int m = 0; m < dataDimension; m++) |
| 208 | { |
| 209 | CALL_NETCDF_INT(nc_inq_dimlen(this->NCDFFD, dimidsp[m], dimensions + m)); |
nothing calls this directly
no test coverage detected