Commit 866c8f97 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Correct use of the HAVE_HDF5 option throughout the whole code.

parent ce5ec3f8
...@@ -642,6 +642,7 @@ int main(int argc, char *argv[]) { ...@@ -642,6 +642,7 @@ int main(int argc, char *argv[]) {
double dim[3] = {0., 0., 0.}; double dim[3] = {0., 0., 0.};
int periodic = 0; int periodic = 0;
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
#if defined(HAVE_HDF5)
#if defined(WITH_MPI) #if defined(WITH_MPI)
#if defined(HAVE_PARALLEL_HDF5) #if defined(HAVE_PARALLEL_HDF5)
read_ic_parallel(ICfileName, &us, dim, &parts, &gparts, &sparts, &Ngas, read_ic_parallel(ICfileName, &us, dim, &parts, &gparts, &sparts, &Ngas,
...@@ -661,6 +662,7 @@ int main(int argc, char *argv[]) { ...@@ -661,6 +662,7 @@ int main(int argc, char *argv[]) {
&Ngpart, &Nspart, &periodic, &flag_entropy_ICs, with_hydro, &Ngpart, &Nspart, &periodic, &flag_entropy_ICs, with_hydro,
(with_external_gravity || with_self_gravity), with_stars, (with_external_gravity || with_self_gravity), with_stars,
cleanup_h, cosmo.h, nr_threads, dry_run); cleanup_h, cosmo.h, nr_threads, dry_run);
#endif
#endif #endif
if (myrank == 0) { if (myrank == 0) {
clocks_gettime(&toc); clocks_gettime(&toc);
......
...@@ -21,21 +21,6 @@ ...@@ -21,21 +21,6 @@
/* Config parameters. */ /* Config parameters. */
#include "../config.h" #include "../config.h"
#if defined(HAVE_HDF5)
/* Some standard headers. */
#include <hdf5.h>
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* MPI headers. */
#ifdef WITH_MPI
#include <mpi.h>
#endif
/* This object's header. */ /* This object's header. */
#include "common_io.h" #include "common_io.h"
...@@ -50,6 +35,22 @@ ...@@ -50,6 +35,22 @@
#include "units.h" #include "units.h"
#include "version.h" #include "version.h"
/* Some standard headers. */
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(HAVE_HDF5)
#include <hdf5.h>
/* MPI headers. */
#ifdef WITH_MPI
#include <mpi.h>
#endif
/** /**
* @brief Converts a C data type to the HDF5 equivalent. * @brief Converts a C data type to the HDF5 equivalent.
* *
...@@ -84,36 +85,6 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type) { ...@@ -84,36 +85,6 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type) {
} }
} }
/**
* @brief Returns the memory size of the data type
*/
size_t io_sizeof_type(enum IO_DATA_TYPE type) {
switch (type) {
case INT:
return sizeof(int);
case UINT:
return sizeof(unsigned int);
case LONG:
return sizeof(long);
case ULONG:
return sizeof(unsigned long);
case LONGLONG:
return sizeof(long long);
case ULONGLONG:
return sizeof(unsigned long long);
case FLOAT:
return sizeof(float);
case DOUBLE:
return sizeof(double);
case CHAR:
return sizeof(char);
default:
error("Unknown type");
return 0;
}
}
/** /**
* @brief Return 1 if the type has double precision * @brief Return 1 if the type has double precision
* *
...@@ -429,6 +400,36 @@ void io_write_engine_policy(hid_t h_file, const struct engine* e) { ...@@ -429,6 +400,36 @@ void io_write_engine_policy(hid_t h_file, const struct engine* e) {
#endif /* HAVE_HDF5 */ #endif /* HAVE_HDF5 */
/**
* @brief Returns the memory size of the data type
*/
size_t io_sizeof_type(enum IO_DATA_TYPE type) {
switch (type) {
case INT:
return sizeof(int);
case UINT:
return sizeof(unsigned int);
case LONG:
return sizeof(long);
case ULONG:
return sizeof(unsigned long);
case LONGLONG:
return sizeof(long long);
case ULONGLONG:
return sizeof(unsigned long long);
case FLOAT:
return sizeof(float);
case DOUBLE:
return sizeof(double);
case CHAR:
return sizeof(char);
default:
error("Unknown type");
return 0;
}
}
/** /**
* @brief Mapper function to copy #part or #gpart fields into a buffer. * @brief Mapper function to copy #part or #gpart fields into a buffer.
*/ */
......
...@@ -37,8 +37,6 @@ struct io_props; ...@@ -37,8 +37,6 @@ struct io_props;
struct engine; struct engine;
struct threadpool; struct threadpool;
#if defined(HAVE_HDF5)
/** /**
* @brief The different types of data used in the GADGET IC files. * @brief The different types of data used in the GADGET IC files.
* *
...@@ -56,9 +54,9 @@ enum IO_DATA_TYPE { ...@@ -56,9 +54,9 @@ enum IO_DATA_TYPE {
CHAR CHAR
}; };
#if defined(HAVE_HDF5)
hid_t io_hdf5_type(enum IO_DATA_TYPE type); hid_t io_hdf5_type(enum IO_DATA_TYPE type);
size_t io_sizeof_type(enum IO_DATA_TYPE type);
int io_is_double_precision(enum IO_DATA_TYPE type);
void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type,
void* data); void* data);
...@@ -86,6 +84,9 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, ...@@ -86,6 +84,9 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
#endif /* defined HDF5 */ #endif /* defined HDF5 */
size_t io_sizeof_type(enum IO_DATA_TYPE type);
int io_is_double_precision(enum IO_DATA_TYPE type);
void io_collect_dm_gparts(const struct gpart* const gparts, size_t Ntot, void io_collect_dm_gparts(const struct gpart* const gparts, size_t Ntot,
struct gpart* const dmparts, size_t Ndm); struct gpart* const dmparts, size_t Ndm);
void io_prepare_dm_gparts(struct threadpool* tp, struct gpart* const gparts, void io_prepare_dm_gparts(struct threadpool* tp, struct gpart* const gparts,
......
...@@ -5089,6 +5089,7 @@ void engine_dump_snapshot(struct engine *e) { ...@@ -5089,6 +5089,7 @@ void engine_dump_snapshot(struct engine *e) {
#endif #endif
/* Dump... */ /* Dump... */
#if defined(WITH_HDF5)
#if defined(WITH_MPI) #if defined(WITH_MPI)
#if defined(HAVE_PARALLEL_HDF5) #if defined(HAVE_PARALLEL_HDF5)
write_output_parallel(e, e->snapshotBaseName, e->internal_units, write_output_parallel(e, e->snapshotBaseName, e->internal_units,
...@@ -5102,6 +5103,7 @@ void engine_dump_snapshot(struct engine *e) { ...@@ -5102,6 +5103,7 @@ void engine_dump_snapshot(struct engine *e) {
#else #else
write_output_single(e, e->snapshotBaseName, e->internal_units, write_output_single(e, e->snapshotBaseName, e->internal_units,
e->snapshotUnits); e->snapshotUnits);
#endif
#endif #endif
e->dump_snapshot = 0; e->dump_snapshot = 0;
......
...@@ -23,9 +23,8 @@ ...@@ -23,9 +23,8 @@
/* Config parameters. */ /* Config parameters. */
#include "../config.h" #include "../config.h"
#if defined(HAVE_HDF5) /* Standard headers */
#include <hdf5.h> #include <stdio.h>
#endif
/* Some constants. */ /* Some constants. */
#define PARSER_MAX_LINE_SIZE 256 #define PARSER_MAX_LINE_SIZE 256
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment