diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp b/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp index 002633fb5f..e46bde7ebf 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.cpp @@ -933,9 +933,9 @@ void HDF5Common::AddNonStringAttribute(core::IO &io, } else { - T val[arraySize]; - H5Aread(attrId, h5Type, val); - io.DefineAttribute(attrName, val, arraySize); + std::vector val(arraySize); + H5Aread(attrId, h5Type, val.data()); + io.DefineAttribute(attrName, val.data(), arraySize); } } diff --git a/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc b/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc index 4aa723980f..b6634e1666 100644 --- a/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc +++ b/source/adios2/toolkit/interop/hdf5/HDF5Common.tcc @@ -208,7 +208,7 @@ void HDF5Common::AddBlockInfo(const core::Variable &variable, hid_t parentId) H5Dcreate(parentId, blockInfo_name.c_str(), H5T_NATIVE_HSIZE, metaSpace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - size_t blocks[dimSize * 2]; + std::vector blocks(dimSize * 2); for (int i = 0; i < dimSize; i++) { blocks[i + dimSize] = variable.m_Count[i]; @@ -223,7 +223,7 @@ void HDF5Common::AddBlockInfo(const core::Variable &variable, hid_t parentId) metaCount, NULL); H5Dwrite(metaId, H5T_NATIVE_HSIZE, metaLocal_id, metaSpace_id, - m_PropertyTxfID, blocks); + m_PropertyTxfID, blocks.data()); H5Sclose(metaLocal_id); H5Sclose(metaSpace_id); diff --git a/source/utils/adios_iotest/hdf5Stream.cpp b/source/utils/adios_iotest/hdf5Stream.cpp index 8b12dcdd13..e684e15d6a 100644 --- a/source/utils/adios_iotest/hdf5Stream.cpp +++ b/source/utils/adios_iotest/hdf5Stream.cpp @@ -13,6 +13,7 @@ #include #include #include +#include hdf5Stream::hdf5Stream(const std::string &streamName, const adios2::Mode mode, MPI_Comm comm) @@ -80,9 +81,9 @@ hid_t hdf5Stream::hdf5Type(std::string &type) void hdf5Stream::defineHDF5Array(const std::shared_ptr ov) { const int ndim = ov->ndim + 1; - hsize_t maxdims[ndim]; - hsize_t dims[ndim]; - hsize_t count[ndim]; + std::vector maxdims(ndim); + std::vector dims(ndim); + std::vector count(ndim); maxdims[0] = H5S_UNLIMITED; dims[0] = 1; @@ -94,14 +95,14 @@ void hdf5Stream::defineHDF5Array(const std::shared_ptr ov) count[d] = ov->count[d - 1]; } - hid_t dataspace = H5Screate_simple(ndim, dims, maxdims); + hid_t dataspace = H5Screate_simple(ndim, dims.data(), maxdims.data()); hid_t cparms; /* * Set chunking, the only way to have extendible arrays */ cparms = H5Pcreate(H5P_DATASET_CREATE); - H5Pset_chunk(cparms, ndim, count); + H5Pset_chunk(cparms, ndim, count.data()); hid_t dataset; dataset = H5Dcreate2(h5file, ov->name.c_str(), hdf5Type(ov->type), @@ -117,9 +118,9 @@ void hdf5Stream::putHDF5Array(const std::shared_ptr ov, const auto it = varmap.find(ov->name); hdf5VarInfo &vi = it->second; int ndim = ov->ndim + 1; - hsize_t start[ndim]; - hsize_t count[ndim]; - hsize_t dims[ndim]; + std::vector start(ndim); + std::vector count(ndim); + std::vector dims(ndim); start[0] = step - 1; count[0] = 1; dims[0] = step; @@ -130,12 +131,13 @@ void hdf5Stream::putHDF5Array(const std::shared_ptr ov, dims[d] = ov->shape[d - 1]; } - H5Dset_extent(vi.dataset, dims); + H5Dset_extent(vi.dataset, dims.data()); hid_t filespace = H5Dget_space(vi.dataset); - H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL); + H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start.data(), NULL, + count.data(), NULL); hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER); H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE); - hid_t memspace = H5Screate_simple(ndim, count, NULL); + hid_t memspace = H5Screate_simple(ndim, count.data(), NULL); H5Dwrite(vi.dataset, hdf5Type(ov->type), memspace, filespace, dxpl_id, ov->data.data()); H5Pclose(dxpl_id); @@ -256,8 +258,8 @@ void hdf5Stream::getHDF5Array(std::shared_ptr ov, size_t step) } int ndim = ov->ndim + 1; - hsize_t start[ndim]; - hsize_t count[ndim]; + std::vector start(ndim); + std::vector count(ndim); start[0] = step - 1; count[0] = 1; for (int d = 1; d < ndim; ++d) @@ -272,10 +274,11 @@ void hdf5Stream::getHDF5Array(std::shared_ptr ov, size_t step) ov->data.resize(ov->datasize); } - hid_t memspace = H5Screate_simple(ndim, count, NULL); + hid_t memspace = H5Screate_simple(ndim, count.data(), NULL); hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER); H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE); - H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL); + H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start.data(), NULL, + count.data(), NULL); void *buf = reinterpret_cast(ov->data.data()); H5Dread(dataset, hdf5Type(ov->type), memspace, filespace, dxpl_id, buf); @@ -317,9 +320,9 @@ adios2::StepStatus hdf5Stream::Read(CommandRead *cmdR, Config &cfg, std::shared_ptr var = cmdR->variables.front(); hid_t dataset = H5Dopen2(h5file, var->name.c_str(), H5P_DEFAULT); hid_t filespace = H5Dget_space(dataset); - hsize_t dims[var->ndim + 1]; + std::vector dims(var->ndim + 1); int ndim = H5Sget_simple_extent_ndims(filespace); - H5Sget_simple_extent_dims(filespace, dims, NULL); + H5Sget_simple_extent_dims(filespace, dims.data(), NULL); /* ndim == var->ndim+1 */ nSteps = dims[0]; if (!settings.myRank && settings.verbose)