Merge branch 'master' of bitbucket.org:glavaux/cosmotool

This commit is contained in:
Guilhem Lavaux 2015-04-28 17:08:00 +02:00
commit 4684c6ea83
5 changed files with 68 additions and 40 deletions

View File

@ -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,6 +38,7 @@ MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module")
include(${CMAKE_SOURCE_DIR}/external/external_build.cmake)
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")
@ -39,16 +46,18 @@ ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "n
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)
find_library(ZLIB z)
if(HDF5_ROOTDIR)
SET(ENV{HDF5_ROOT} ${HDF5_ROOTDIR})
endif(HDF5_ROOTDIR)
find_package(HDF5 COMPONENTS HL CXX)
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 +69,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)
if(BUILD_PYTHON)
add_subdirectory(python)
endif(BUILD_PYTHON)
include(CPack)

View File

@ -66,8 +66,8 @@ if (INTERNAL_HDF5)
SET(hdf5_built hdf5)
set(HDF5_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5.a CACHE STRING "HDF5 lib" FORCE)
set(HDF5_CPP_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_cpp.a CACHE STRING "HDF5 C++ lib" FORCE)
set(HDF5HL_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl.a CACHE STRING "HDF5-HL lib" FORCE)
set(HDF5HL_CPP_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl_cpp.a CACHE STRING "HDF5-HL C++ lib" FORCE)
set(HDF5_HL_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl.a CACHE STRING "HDF5-HL lib" FORCE)
set(HDF5_HL_CPP_LIBRARY ${HDF5_BIN_DIR}/lib/libhdf5_hl_cpp.a CACHE STRING "HDF5-HL C++ lib" FORCE)
SET(HDF5_INCLUDE_PATH ${HDF5_BIN_DIR}/include CACHE STRING "HDF5 include path" FORCE)
SET(ENV{HDF5_ROOT} ${HDF5_BIN_DIR})
SET(HDF5_ROOTDIR ${HDF5_BIN_DIR})
@ -76,11 +76,11 @@ else(INTERNAL_HDF5)
find_path(HDF5_INCLUDE_PATH hdf5.h)
find_library(HDF5_LIBRARY hdf5)
find_library(HDF5_CPP_LIBRARY hdf5_cpp)
find_library(HDF5HL_CPP_LIBRARY hdf5_hl_cpp)
find_library(HDF5HL_LIBRARY hdf5_hl)
find_library(HDF5_HL_CPP_LIBRARY hdf5_hl_cpp)
find_library(HDF5_HL_LIBRARY hdf5_hl)
endif (INTERNAL_HDF5)
SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${HDF5_INCLUDE_PATH}")
mark_as_advanced(HDF5_INCLUDE_PATH HDF5_LIBRARY HDF5_CPP_LIBRARY HDF5HL_LIBRARY HDF5HL_CPP_LIBRARY)
mark_as_advanced(HDF5_INCLUDE_PATH HDF5_LIBRARY HDF5_CPP_LIBRARY HDF5_HL_LIBRARY HDF5_HL_CPP_LIBRARY)
###############
# Build NetCDF

View File

@ -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)
@ -33,6 +35,9 @@ add_executable(testPool testPool.cpp)
target_link_libraries(testPool ${tolink})
if (HDF5_FOUND)
include_directories(${HDF5_INCLUDE_PATH})
SET(tolink ${tolink} ${ZLIB})
add_executable(testReadFlash testReadFlash.cpp)
target_link_libraries(testReadFlash ${tolink})
@ -63,8 +68,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)
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 +88,17 @@ target_link_libraries(test_cosmopower ${tolink})
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
IF (YORICK_SUPPORT)
add_executable(testSmooth testSmooth.cpp)
target_link_libraries(testSmooth ${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)

View File

@ -22,6 +22,7 @@ ENDIF (Boost_FOUND)
IF (ENABLE_OPENMP)
ENDIF (ENABLE_OPENMP)
IF (YORICK_SUPPORT)
IF(FOUND_NETCDF3)
SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc3.cpp)
ELSE(FOUND_NETCDF3)
@ -29,6 +30,7 @@ IF(FOUND_NETCDF4)
SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc4.cpp)
ENDIF(FOUND_NETCDF4)
ENDIF(FOUND_NETCDF3)
ENDIF(YORICK_SUPPORT)
if (HDF5_FOUND)
@ -66,9 +68,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})

View File

@ -126,11 +126,13 @@ namespace CosmoTool {
bool doCreate = true,
bool useBases = false)
{
H5::DataSpace dataspace(data.num_dimensions(), dimensions.data());
std::vector<hsize_t> memdims(data.shape(), data.shape() + data.num_dimensions());
H5::DataSpace dataspace(dimensions.size(), dimensions.data());
H5::DataSpace memspace(memdims.size(), memdims.data());
if (useBases) {
std::vector<hssize_t> offsets(data.index_bases(), data.index_bases() + data.num_dimensions());
dataspace.offsetSimple(offsets.data());
std::vector<hsize_t> offsets(data.index_bases(), data.index_bases() + data.num_dimensions());
dataspace.selectHyperslab(H5S_SELECT_SET, memdims.data(), offsets.data());
}
H5::DataSet dataset;
@ -139,7 +141,7 @@ namespace CosmoTool {
else
dataset = fg.openDataSet(data_set_name);
dataset.write(data.data(), datatype);
dataset.write(data.data(), datatype, memspace, dataspace);
}