Skip to content

Commit

Permalink
Set to never write fill values to the dataset for HDF5 output (#2450)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtnfld authored Oct 30, 2021
1 parent 6e97881 commit 2cfe835
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
17 changes: 11 additions & 6 deletions Src/Base/AMReX_PlotFileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,10 @@ void WriteMultiLevelPlotfileHDF5 (const std::string& plotfilename,

// Write data for each level
char level_name[32];

hid_t dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_NEVER);

for (int level = 0; level <= finest_level; ++level) {
sprintf(level_name, "level_%d", level);
#ifdef AMREX_USE_HDF5_ASYNC
Expand All @@ -1007,9 +1011,9 @@ void WriteMultiLevelPlotfileHDF5 (const std::string& plotfilename,
boxdataspace = H5Screate_simple(1, flatdims, NULL);

#ifdef AMREX_USE_HDF5_ASYNC
boxdataset = H5Dcreate_async(grp, bdsname.c_str(), babox_id, boxdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, es_id_g);
boxdataset = H5Dcreate_async(grp, bdsname.c_str(), babox_id, boxdataspace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT, es_id_g);
#else
boxdataset = H5Dcreate(grp, bdsname.c_str(), babox_id, boxdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
boxdataset = H5Dcreate(grp, bdsname.c_str(), babox_id, boxdataspace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
#endif
if (boxdataset < 0) { std::cout << "H5Dcreate [" << bdsname << "] failed!" << std::endl; break; }

Expand Down Expand Up @@ -1037,19 +1041,19 @@ void WriteMultiLevelPlotfileHDF5 (const std::string& plotfilename,
oflatdims[0] = sortedGrids.size() + 1;
offsetdataspace = H5Screate_simple(1, oflatdims, NULL);
#ifdef AMREX_USE_HDF5_ASYNC
offsetdataset = H5Dcreate_async(grp, odsname.c_str(), H5T_NATIVE_LLONG, offsetdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, es_id_g);
offsetdataset = H5Dcreate_async(grp, odsname.c_str(), H5T_NATIVE_LLONG, offsetdataspace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT, es_id_g);
#else
offsetdataset = H5Dcreate(grp, odsname.c_str(), H5T_NATIVE_LLONG, offsetdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
offsetdataset = H5Dcreate(grp, odsname.c_str(), H5T_NATIVE_LLONG, offsetdataspace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
#endif
if(offsetdataset < 0) { std::cout << "create offset dataset failed! ret = " << offsetdataset << std::endl; break;}

hsize_t centerdims[1];
centerdims[0] = sortedGrids.size() ;
centerdataspace = H5Screate_simple(1, centerdims, NULL);
#ifdef AMREX_USE_HDF5_ASYNC
centerdataset = H5Dcreate_async(grp, centername.c_str(), center_id, centerdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT, es_id_g);
centerdataset = H5Dcreate_async(grp, centername.c_str(), center_id, centerdataspace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT, es_id_g);
#else
centerdataset = H5Dcreate(grp, centername.c_str(), center_id, centerdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
centerdataset = H5Dcreate(grp, centername.c_str(), center_id, centerdataspace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
#endif
if(centerdataset < 0) { std::cout << "Create center dataset failed! ret = " << centerdataset << std::endl; break;}

Expand Down Expand Up @@ -1198,6 +1202,7 @@ void WriteMultiLevelPlotfileHDF5 (const std::string& plotfilename,
H5Tclose(center_id);
H5Tclose(babox_id);
H5Pclose(fapl);
H5Pclose(dcpl_id);
H5Pclose(dxpl_col);
H5Pclose(dxpl_ind);
H5Pclose(dcpl);
Expand Down
10 changes: 8 additions & 2 deletions Src/Particle/AMReX_WriteBinaryParticleData.H
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,10 @@ void WriteHDF5ParticleDataSync (PC const& pc,

char level_name[128];
int ngrids;

hid_t dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_NEVER);

for (int lev = 0; lev <= finest_level; ++lev) {
sprintf(level_name, "level_%d", lev);

Expand All @@ -1313,7 +1317,9 @@ void WriteHDF5ParticleDataSync (PC const& pc,
hsize_t mfs_dim = (hsize_t)ngrids;

hid_t mfs_dset_space = H5Screate_simple(1, &mfs_dim, NULL);
hid_t mfs_dset= H5Dcreate(grp, "boxes", comp_dtype, mfs_dset_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);


hid_t mfs_dset= H5Dcreate(grp, "boxes", comp_dtype, mfs_dset_space, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);

Vector<int> vbox(ngrids * mfs_size);
for(int j = 0; j < pc.ParticleBoxArray(lev).size(); ++j) {
Expand All @@ -1334,7 +1340,7 @@ void WriteHDF5ParticleDataSync (PC const& pc,

H5Gclose(grp);
}

H5Pclose(dcpl_id);
H5Fclose(fid);
}

Expand Down

0 comments on commit 2cfe835

Please sign in to comment.