diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aa64b8..f981cc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## latest +- Bugfix: mem-leak while reading microstructure and added wider CMake support [#140](https://github.com/DataAnalyticsEngineering/FANS/pull/140) - Added MPI communicator abstraction [#139](https://github.com/DataAnalyticsEngineering/FANS/pull/139) ## v0.6.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a9f5c2..fa9c3fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ target_compile_definitions(FANS_FANS PUBLIC ${FFTW3_DEFINITIONS}) target_link_libraries(FANS_FANS PUBLIC Eigen3::Eigen) target_link_libraries(FANS_FANS PUBLIC nlohmann_json::nlohmann_json) -target_include_directories(FANS_main PRIVATE ${HDF5_INCLUDE_DIRS}) +target_include_directories(FANS_main PRIVATE ${HDF5_INCLUDE_DIRS} ${FFTW3_INCLUDE_DIRS}) target_link_libraries(FANS_main PRIVATE FANS::FANS) # ############################################################################## diff --git a/cmake/modules/FindFFTW3.cmake b/cmake/modules/FindFFTW3.cmake index 7542691..c4b22f7 100644 --- a/cmake/modules/FindFFTW3.cmake +++ b/cmake/modules/FindFFTW3.cmake @@ -72,11 +72,15 @@ macro(find_specific_libraries KIND PARALLEL) # adding target properties to the different cases ## MPI if(PARALLEL STREQUAL "MPI") - if(MPI_C_LIBRARIES) - set_target_properties(fftw3::${kind}::mpi PROPERTIES - IMPORTED_LOCATION "${FFTW3_${KIND}_${PARALLEL}_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR_PARALLEL}" - IMPORTED_LINK_INTERFACE_LIBRARIES ${MPI_C_LIBRARIES}) + set_target_properties(fftw3::${kind}::mpi PROPERTIES + IMPORTED_LOCATION "${FFTW3_${KIND}_${PARALLEL}_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR_PARALLEL}" + ) + + if(MPI_C_LIBRARIES AND NOT MPI_C_LIBRARIES STREQUAL "") + set_property(TARGET fftw3::${kind}::mpi PROPERTY + INTERFACE_LINK_LIBRARIES "${MPI_C_LIBRARIES}" + ) endif() endif() ## OpenMP diff --git a/pyfans/CMakeLists.txt b/pyfans/CMakeLists.txt index 94608ed..47882af 100644 --- a/pyfans/CMakeLists.txt +++ b/pyfans/CMakeLists.txt @@ -1,5 +1,5 @@ pybind11_add_module(PyFANS micro.hpp micro.cpp) -target_include_directories(PyFANS PRIVATE ${HDF5_INCLUDE_DIRS}) +target_include_directories(PyFANS PRIVATE ${HDF5_INCLUDE_DIRS} ${FFTW3_INCLUDE_DIRS}) target_link_libraries(PyFANS PRIVATE FANS::FANS) add_custom_command( diff --git a/src/reader.cpp b/src/reader.cpp index ea7dd7f..372a856 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -393,7 +393,8 @@ void Reader ::ReadMS(int hm) FANS_free(tmp); } else { /* XYZ case: the slab is already in correct order */ - ms = tmp; // steal the buffer; no copy + FANS_free(ms); // dealloc mem + ms = tmp; // steal the buffer; no copy } /*--------------------------------------------------------------------