/** Read the skalar field and optionally the attribute into the values referenced by the pointers */ void operator()(ThreadParams& params, const std::string& name, T_Scalar* value, const std::string& attrName = "", T_Attribute* attribute = nullptr) { log<picLog::INPUT_OUTPUT> ("ADIOS: read %1%D scalars: %2%") % simDim % name; std::string datasetName = params.adiosBasePath + name; ADIOS_VARINFO* varInfo; ADIOS_CMD_EXPECT_NONNULL( varInfo = adios_inq_var(params.fp, datasetName.c_str()) ); if(varInfo->ndim != simDim) throw std::runtime_error(std::string("Invalid dimensionality for ") + name); if(varInfo->type != traits::PICToAdios<T_Scalar>().type) throw std::runtime_error(std::string("Invalid type for ") + name); DataSpace<simDim> gridPos = Environment<simDim>::get().GridController().getPosition(); uint64_t start[varInfo->ndim]; uint64_t count[varInfo->ndim]; for(int d = 0; d < varInfo->ndim; ++d) { /* \see adios_define_var: z,y,x in C-order */ start[d] = gridPos.revert()[d]; count[d] = 1; } ADIOS_SELECTION* fSel = adios_selection_boundingbox(varInfo->ndim, start, count); // avoid deadlock between not finished pmacc tasks and mpi calls in adios __getTransactionEvent().waitForFinished(); /* specify what we want to read, but start reading at below at `adios_perform_reads` */ /* magic parameters (0, 1): `from_step` (not used in streams), `nsteps` to read (must be 1 for stream) */ log<picLog::INPUT_OUTPUT > ("ADIOS: Schedule read skalar %1%)") % datasetName; ADIOS_CMD( adios_schedule_read(params.fp, fSel, datasetName.c_str(), 0, 1, (void*)value) ); /* start a blocking read of all scheduled variables */ ADIOS_CMD( adios_perform_reads(params.fp, 1) ); adios_selection_delete(fSel); adios_free_varinfo(varInfo); if(!attrName.empty()) { log<picLog::INPUT_OUTPUT> ("ADIOS: read attribute %1% for scalars: %2%") % attrName % name; *attribute = readAttribute<T_Attribute>(params.fp, datasetName, attrName); } }