@@ -2293,7 +2293,7 @@ void Component::write_HDF5(HighFive::Group& group, bool masses, bool IDs)
22932293 auto dcplI = HighFive::DataSetCreateProps{};
22942294 auto dcplD = HighFive::DataSetCreateProps{};
22952295
2296- if (H5compress) {
2296+ if (H5compress or H5chunk ) {
22972297 int chunk = H5chunk;
22982298
22992299 // Sanity
@@ -2349,20 +2349,23 @@ template
23492349void Component::write_HDF5<double >
23502350(HighFive::Group& group, bool masses, bool IDs);
23512351
2352- // Helper structure
2352+ // Helper structure for reading and writing the HDF5 compound data
2353+ // type. Used by Component and ParticleReader.
23532354template <typename T>
23542355struct H5Particle
23552356{
23562357 unsigned long id;
23572358 T mass;
23582359 T pos[3 ];
23592360 T vel[3 ];
2360- hvl_t iattrib;
2361- hvl_t dattrib;
2361+ T pot;
2362+ T potext;
2363+ hvl_t iattrib; // HDF5 variable length
2364+ hvl_t dattrib; // HDF5 variable length
23622365};
23632366
2364-
2365- // ! Write HDF5 phase-space structure for this nodes particles only.
2367+ // Write HDF5 phase-space structure for this nodes particles only in
2368+ // PSP style
23662369template <typename T>
23672370void Component::write_H5 (H5::Group& group)
23682371{
@@ -2385,8 +2388,10 @@ void Component::write_H5(H5::Group& group)
23852388 hsize_t dims3[1 ] = {3 };
23862389 H5::ArrayType array3_type (type, 1 , dims3);
23872390
2388- compound_type.insertMember (" pos" , HOFFSET (H5Particle<T>, pos), array3_type);
2389- compound_type.insertMember (" vel" , HOFFSET (H5Particle<T>, vel), array3_type);
2391+ compound_type.insertMember (" pos" , HOFFSET (H5Particle<T>, pos ), array3_type);
2392+ compound_type.insertMember (" vel" , HOFFSET (H5Particle<T>, vel ), array3_type);
2393+ compound_type.insertMember (" pot" , HOFFSET (H5Particle<T>, pot ), type);
2394+ compound_type.insertMember (" potext" , HOFFSET (H5Particle<T>, potext), type);
23902395 compound_type.insertMember (" iattrib" , HOFFSET (H5Particle<T>, iattrib), H5::VarLenType (H5::PredType::NATIVE_INT));
23912396 compound_type.insertMember (" dattrib" , HOFFSET (H5Particle<T>, dattrib), H5::VarLenType (type));
23922397
@@ -2407,18 +2412,20 @@ void Component::write_H5(H5::Group& group)
24072412 h5_particles[n].pos [k] = P->pos [k];
24082413 h5_particles[n].vel [k] = P->vel [k];
24092414 }
2415+ h5_particles[n].pot = P->pot ;
2416+ h5_particles[n].potext = P->potext ;
24102417 h5_particles[n].iattrib .len = P->iattrib .size ();
24112418 h5_particles[n].dattrib .len = P->dattrib .size ();
24122419 h5_particles[n].iattrib .p = P->iattrib .data ();
24132420 h5_particles[n].dattrib .p = P->dattrib .data ();
24142421 }
24152422
2416- // Set properties, if requested
2423+ // Set properties, if requested for chunking and compression
24172424 H5::DSetCreatPropList dcpl;
24182425
24192426 // This could be generalized by registering a user filter, like
24202427 // blosc. Right now, we're using the default (which is gzip)
2421- if (H5compress) {
2428+ if (H5compress or H5chunk ) {
24222429 int chunk = H5chunk;
24232430
24242431 // Sanity
0 commit comments