diff --git a/examples/main.c b/examples/main.c index fcf51e7807a32f5d25edefae2b197f8a2af7acf2..ca91c9e718cca9f7f8d82fce2f5d237f9f5b98e4 100644 --- a/examples/main.c +++ b/examples/main.c @@ -642,6 +642,7 @@ int main(int argc, char *argv[]) { double dim[3] = {0., 0., 0.}; int periodic = 0; if (myrank == 0) clocks_gettime(&tic); +#if defined(HAVE_HDF5) #if defined(WITH_MPI) #if defined(HAVE_PARALLEL_HDF5) read_ic_parallel(ICfileName, &us, dim, &parts, &gparts, &sparts, &Ngas, @@ -661,6 +662,7 @@ int main(int argc, char *argv[]) { &Ngpart, &Nspart, &periodic, &flag_entropy_ICs, with_hydro, (with_external_gravity || with_self_gravity), with_stars, cleanup_h, cosmo.h, nr_threads, dry_run); +#endif #endif if (myrank == 0) { clocks_gettime(&toc); diff --git a/src/common_io.c b/src/common_io.c index 19adc57fbd51972336840669dab473f846d23dee..c235060b1008aef0aa157bfe6e41dea76357b7b5 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -21,21 +21,6 @@ /* Config parameters. */ #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. */ #include "common_io.h" @@ -50,6 +35,22 @@ #include "units.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. * @@ -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 * @@ -429,6 +400,36 @@ void io_write_engine_policy(hid_t h_file, const struct engine* e) { #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. */ diff --git a/src/common_io.h b/src/common_io.h index 49358d8a374553d803de144f1135df6eee80cf15..4f6d75fad0482f62b8d5c3f80a632d7eb6f54d60 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -37,8 +37,6 @@ struct io_props; struct engine; struct threadpool; -#if defined(HAVE_HDF5) - /** * @brief The different types of data used in the GADGET IC files. * @@ -56,9 +54,9 @@ enum IO_DATA_TYPE { CHAR }; +#if defined(HAVE_HDF5) + 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* data); @@ -86,6 +84,9 @@ void io_copy_temp_buffer(void* temp, const struct engine* e, #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, struct gpart* const dmparts, size_t Ndm); void io_prepare_dm_gparts(struct threadpool* tp, struct gpart* const gparts, diff --git a/src/engine.c b/src/engine.c index 47c96abab226eb4199f8b531be7b6ad6f237fce8..fd7b2cd94e82d70a514de05a87593d38f2273264 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5089,6 +5089,7 @@ void engine_dump_snapshot(struct engine *e) { #endif /* Dump... */ +#if defined(WITH_HDF5) #if defined(WITH_MPI) #if defined(HAVE_PARALLEL_HDF5) write_output_parallel(e, e->snapshotBaseName, e->internal_units, @@ -5102,6 +5103,7 @@ void engine_dump_snapshot(struct engine *e) { #else write_output_single(e, e->snapshotBaseName, e->internal_units, e->snapshotUnits); +#endif #endif e->dump_snapshot = 0; diff --git a/src/parser.h b/src/parser.h index 4e61b16ab53b3688e60f85a42e786c44b095120a..7909b1209091b388aa4a6dc87a53fcb593d15828 100644 --- a/src/parser.h +++ b/src/parser.h @@ -23,9 +23,8 @@ /* Config parameters. */ #include "../config.h" -#if defined(HAVE_HDF5) -#include <hdf5.h> -#endif +/* Standard headers */ +#include <stdio.h> /* Some constants. */ #define PARSER_MAX_LINE_SIZE 256