------------------------------------------------------------------------------
| 321 | |
| 322 | //------------------------------------------------------------------------------ |
| 323 | bool vtkADIOS2CoreImageReader::OpenAndReadMetaData() |
| 324 | { |
| 325 | // Is name valid |
| 326 | if (!this->CanReadFile(this->FileName)) |
| 327 | { |
| 328 | vtkErrorMacro("cannot read file" << this->FileName); |
| 329 | return false; |
| 330 | } |
| 331 | |
| 332 | // Initialize the ADIOS2 data structures |
| 333 | if (!this->Impl->Adios) |
| 334 | { |
| 335 | #if VTK_MODULE_ENABLE_VTK_ParallelMPI |
| 336 | // Make sure the ADIOS subsystem is initialized before processing any |
| 337 | // sort of request. |
| 338 | if (!this->Controller) |
| 339 | { |
| 340 | vtkErrorMacro("The reader is built with MPI support but the application is not launched in " |
| 341 | "parallel mode. Abort reading."); |
| 342 | return false; |
| 343 | } |
| 344 | vtkMPICommunicator* comm = |
| 345 | static_cast<vtkMPICommunicator*>(this->Controller->GetCommunicator()); |
| 346 | |
| 347 | this->Impl->Adios.reset(new adios2::ADIOS(*comm->GetMPIComm()->GetHandle())); |
| 348 | #else |
| 349 | // Make sure the ADIOS subsystem is initialized before processing any |
| 350 | // sort of request. |
| 351 | |
| 352 | this->Impl->Adios.reset(new adios2::ADIOS()); |
| 353 | // Before processing any request, read the meta data first |
| 354 | #endif |
| 355 | } |
| 356 | // Before processing any request, read the meta data first |
| 357 | try |
| 358 | { |
| 359 | #if IOADIOS2_BP5_RANDOM_ACCESS |
| 360 | auto mode = adios2::Mode::ReadRandomAccess; |
| 361 | #else |
| 362 | auto mode = adios2::Mode::Read; |
| 363 | #endif |
| 364 | this->Impl->AdiosIO = this->Impl->Adios->DeclareIO("vtkADIOS2ImageRead"); |
| 365 | if (vtksys::SystemTools::StringEndsWith(this->FileName, ".bp") || |
| 366 | vtksys::SystemTools::StringEndsWith(this->FileName, ".bp4") || |
| 367 | vtksys::SystemTools::StringEndsWith(this->FileName, ".bp5")) |
| 368 | { |
| 369 | this->Impl->AdiosIO.SetEngine("BPFile"); |
| 370 | this->Impl->BpReader = this->Impl->AdiosIO.Open(this->FileName, mode); |
| 371 | } |
| 372 | else if (vtksys::SystemTools::StringEndsWith(this->FileName, "md.idx")) |
| 373 | { |
| 374 | this->Impl->AdiosIO.SetEngine("BP4"); |
| 375 | this->Impl->BpReader = |
| 376 | this->Impl->AdiosIO.Open(this->FileName.substr(0, this->FileName.size() - 6), mode); |
| 377 | } |
| 378 | else |
| 379 | { |
| 380 | throw std::runtime_error("Unsupported file extension"); |
no test coverage detected