Update requirements. Split HDF5 compilation into its own virtual target.
This commit is contained in:
parent
1d261c6251
commit
aa42376cbe
9 changed files with 60 additions and 30 deletions
|
@ -34,12 +34,13 @@ ENDIF(YORICK_SUPPORT)
|
|||
|
||||
|
||||
if (HDF5_FOUND)
|
||||
set(CosmoTool_SRCS ${CosmoTool_SRCS}
|
||||
add_library(CosmoHDF5 OBJECT
|
||||
h5_readFlash.cpp
|
||||
loadFlash.cpp
|
||||
)
|
||||
target_include_directories(CosmoHDF5 BEFORE PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
else(HDF5_FOUND)
|
||||
set(CosmoTool_SRCS ${CosmoTool_SRCS}
|
||||
add_library(CosmoHdf5 OBJECT
|
||||
loadFlash_dummy.cpp
|
||||
)
|
||||
endif (HDF5_FOUND)
|
||||
|
@ -78,22 +79,23 @@ endif(YORICK_SUPPORT)
|
|||
|
||||
if (HDF5_FOUND)
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${ZLIB})
|
||||
include_directories(${HDF5_INCLUDE_DIR})
|
||||
message(STATUS "CosmoTool_LIBS: ${CosmoTool_LIBS}")
|
||||
endif (HDF5_FOUND)
|
||||
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} PARENT_SCOPE)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_library(CosmoTool SHARED ${CosmoTool_SRCS})
|
||||
add_library(CosmoTool SHARED ${CosmoTool_SRCS} $<TARGET_OBJECTS:CosmoHDF5>)
|
||||
target_link_libraries(CosmoTool ${CosmoTool_LIBS})
|
||||
if (BUILD_STATIC_LIBS)
|
||||
add_library(CosmoTool_static STATIC ${CosmoTool_SRCS})
|
||||
set_target_properties(CosmoTool_static PROPERTIES COMPILE_FLAGS "${CMAKE_C_COMPILE_OPTIONS_PIC}")
|
||||
add_library(CosmoTool_static STATIC ${CosmoTool_SRCS} $<TARGET_OBJECTS:CosmoHDF5>)
|
||||
target_link_libraries(CosmoTool_static)
|
||||
set_property(TARGET CosmoTool_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif(BUILD_STATIC_LIBS)
|
||||
else (BUILD_SHARED_LIBS)
|
||||
add_library(CosmoTool STATIC ${CosmoTool_SRCS})
|
||||
set_target_properties(CosmoTool PROPERTIES COMPILE_FLAGS "${CMAKE_C_COMPILE_OPTIONS_PIC}")
|
||||
add_library(CosmoTool STATIC ${CosmoTool_SRCS} $<TARGET_OBJECTS:CosmoHDF5>)
|
||||
target_link_libraries(CosmoTool)
|
||||
set_property(TARGET CosmoTool PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif (BUILD_SHARED_LIBS)
|
||||
|
||||
install(TARGETS CosmoTool
|
||||
|
|
|
@ -51,6 +51,7 @@ UnformattedRead::UnformattedRead(const string& fname)
|
|||
swapOrdering = false;
|
||||
cSize = Check_32bits;
|
||||
checkPointRef = checkPointAccum = 0;
|
||||
recordBuffer = 0;
|
||||
}
|
||||
|
||||
UnformattedRead::UnformattedRead(const char *fname)
|
||||
|
@ -130,6 +131,7 @@ void UnformattedRead::beginCheckpoint(bool bufferRecord)
|
|||
throw EndOfFileException();
|
||||
|
||||
if (bufferRecord) {
|
||||
std::cout << "Use fast I/O mode" << std::endl;
|
||||
recordBuffer = new uint8_t[checkPointRef];
|
||||
f->read(reinterpret_cast<char *>(recordBuffer), checkPointRef);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace CosmoTool {
|
|||
//!
|
||||
//!_______________________________________________________________________________________
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name,
|
||||
void hdf5_write_array(H5::H5Location& fg, const std::string& data_set_name,
|
||||
const ArrayType& data,
|
||||
const hdf5_data_type& datatype,
|
||||
const std::vector<hsize_t>& dimensions,
|
||||
|
@ -156,7 +156,7 @@ namespace CosmoTool {
|
|||
|
||||
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name,
|
||||
void hdf5_write_array(H5::H5Location& fg, const std::string& data_set_name,
|
||||
const ArrayType& data,
|
||||
const hdf5_data_type& datatype,
|
||||
bool doCreate = true,
|
||||
|
@ -255,7 +255,7 @@ namespace CosmoTool {
|
|||
};
|
||||
|
||||
template<typename ArrayType>
|
||||
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name, const ArrayType& data )
|
||||
void hdf5_write_array(H5::H5Location& fg, const std::string& data_set_name, const ArrayType& data )
|
||||
{
|
||||
typedef typename ArrayType::element T;
|
||||
get_hdf5_data_type<T> hdf_data_type;
|
||||
|
@ -341,7 +341,7 @@ namespace CosmoTool {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
void hdf5_read_array_typed(H5::CommonFG& fg, const std::string& data_set_name,
|
||||
void hdf5_read_array_typed(H5::H5Location& fg, const std::string& data_set_name,
|
||||
ArrayType& data,
|
||||
const hdf5_data_type& datatype, bool auto_resize = true, bool useBases = false)
|
||||
{
|
||||
|
@ -377,7 +377,7 @@ namespace CosmoTool {
|
|||
}
|
||||
|
||||
template<typename ArrayType>
|
||||
void hdf5_read_array(H5::CommonFG& fg, const std::string& data_set_name, ArrayType& data, bool auto_resize = true,
|
||||
void hdf5_read_array(H5::H5Location& fg, const std::string& data_set_name, ArrayType& data, bool auto_resize = true,
|
||||
bool useBases = false )
|
||||
{
|
||||
typedef typename ArrayType::element T;
|
||||
|
|
|
@ -417,6 +417,9 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
|
|||
data->Vel[1] = new float[nPar];
|
||||
data->Vel[2] = new float[nPar];
|
||||
}
|
||||
if (flags & NEED_MASS) {
|
||||
data->Mass = new float[nPar];
|
||||
}
|
||||
if (flags & NEED_GADGET_ID)
|
||||
{
|
||||
data->Id = new int64_t[nPar];
|
||||
|
@ -455,9 +458,10 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
|
|||
|
||||
float minMass = INFINITY;
|
||||
infile.beginCheckpoint();
|
||||
for (uint32_t i = nPar; i > 0; i--)
|
||||
{
|
||||
for (uint32_t i = 0; i < nPar; i++) {
|
||||
float dummyF = dp ? infile.readReal64() : infile.readReal32();
|
||||
if (flags & NEED_MASS)
|
||||
data->Mass[i] = dummyF;
|
||||
if (dummyF < minMass) minMass = dummyF;
|
||||
}
|
||||
infile.endCheckpoint();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue