diff --git a/examples/main.c b/examples/main.c index 9fb55e09944011c58bd47aab4f095f7970c286b8..92c68e4ceec5fe68323c02cde672a6e4d8e1b73c 100644 --- a/examples/main.c +++ b/examples/main.c @@ -79,6 +79,8 @@ int main(int argc, char *argv[]) { int nr_nodes = 1, myrank = 0; FILE *file_thread; int with_outputs = 1; + int with_gravity = 0; + int engine_policies = 0; int verbose = 0, talking = 0; unsigned long long cpufreq = 0; @@ -156,7 +158,7 @@ int main(int argc, char *argv[]) { bzero(&s, sizeof(struct space)); /* Parse the options */ - while ((c = getopt(argc, argv, "a:c:d:e:f:h:m:oP:q:R:s:t:v:w:y:z:")) != -1) + while ((c = getopt(argc, argv, "a:c:d:e:f:gh:m:oP:q:R:s:t:v:w:y:z:")) != -1) switch (c) { case 'a': if (sscanf(optarg, "%lf", &scaling) != 1) @@ -185,6 +187,9 @@ int main(int argc, char *argv[]) { case 'f': if (!strcpy(ICfileName, optarg)) error("Error parsing IC file name."); break; + case 'g': + with_gravity = 1; + break; case 'h': if (sscanf(optarg, "%llu", &cpufreq) != 1) error("Error parsing CPU frequency."); @@ -388,23 +393,26 @@ int main(int argc, char *argv[]) { #endif /* MATTHIEU: Temporary fix to preserve master */ - free(gparts); - Ngpart = 0; + if (!with_gravity) { + free(gparts); + Ngpart = 0; #if defined(WITH_MPI) - N_long[0] = Ngas; - N_long[1] = Ngpart; - MPI_Reduce(&N_long, &N_total, 2, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); - if (myrank == 0) + N_long[0] = Ngas; + N_long[1] = Ngpart; + MPI_Reduce(&N_long, &N_total, 2, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); + if (myrank == 0) + message( + "AFTER FIX: Read %lld gas particles and %lld DM particles from the " + "ICs", + N_total[0], N_total[1]); +#else + N_total[0] = Ngas; + N_total[1] = Ngpart; message( "AFTER FIX: Read %lld gas particles and %lld DM particles from the ICs", N_total[0], N_total[1]); -#else - N_total[0] = Ngas; - N_total[1] = Ngpart; - message( - "AFTER FIX: Read %lld gas particles and %lld DM particles from the ICs", - N_total[0], N_total[1]); #endif + } /* MATTHIEU: End temporary fix */ /* Apply h scaling */ @@ -469,12 +477,15 @@ int main(int argc, char *argv[]) { message("nr of cells at depth %i is %i.", data[0], data[1]); } + /* Construct the engine policy */ + engine_policies = ENGINE_POLICY | engine_policy_steal | engine_policy_hydro; + if (with_gravity) engine_policies |= engine_policy_external_gravity; + /* Initialize the engine with this space. */ if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) message("nr_nodes is %i.", nr_nodes); engine_init(&e, &s, dt_max, nr_threads, nr_queues, nr_nodes, myrank, - ENGINE_POLICY | engine_policy_steal | engine_policy_hydro, 0, - time_end, dt_min, dt_max, talking); + engine_policies, 0, time_end, dt_min, dt_max, talking); if (myrank == 0 && verbose) { clocks_gettime(&toc); message("engine_init took %.3f %s.", clocks_diff(&tic, &toc),