Push compatibility to HDF5 1.12

This commit is contained in:
Guilhem Lavaux 2022-08-17 08:57:52 +03:00
parent 31d0f19408
commit f03751907b

View File

@ -7,16 +7,16 @@ This software is a computer program whose purpose is to provide a toolbox for co
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
@ -25,9 +25,9 @@ that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
@ -59,8 +59,8 @@ int ipvz_out = 5;
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
/* n*_runtime_parameters should be set by the caller to
the maximum number of runtime parameters to read.
/* n*_runtime_parameters should be set by the caller to
the maximum number of runtime parameters to read.
*/
void h5_read_runtime_parameters
@ -100,12 +100,12 @@ void h5_read_runtime_parameters
nreal_runtime_parameters = MAX_PARM;
/* integer runtime parameters */
int_rt_parms = (int_runtime_params_t *) malloc(nint_runtime_parameters * sizeof(int_runtime_params_t));
int_rt_parms = (int_runtime_params_t *) malloc(nint_runtime_parameters * sizeof(int_runtime_params_t));
rank = 1;
DataSet dataset = file->openDataSet("integer runtime parameters");
IntType int_rt_type = dataset.getIntType();
IntType int_rt_type = dataset.getIntType();
//int_rt_type = H5Dget_type(dataset);
DataSpace dataspace = dataset.getSpace();
@ -123,10 +123,7 @@ void h5_read_runtime_parameters
DataSpace memspace(rank, &dimens_1d);
//memspace = H5Screate_simple(rank, &dimens_1d, NULL);
dataset.read(int_rt_parms, int_rt_type, memspace, dataspace,
H5P_DEFAULT);
//status = H5Dread(dataset, int_rt_type, memspace, dataspace,
// H5P_DEFAULT, int_rt_parms);
dataset.read(int_rt_parms, int_rt_type, memspace, dataspace);
for (i = 0; i < nint_runtime_parameters; i++) {
@ -145,14 +142,14 @@ void h5_read_runtime_parameters
/* reals */
real_rt_parms = (real_runtime_params_t *) malloc(nreal_runtime_parameters * sizeof(real_runtime_params_t));
real_rt_parms = (real_runtime_params_t *) malloc(nreal_runtime_parameters * sizeof(real_runtime_params_t));
rank = 1;
dataset = file->openDataSet("real runtime parameters");
//dataset = H5Dopen(*file_identifier, "real runtime parameters");
//dataset = H5Dopen(*file_identifier, "real runtime parameters");
dataspace = dataset.getSpace();
FloatType real_rt_type = dataset.getFloatType();
FloatType real_rt_type = dataset.getFloatType();
ndims = dataspace.getSimpleExtentDims(&dimens_1d, NULL);
//dataspace = H5Dget_space(dataset);
//real_rt_type = H5Dget_type(dataset);
@ -167,10 +164,7 @@ void h5_read_runtime_parameters
memspace = DataSpace(rank, &dimens_1d);
//memspace = H5Screate_simple(rank, &dimens_1d, NULL);
dataset.read(real_rt_parms, real_rt_type, memspace, dataspace,
H5P_DEFAULT);
//status = H5Dread(dataset, real_rt_type, memspace, dataspace,
// H5P_DEFAULT, real_rt_parms);
dataset.read(real_rt_parms, real_rt_type, memspace, dataspace);
for (i = 0; i < nreal_runtime_parameters; i++) {
@ -193,7 +187,7 @@ void h5_read_runtime_parameters
*LBox = real_runtime_parameter_values[i];
}
if (strncmp(real_runtime_parameter_names[i],"hubbleconstant", 14) == 0 ) {
*hubble = real_runtime_parameter_values[i];
*hubble = real_runtime_parameter_values[i];
}
if (strncmp(real_runtime_parameter_names[i],"omegamatter", 11) == 0 ) {
*omegam = real_runtime_parameter_values[i];
@ -205,7 +199,7 @@ void h5_read_runtime_parameters
*omegalambda = real_runtime_parameter_values[i];
}
}
for (i = 0; i < nint_runtime_parameters; i++) {
if (strncmp(int_runtime_parameter_names[i],"pt_numx",7) == 0 ) {
*numPart = int_runtime_parameter_values[i];
@ -214,7 +208,7 @@ void h5_read_runtime_parameters
}
}
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
void h5_read_flash3_particles (H5File* file,
int* totalparticles,
@ -241,8 +235,8 @@ void h5_read_flash3_particles (H5File* file,
char *propName;
double *partBuffer;
char part_names[50][OUTPUT_PROP_LENGTH];
int string_size;
int string_size;
// char part_names[NPART_PROPS][OUTPUT_PROP_LENGTH];
hsize_t dimens_2d[2], maxdimens_2d[2];
hsize_t start_2d[2], count_2d[2], stride_2d[2];
@ -265,12 +259,12 @@ void h5_read_flash3_particles (H5File* file,
//total number of particle properties
numProps = dimens_2d[0];
string_size = OUTPUT_PROP_LENGTH;
StrType string_type = H5Tcopy(H5T_C_S1);
string_type.setSize(string_size);
//status = H5Tset_size(string_type, string_size);
rank = 2;
start_2d[0] = 0;
@ -282,22 +276,20 @@ void h5_read_flash3_particles (H5File* file,
count_2d[0] = dimens_2d[0];
count_2d[1] = dimens_2d[1];
dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d);
dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d);
//status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d,
// stride_2d, count_2d, NULL);
DataSpace memspace(rank, dimens_2d);
//memspace = H5Screate_simple(rank, dimens_2d, NULL);
dataset.read(part_names, string_type, H5S_ALL, H5S_ALL, H5P_DEFAULT);
//status = H5Dread(dataset, string_type, H5S_ALL, H5S_ALL,
// H5P_DEFAULT, part_names);
dataset.read(part_names, string_type);
string_type.close();
memspace.close();
dataspace.close();
dataset.close();
dataset.close();
//H5Tclose(string_type);
//H5Sclose(memspace);
//H5Sclose(dataspace);
@ -313,7 +305,7 @@ void h5_read_flash3_particles (H5File* file,
if (strncmp(part_names[i], "velz", 4) == 0) { ipvz = i+1; }
}
if ((iptag < 0) || (ipx < 0) || (ipy < 0) || (ipz < 0) || (ipvx < 0) ||
if ((iptag < 0) || (ipx < 0) || (ipy < 0) || (ipz < 0) || (ipvx < 0) ||
(ipvy < 0) || (ipvz < 0) ) {
printf("One or more required particle attributes not found in file!\n");
return;
@ -325,7 +317,7 @@ void h5_read_flash3_particles (H5File* file,
//read particles
dataset = file->openDataSet("tracer particles");
//dataset = H5Dopen(*file_identifier, "tracer particles");
FloatType datatype = dataset.getFloatType();
//datatype = H5Dget_type(dataset);
@ -338,7 +330,7 @@ void h5_read_flash3_particles (H5File* file,
ndims = dataspace.getSimpleExtentDims(dimens_2d, NULL);
//dataspace = H5Dget_space(dataset);
//H5Sget_simple_extent_dims(dataspace, dimens_2d, maxdimens_2d);
/*insert particle properties (numPartBuffer) particles at a time*/
pstack = (*localnp);
poffset = 0;
@ -366,7 +358,7 @@ void h5_read_flash3_particles (H5File* file,
dimens_2d[0] = (pcount);
dimens_2d[1] = (numProps);
dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d);
dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d);
//status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d,
// stride_2d, count_2d, NULL);
@ -374,8 +366,7 @@ void h5_read_flash3_particles (H5File* file,
//memspace = H5Screate_simple(rank, dimens_2d, maxdimens_2d);
/* read data from the dataset */
dataset.read(partBuffer, datatype, memspace, dataspace, H5P_DEFAULT);
//status = H5Dread(dataset, datatype, memspace, dataspace, H5P_DEFAULT, partBuffer);
dataset.read(partBuffer, datatype, memspace, dataspace);
/* convert buffer into particle struct */
@ -391,8 +382,8 @@ void h5_read_flash3_particles (H5File* file,
pos3[p+poffset] = (float) *(partBuffer+ipz-1+p*numProps);
}
}
if (vel1 && vel2 && vel3) {
for(p=0; p < (pcount); p++) {
vel1[p+poffset] = (float) *(partBuffer+ipvx-1+p*numProps);
@ -423,7 +414,7 @@ void h5_read_flash3_particles (H5File* file,
//status = H5Sclose(dataspace);
//status = H5Dclose(dataset);
}
/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
@ -451,7 +442,7 @@ void h5_read_flash3_header_info(H5File* file,
H5std_string DATASET_NAME;
string_type = H5Tcopy(H5T_C_S1);
string_type = H5Tcopy(H5T_C_S1);
H5Tset_size(string_type, MAX_STRING_LENGTH);
DataSet dataset = file->openDataSet("real scalars");
@ -467,13 +458,13 @@ void h5_read_flash3_header_info(H5File* file,
/* malloc a pointer to a list of real_list_t's */
real_list = (real_list_t *) malloc(dimens_1d * sizeof(real_list_t));
// create a new simple dataspace of 1 dimension and size of 'dimens_1d'
// create a new simple dataspace of 1 dimension and size of 'dimens_1d'
DataSpace memspace(1, &dimens_1d);
// create an empty vessel sized to hold one real_list_t's worth of data
// create an empty vessel sized to hold one real_list_t's worth of data
CompType real_list_type( sizeof(real_list_t) );
// subdivide the empty vessel into its component sections (name and value)
// subdivide the empty vessel into its component sections (name and value)
real_list_type.insertMember(
"name",
HOFFSET(real_list_t, name),
@ -484,9 +475,8 @@ void h5_read_flash3_header_info(H5File* file,
HOFFSET(real_list_t, value),
PredType::NATIVE_DOUBLE);
// read the data into 'real_list'
dataset.read( real_list, real_list_type, memspace, dataspace,
H5P_DEFAULT);
// read the data into 'real_list'
dataset.read( real_list, real_list_type, memspace, dataspace);
if (status < 0) {