From 03fce51182d50d8ceef14ce20628cce1f6f2a016 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sat, 21 Mar 2015 18:27:09 +0100 Subject: [PATCH 1/5] Moved extent generator definition up --- src/hdf5_array.hpp | 51 +++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/hdf5_array.hpp b/src/hdf5_array.hpp index 64eab5f..4250a0d 100644 --- a/src/hdf5_array.hpp +++ b/src/hdf5_array.hpp @@ -90,10 +90,31 @@ namespace CosmoTool { #undef HDF5_TYPE + // Extent generator + template + struct hdf5_extent_gen { + typedef typename boost::detail::multi_array::extent_gen type; + + static inline type build(hsize_t *d) + { + return (hdf5_extent_gen::build(d))[d[r-1]]; + } + }; + + template<> + struct hdf5_extent_gen<0> { + static inline boost::multi_array_types::extent_gen build(hsize_t *d) + { + return boost::extents; + } + }; + + //!_______________________________________________________________________________________ //! //! write_hdf5 multi_array //! +//! \author Guilhem Lavaux (2014-2015) //! \author leo Goodstadt (04 March 2013) //! //!_______________________________________________________________________________________ @@ -214,24 +235,11 @@ namespace CosmoTool { class InvalidDimensions: virtual std::exception { }; - template - struct hdf5_extent_gen { - typedef typename boost::detail::multi_array::extent_gen type; - - static inline type build(hsize_t *d) - { - return (hdf5_extent_gen::build(d))[d[r-1]]; - } - }; - - template<> - struct hdf5_extent_gen<0> { - static inline boost::multi_array_types::extent_gen build(hsize_t *d) - { - return boost::extents; - } - }; + // ---------------------------------------------------------------------- + // Conditional resize support + // If the Array type support resize then it is called. Otherwise + // the dimensions are checked and lead to a failure if they are different template class array_has_resize { struct Fallback { int resize; }; @@ -280,11 +288,13 @@ namespace CosmoTool { hdf5_resize_array(ArrayType& data, std::vector& dims) { hdf5_check_array(data, dims); } + + // ---------------------------------------------------------------------- template void hdf5_read_array_typed(H5::CommonFG& fg, const std::string& data_set_name, - ArrayType& data, - const hdf5_data_type& datatype, bool auto_resize = true) + ArrayType& data, + const hdf5_data_type& datatype, bool auto_resize = true) { H5::DataSet dataset = fg.openDataSet(data_set_name); H5::DataSpace dataspace = dataset.getSpace(); @@ -309,8 +319,7 @@ namespace CosmoTool { { typedef typename ArrayType::element T; - get_hdf5_data_type hdf_data_type; - hdf5_read_array_typed(fg, data_set_name, data, hdf_data_type.type(), auto_resize); + hdf5_read_array_typed(fg, data_set_name, data, get_hdf5_data_type::type(), auto_resize); } From f7d6aa9bd36a5d7e54d0056d69458e56ed0a8949 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 7 Apr 2015 14:36:47 +0200 Subject: [PATCH 2/5] Updated version handling --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c36a26..c4aba78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,14 +13,18 @@ set(NumPy_FIND_REQUIRED TRUE) include(${CMAKE_SOURCE_DIR}/FindPyLibs.cmake) include(${CMAKE_SOURCE_DIR}/FindNumPy.cmake) -get_git_head_revision(HEAD GIT_VER) - option(BUILD_SHARED_LIBS "Build shared libraries." OFF) option(BUILD_STATIC_LIBS "Build static libraries." ON) option(ENABLE_SHARP "Enable SHARP support." ON) option(INTERNAL_HDF5 "Build internal version of HDF5" OFF) option(INTERNAL_NETCDF "Build internal version of NETCDF" OFF) option(INTERNAL_BOOST "Build internal version of BOOST" OFF) +option(USE_GIT_VERSION "Use GIT version to pad version number" OFF) +IF(USE_GIT_VERSION) + get_git_head_revision(HEAD GIT_VER) + SET(EXTRA_VERSION "-${GIT_VER}") +ENDIF(USE_GIT_VERSION) + #IF(NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) # SET(CosmoTool_local CosmoTool_static) @@ -60,8 +64,8 @@ SET(CPACK_PACKAGE_VENDOR "Guilhem Lavaux") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENCE_CeCILL_V2") SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MINOR "0") -SET(CPACK_PACKAGE_VERSION_PATCH "0-${GIT_VER}") -SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${GalaxExplorer_VERSION_MAJOR}.${GalaxExplorer_VERSION_MINOR}") +SET(CPACK_PACKAGE_VERSION_PATCH "0${EXTRA_VERSION}") +SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") SET(CPACK_STRIP_FILES "lib/libCosmoTool.so") SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.git/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;/CMakeFiles/;.*\\\\.cmake;Makefile") From e2ef019ab5cb80db962a9cfff4da760a5e419743 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 7 Apr 2015 14:45:38 +0200 Subject: [PATCH 3/5] Allow to opt-out from yorick classes --- CMakeLists.txt | 19 +++++++++++-------- sample/CMakeLists.txt | 26 ++++++++++++++++---------- src/CMakeLists.txt | 20 +++++++++++++------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4aba78..5689932 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ option(INTERNAL_HDF5 "Build internal version of HDF5" OFF) option(INTERNAL_NETCDF "Build internal version of NETCDF" OFF) option(INTERNAL_BOOST "Build internal version of BOOST" OFF) option(USE_GIT_VERSION "Use GIT version to pad version number" OFF) +option(YORICK_SUPPORT "Add for pleasant yorick support" ON) IF(USE_GIT_VERSION) get_git_head_revision(HEAD GIT_VER) SET(EXTRA_VERSION "-${GIT_VER}") @@ -36,13 +37,15 @@ MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module") include(${CMAKE_SOURCE_DIR}/external/external_build.cmake) -IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") - SET(FOUND_NETCDF4 1) - FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1") -ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") - SET(FOUND_NETCDF3 1) - FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4") -ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") +IF(YORICK_SUPPORT) + IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") + SET(FOUND_NETCDF4 1) + FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1") + ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") + SET(FOUND_NETCDF3 1) + FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4") + ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") +ENDIF(YORICK_SUPPORT) find_program(CYTHON cython) @@ -52,7 +55,7 @@ endif(HDF5_ROOTDIR) find_package(HDF5 COMPONENTS HL CXX) -set(NETCDF_FIND_REQUIRED TRUE) +set(NETCDF_FIND_REQUIRED ${YORICK_SUPPORT}) set(GSL_FIND_REQUIRED TRUE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(NetCDF DEFAULT_MSG NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GSL DEFAULT_MSG GSL_LIBRARY GSLCBLAS_LIBRARY GSL_INCLUDE_PATH) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index dc7ee5a..42fbd2a 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,7 +1,9 @@ SET(tolink ${GSL_LIBRARIES} ${CosmoTool_local} ${CosmoTool_LIBS}) include_directories(${CMAKE_SOURCE_DIR}/src) -include_directories(${FFTW3_INCLUDE_DIRS} -${EIGEN3_INCLUDE_DIRS} ${NETCDF_INCLUDE_PATH} ${GSL_INCLUDE_PATH}) +include_directories(${FFTW3_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${GSL_INCLUDE_PATH}) +if(YORICK_SUPPORT) + include_directories(${NETCDF_INCLUDE_PATH}) +endif(YORICK_SUPPORT) include_directories(${CMAKE_SOURCE_DIR}/sample) IF(SHARP_INCLUDE_PATH) @@ -63,8 +65,10 @@ if (FFTW3_FOUND AND FFTW3F_FOUND AND EIGEN3_FOUND) IF (FFTW3_LIBRARY_FULL) SET(FFTW3_LIB ${FFTW3_LIB} ${FFTW3_LIBRARY_FULL}) ENDIF (FFTW3_LIBRARY_FULL) - add_executable(test_fft_calls test_fft_calls.cpp) - target_link_libraries(test_fft_calls ${tolink} ${FFTW3_LIB}) + IF(YORICK_SUPPORT) + add_executable(test_fft_calls test_fft_calls.cpp) + target_link_libraries(test_fft_calls ${tolink} ${FFTW3_LIB}) + ENDIF(YORICK_SUPPORT) endif (FFTW3_FOUND AND FFTW3F_FOUND AND EIGEN3_FOUND) if (ENABLE_SHARP AND SHARP_LIBRARY AND SHARP_INCLUDE_PATH AND EIGEN3_FOUND) @@ -81,15 +85,17 @@ target_link_libraries(test_cosmopower ${tolink}) if (Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) - add_executable(testSmooth testSmooth.cpp) - target_link_libraries(testSmooth ${tolink}) + IF (YORICK_SUPPORT) + add_executable(testSmooth testSmooth.cpp) + target_link_libraries(testSmooth ${tolink}) - add_executable(simple3DFilter simple3DFilter.cpp) - target_link_libraries(simple3DFilter ${tolink}) + add_executable(simple3DFilter simple3DFilter.cpp) + target_link_libraries(simple3DFilter ${tolink}) + ENDIF (YORICK_SUPPORT) endif (Boost_FOUND) -IF (ENABLE_OPENMP) +IF (ENABLE_OPENMP AND YORICK_SUPPORT) add_executable(gadgetToDensity gadgetToDensity.cpp) target_link_libraries(gadgetToDensity ${tolink}) -ENDIF (ENABLE_OPENMP) +ENDIF (ENABLE_OPENMP AND YORICK_SUPPORT) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce0aea7..5b0c5b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,13 +15,15 @@ SET(CosmoTool_SRCS IF (ENABLE_OPENMP) ENDIF (ENABLE_OPENMP) -IF(FOUND_NETCDF3) +IF (YORICK_SUPPORT) + IF(FOUND_NETCDF3) SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc3.cpp) -ELSE(FOUND_NETCDF3) -IF(FOUND_NETCDF4) + ELSE(FOUND_NETCDF3) + IF(FOUND_NETCDF4) SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc4.cpp) -ENDIF(FOUND_NETCDF4) -ENDIF(FOUND_NETCDF3) + ENDIF(FOUND_NETCDF4) + ENDIF(FOUND_NETCDF3) +ENDIF(YORICK_SUPPORT) if (HDF5_FOUND) @@ -59,9 +61,13 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS} growthFactor.hpp ) -include_directories(${GSL_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) +include_directories(${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) -set(CosmoTool_LIBS ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES}) +set(CosmoTool_LIBS ${GSL_LIBRARIES}) +if(YORICK_SUPPORT) + set(CosmoTool_LIBS ${CosmoTool_LIBS} ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES}) + include_directories(${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH}) +endif(YORICK_SUPPORT) if (HDF5_FOUND) set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_CXX_LIBRARIES} ${HDF5_LIBRARIES}) include_directories(${HDF5_INCLUDE_DIRS}) From 8050679a7fdc17823bea1f7578dd0ca808b0ee01 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 7 Apr 2015 14:49:49 +0200 Subject: [PATCH 4/5] Allow to skip python --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5689932..519d4cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ option(INTERNAL_NETCDF "Build internal version of NETCDF" OFF) option(INTERNAL_BOOST "Build internal version of BOOST" OFF) option(USE_GIT_VERSION "Use GIT version to pad version number" OFF) option(YORICK_SUPPORT "Add for pleasant yorick support" ON) +option(BUILD_PYTHON "Build the python modules" ON) IF(USE_GIT_VERSION) get_git_head_revision(HEAD GIT_VER) SET(EXTRA_VERSION "-${GIT_VER}") @@ -75,6 +76,8 @@ SET(CPACK_SOURCE_IGNORE_FILES add_subdirectory(src) add_subdirectory(sample) -add_subdirectory(python) +if(BUILD_PYTHON) + add_subdirectory(python) +endif(BUILD_PYTHON) include(CPack) From 4b51ee0c9f0c35d1bf5f4618621f67092a335167 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 7 Apr 2015 15:17:14 +0200 Subject: [PATCH 5/5] Include Boost dirs --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b0c5b7..659d4cc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,7 +61,7 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS} growthFactor.hpp ) -include_directories(${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) +include_directories(${Boost_INCLUDE_DIRS} ${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) set(CosmoTool_LIBS ${GSL_LIBRARIES}) if(YORICK_SUPPORT)