Commit f9d7ee7d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Make the stop condition into a function for improved readability

parent 57f2c0c4
...@@ -192,8 +192,8 @@ int main(int argc, char *argv[]) { ...@@ -192,8 +192,8 @@ int main(int argc, char *argv[]) {
with_outputs = 0; with_outputs = 0;
break; break;
case 'P': case 'P':
/* Partition type is one of "g", "m", "w", or "v"; "g" can be /* Partition type is one of "g", "m", "w", or "v"; "g" can be
* followed by three numbers defining the grid. */ * followed by three numbers defining the grid. */
#ifdef WITH_MPI #ifdef WITH_MPI
switch (optarg[0]) { switch (optarg[0]) {
case 'g': case 'g':
...@@ -224,8 +224,8 @@ int main(int argc, char *argv[]) { ...@@ -224,8 +224,8 @@ int main(int argc, char *argv[]) {
error("Error parsing number of queues."); error("Error parsing number of queues.");
break; break;
case 'R': case 'R':
/* Repartition type "n", "b", "v", "e" or "x". /* Repartition type "n", "b", "v", "e" or "x".
* Note only none is available without METIS. */ * Note only none is available without METIS. */
#ifdef WITH_MPI #ifdef WITH_MPI
switch (optarg[0]) { switch (optarg[0]) {
case 'n': case 'n':
...@@ -468,7 +468,7 @@ int main(int argc, char *argv[]) { ...@@ -468,7 +468,7 @@ int main(int argc, char *argv[]) {
"[ms]\n"); "[ms]\n");
/* Let loose a runner on the space. */ /* Let loose a runner on the space. */
for (j = 0; e.ti_current < max_nr_timesteps; j++) { for (j = 0; !engine_is_done(&e); j++) {
/* Repartition the space amongst the nodes? */ /* Repartition the space amongst the nodes? */
#ifdef WITH_MPI #ifdef WITH_MPI
......
...@@ -1624,6 +1624,13 @@ void engine_step(struct engine *e) { ...@@ -1624,6 +1624,13 @@ void engine_step(struct engine *e) {
// printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts); // printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
} }
/**
* @brief Returns 1 if the simulation has reached its end point, 0 otherwise
*/
int engine_is_done(struct engine *e) {
return !(e->ti_current < max_nr_timesteps);
}
/** /**
* @brief Create and fill the proxies. * @brief Create and fill the proxies.
* *
...@@ -1957,7 +1964,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -1957,7 +1964,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
float dt_max = timeEnd - timeBegin; float dt_max = timeEnd - timeBegin;
while (dt_max > e->dt_max) dt_max /= 2.f; while (dt_max > e->dt_max) dt_max /= 2.f;
message("Minimal timestep size (on time-line): %e", dt_max); message("Maximal timestep size (on time-line): %e", dt_max);
} }
} }
......
...@@ -63,7 +63,6 @@ extern const char *engine_policy_names[]; ...@@ -63,7 +63,6 @@ extern const char *engine_policy_names[];
#define engine_maxproxies 64 #define engine_maxproxies 64
#define engine_tasksreweight 10 #define engine_tasksreweight 10
/* The rank of the engine as a global variable (for messages). */ /* The rank of the engine as a global variable (for messages). */
extern int engine_rank; extern int engine_rank;
...@@ -186,5 +185,6 @@ void engine_makeproxies(struct engine *e); ...@@ -186,5 +185,6 @@ void engine_makeproxies(struct engine *e);
void engine_redistribute(struct engine *e); void engine_redistribute(struct engine *e);
struct link *engine_addlink(struct engine *e, struct link *l, struct task *t); struct link *engine_addlink(struct engine *e, struct link *l, struct task *t);
void engine_print_policy(struct engine *e); void engine_print_policy(struct engine *e);
int engine_is_done(struct engine *e);
#endif /* SWIFT_ENGINE_H */ #endif /* SWIFT_ENGINE_H */
Supports Markdown
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