Skip to content

Commit

Permalink
Fix build with HDF5P on (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlucf22 authored May 2, 2024
1 parent 494e46c commit 8646957
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ else() #search for HDF5
if(MGMOL_USE_HDF5P)
message(STATUS "Use HDF5 parallel capability")
set(HDF5_PREFER_PARALLEL True)
add_definitions(-DMGMOL_USE_HDF5P)
endif()
message(STATUS "HDF5_ROOT: ${HDF5_ROOT}")
find_package(HDF5 REQUIRED COMPONENTS C HL)
Expand All @@ -73,6 +72,10 @@ else() #search for HDF5
message(FATAL_ERROR "Required HDF5 package not found.")
endif (${HDF5_FOUND})
endif()
if(MGMOL_USE_HDF5P)
add_definitions(-DMGMOL_USE_HDF5P)
endif()


set(MGMOL_WITH_LIBXC FALSE CACHE BOOL "Compile with LIBXC")
if(${MGMOL_WITH_LIBXC})
Expand Down
1 change: 1 addition & 0 deletions scripts/build_condo-mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
-DCMAKE_CXX_COMPILER=mpiCC \
-DCMAKE_Fortran_COMPILER=mpif77 \
-DBLA_VENDOR=${BLAS_VENDOR} \
-DMGMOL_USE_HDF5P=OFF \
-DMGMOL_WITH_CLANG_FORMAT=ON \
-DCMAKE_PREFIX_PATH=${HOME}/bin \
-DSCALAPACK_LIBRARY="${SCALAPACK_DIR}/lib/libscalapack.a;/lib64/libgfortran.so.3" \
Expand Down
26 changes: 13 additions & 13 deletions src/Ions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ double Ions::max_Vl_radius_ = -1.;
double Ions::max_Vnl_radius_ = -1.;

template <typename T>
void writeData2d(hid_t file_id, std::string datasetname, std::vector<T>& data,
const int n, T element)
void writeData2d(HDFrestart& h5f_file, std::string datasetname,
std::vector<T>& data, const size_t n, T element)
{
hid_t file_id = h5f_file.file_id();
#ifdef MGMOL_USE_HDF5P
if (h5f_file.useHdf5p())
{
Expand All @@ -67,7 +68,7 @@ void writeData2d(hid_t file_id, std::string datasetname, std::vector<T>& data,
else
#endif
{
size_t dims[2] = { data.size()/n, n };
size_t dims[2] = { data.size() / n, n };
mgmol_tools::write2d(file_id, datasetname, data, dims);
}
}
Expand Down Expand Up @@ -753,7 +754,7 @@ void Ions::writeAtomicNumbers(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/Atomic_numbers");
writeData2d(file_id, datasetname, data, 1, -1);
writeData2d(h5f_file, datasetname, data, 1, -1);
}
}

Expand Down Expand Up @@ -788,12 +789,11 @@ void Ions::writeAtomNames(HDFrestart& h5f_file)

// write data
hid_t file_id = h5f_file.file_id();

if (file_id >= 0)
{
std::string datasetname("/Atomic_names");
std::string empty;
writeData2d(file_id, datasetname, data, 1, empty);
writeData2d(h5f_file, datasetname, data, 1, empty);
}
}

Expand Down Expand Up @@ -864,7 +864,7 @@ void Ions::writeLockedAtomNames(HDFrestart& h5f_file)
{
std::string datasetname("/LockedAtomsNames");
std::string empty;
writeData2d(file_id, datasetname, data, 1, empty);
writeData2d(h5f_file, datasetname, data, 1, empty);
}
}

Expand Down Expand Up @@ -900,7 +900,7 @@ void Ions::writeAtomicIDs(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/Atomic_IDs");
writeData2d(file_id, datasetname, data, 1, -1);
writeData2d(h5f_file, datasetname, data, 1, -1);
}
}

Expand Down Expand Up @@ -937,7 +937,7 @@ void Ions::writeAtomicNLprojIDs(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/AtomicNLproj_IDs");
writeData2d(file_id, datasetname, data, 1, -1);
writeData2d(h5f_file, datasetname, data, 1, -1);
}
}

Expand Down Expand Up @@ -975,7 +975,7 @@ void Ions::writePositions(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/Ionic_positions");
writeData2d(file_id, datasetname, data, 3, 1.e32);
writeData2d(h5f_file, datasetname, data, 3, 1.e32);
}
}

Expand Down Expand Up @@ -1138,7 +1138,7 @@ void Ions::writeVelocities(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/Ionic_velocities");
writeData2d(file_id, datasetname, data, 3, 1.e32);
writeData2d(h5f_file, datasetname, data, 3, 1.e32);
}
}

Expand Down Expand Up @@ -1184,7 +1184,7 @@ void Ions::writeRandomStates(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/Ionic_RandomStates");
writeData2d(file_id, datasetname, data, 3, (unsigned short)0);
writeData2d(h5f_file, datasetname, data, 3, (unsigned short)0);
}
}

Expand Down Expand Up @@ -1343,7 +1343,7 @@ void Ions::writeForces(HDFrestart& h5f_file)
if (file_id >= 0)
{
std::string datasetname("/Ionic_forces");
writeData2d(file_id, datasetname, data, 3, 1.e32);
writeData2d(h5f_file, datasetname, data, 3, 1.e32);
}
}

Expand Down

0 comments on commit 8646957

Please sign in to comment.