Merge branch 'master' of bitbucket.org:glavaux/cosmotool
This commit is contained in:
commit
5e7437b7d4
@ -13,14 +13,20 @@ 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)
|
||||
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}")
|
||||
ENDIF(USE_GIT_VERSION)
|
||||
|
||||
|
||||
#IF(NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
|
||||
# SET(CosmoTool_local CosmoTool_static)
|
||||
@ -32,13 +38,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)
|
||||
|
||||
@ -48,7 +56,7 @@ endif(HDF5_ROOTDIR)
|
||||
find_package(HDF5 COMPONENTS CXX HL)
|
||||
|
||||
|
||||
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)
|
||||
@ -60,14 +68,16 @@ 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")
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(sample)
|
||||
add_subdirectory(python)
|
||||
if(BUILD_PYTHON)
|
||||
add_subdirectory(python)
|
||||
endif(BUILD_PYTHON)
|
||||
|
||||
include(CPack)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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(${Boost_INCLUDE_DIRS} ${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})
|
||||
|
@ -90,10 +90,31 @@ namespace CosmoTool {
|
||||
|
||||
#undef HDF5_TYPE
|
||||
|
||||
// Extent generator
|
||||
template<std::size_t r>
|
||||
struct hdf5_extent_gen {
|
||||
typedef typename boost::detail::multi_array::extent_gen<r> type;
|
||||
|
||||
static inline type build(hsize_t *d)
|
||||
{
|
||||
return (hdf5_extent_gen<r-1>::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)
|
||||
//!
|
||||
//!_______________________________________________________________________________________
|
||||
@ -216,24 +237,11 @@ namespace CosmoTool {
|
||||
class InvalidDimensions: virtual std::exception {
|
||||
};
|
||||
|
||||
template<std::size_t r>
|
||||
struct hdf5_extent_gen {
|
||||
typedef typename boost::detail::multi_array::extent_gen<r> type;
|
||||
|
||||
static inline type build(hsize_t *d)
|
||||
{
|
||||
return (hdf5_extent_gen<r-1>::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<typename Array> class array_has_resize {
|
||||
struct Fallback { int resize; };
|
||||
@ -282,11 +290,13 @@ namespace CosmoTool {
|
||||
hdf5_resize_array(ArrayType& data, std::vector<hsize_t>& dims) {
|
||||
hdf5_check_array(data, dims);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
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();
|
||||
@ -311,8 +321,7 @@ namespace CosmoTool {
|
||||
{
|
||||
typedef typename ArrayType::element T;
|
||||
|
||||
get_hdf5_data_type<T> 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<T>::type(), auto_resize);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user