Commit f8f1f502 authored by Matthieu Schaller's avatar Matthieu Schaller

Compile the FOF-related functions only if WITH_FOF is defined.

parent 5e482a41
......@@ -843,7 +843,9 @@ int main(int argc, char *argv[]) {
/* Initialise the FOF properties */
bzero(&fof_properties, sizeof(struct fof_props));
#ifdef WITH_FOF
if (with_fof) fof_init(&fof_properties, params, &prog_const, &us);
#endif
/* Be verbose about what happens next */
if (myrank == 0) message("Reading ICs from file '%s'", ICfileName);
......
......@@ -5572,8 +5572,10 @@ void engine_config(int restart, int fof, struct engine *e,
stats_create_mpi_type();
proxy_create_mpi_type();
task_create_mpi_comms();
#ifdef WITH_FOF
fof_create_mpi_types();
#endif
#endif /* WITH_FOF */
#endif /* WITH_MPI */
if (!fof) {
......@@ -6253,7 +6255,9 @@ void engine_struct_dump(struct engine *e, FILE *stream) {
feedback_struct_dump(e->feedback_props, stream);
black_holes_struct_dump(e->black_holes_properties, stream);
chemistry_struct_dump(e->chemistry, stream);
#ifdef WITH_FOF
fof_struct_dump(e->fof_properties, stream);
#endif
parser_struct_dump(e->parameter_file, stream);
if (e->output_list_snapshots)
output_list_struct_dump(e->output_list_snapshots, stream);
......@@ -6371,10 +6375,12 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
chemistry_struct_restore(chemistry, stream);
e->chemistry = chemistry;
#ifdef WITH_FOF
struct fof_props *fof_props =
(struct fof_props *)malloc(sizeof(struct fof_props));
fof_struct_restore(fof_props, stream);
e->fof_properties = fof_props;
#endif
struct swift_params *parameter_file =
(struct swift_params *)malloc(sizeof(struct swift_params));
......@@ -6490,6 +6496,8 @@ void engine_activate_fof_tasks(struct engine *e) {
void engine_fof(struct engine *e, const int dump_results,
const int seed_black_holes) {
#ifdef WITH_FOF
ticks tic = getticks();
/* Compute number of DM particles */
......@@ -6527,4 +6535,7 @@ void engine_fof(struct engine *e, const int dump_results,
if (engine_rank == 0)
message("Complete FOF search took: %.3f %s.",
clocks_from_ticks(getticks() - tic), clocks_getunit());
#else
error("SWIFT was not compiled with FOF enabled!");
#endif
}
......@@ -20,6 +20,8 @@
/* Config parameters. */
#include "../config.h"
#ifdef WITH_FOF
/* Some standard headers. */
#include <errno.h>
#include <libgen.h>
......@@ -2772,3 +2774,5 @@ void fof_struct_restore(struct fof_props *props, FILE *stream) {
restart_read_blocks((void *)props, sizeof(struct fof_props), 1, stream, NULL,
"fof_props");
}
#endif /* WITH_FOF */
......@@ -22,6 +22,8 @@
/* Config parameters. */
#include "../config.h"
#ifdef WITH_FOF
INLINE static void convert_part_group_id(const struct engine* e,
const struct part* p,
const struct xpart* xp,
......@@ -41,6 +43,8 @@ INLINE static void convert_bpart_group_id(const struct engine* e,
ret[0] = bp->gpart->fof_data.group_id;
}
#endif /* WITH_FOF */
/**
* @brief Specifies which FoF-related particle fields to write to a dataset
*
......@@ -54,11 +58,15 @@ INLINE static int fof_write_parts(const struct part* parts,
const struct xpart* xparts,
struct io_props* list) {
#ifdef WITH_FOF
list[0] = io_make_output_field_convert_part("GroupIDs", LONGLONG, 1,
UNIT_CONV_NO_UNITS, parts, xparts,
convert_part_group_id);
return 1;
#else
return 0;
#endif
}
/**
......@@ -72,10 +80,15 @@ INLINE static int fof_write_parts(const struct part* parts,
INLINE static int fof_write_gparts(const struct gpart* gparts,
struct io_props* list) {
#ifdef WITH_FOF
list[0] = io_make_output_field("GroupIDs", LONGLONG, 1, UNIT_CONV_NO_UNITS,
gparts, fof_data.group_id);
return 1;
#else
return 0;
#endif
}
/**
......@@ -89,11 +102,15 @@ INLINE static int fof_write_gparts(const struct gpart* gparts,
INLINE static int fof_write_sparts(const struct spart* sparts,
struct io_props* list) {
#ifdef WITH_FOF
list[0] = io_make_output_field_convert_spart("GroupIDs", LONGLONG, 1,
UNIT_CONV_NO_UNITS, sparts,
convert_spart_group_id);
return 1;
#else
return 0;
#endif
}
/**
......@@ -107,11 +124,15 @@ INLINE static int fof_write_sparts(const struct spart* sparts,
INLINE static int fof_write_bparts(const struct bpart* bparts,
struct io_props* list) {
#ifdef WITH_FOF
list[0] = io_make_output_field_convert_bpart("GroupIDs", LONGLONG, 1,
UNIT_CONV_NO_UNITS, bparts,
convert_bpart_group_id);
return 1;
#else
return 0;
#endif
}
#endif /* SWIFT_FOF_IO_H */
......@@ -22,6 +22,8 @@
/* Config parameters. */
#include "../config.h"
#ifdef WITH_FOF
/**
* @brief Particle-carried fields for the FoF scheme.
*/
......@@ -34,4 +36,13 @@ struct fof_gpart_data {
size_t group_size;
};
#else
/**
* @brief Particle-carried fields for the FoF scheme.
*/
struct fof_gpart_data {};
#endif
#endif /* SWIFT_FOF_STRUCT_H */
......@@ -4748,6 +4748,8 @@ void runner_do_logger(struct runner *r, struct cell *c, int timer) {
*/
void runner_do_fof_self(struct runner *r, struct cell *c, int timer) {
#ifdef WITH_FOF
TIMER_TIC;
const struct engine *e = r->e;
......@@ -4760,6 +4762,10 @@ void runner_do_fof_self(struct runner *r, struct cell *c, int timer) {
rec_fof_search_self(e->fof_properties, dim, search_r2, periodic, gparts, c);
if (timer) TIMER_TOC(timer_fof_self);
#else
error("SWIFT was not compiled with FOF enabled!");
#endif
}
/**
......@@ -4773,6 +4779,8 @@ void runner_do_fof_self(struct runner *r, struct cell *c, int timer) {
void runner_do_fof_pair(struct runner *r, struct cell *ci, struct cell *cj,
int timer) {
#ifdef WITH_FOF
TIMER_TIC;
const struct engine *e = r->e;
......@@ -4786,4 +4794,7 @@ void runner_do_fof_pair(struct runner *r, struct cell *ci, struct cell *cj,
cj);
if (timer) TIMER_TOC(timer_fof_pair);
#else
error("SWIFT was not compiled with FOF enabled!");
#endif
}
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