Merge branch 'master' of bitbucket.org:glavaux/cosmotool
This commit is contained in:
commit
5e7437b7d4
4 changed files with 82 additions and 51 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue