Skip to content
Snippets Groups Projects
Commit 6ee57542 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add command line argument to stop after a fixed number of steps

Useful when profiling.
parent 4b518aaf
No related branches found
No related tags found
1 merge request!190Autotools update
...@@ -26,6 +26,8 @@ Valid options are: ...@@ -26,6 +26,8 @@ Valid options are:
-f {int} Overwrite the CPU frequency (Hz) to be used for time measurements -f {int} Overwrite the CPU frequency (Hz) to be used for time measurements
-g Run with an external gravitational potential -g Run with an external gravitational potential
-G Run with self-gravity -G Run with self-gravity
-n {int} Execute a fixed number of time steps. Defaults to -1, which means
use the time_end parameter to stop.
-s Run with SPH -s Run with SPH
-t {int} The number of threads to use on each MPI rank. Defaults to 1 if not specified. -t {int} The number of threads to use on each MPI rank. Defaults to 1 if not specified.
-v [12] Increase the level of verbosity 1: MPI-rank 0 writes -v [12] Increase the level of verbosity 1: MPI-rank 0 writes
......
...@@ -74,6 +74,7 @@ void print_help_message() { ...@@ -74,6 +74,7 @@ void print_help_message() {
printf(" %2s %8s %s\n", "-g", "", printf(" %2s %8s %s\n", "-g", "",
"Run with an external gravitational potential"); "Run with an external gravitational potential");
printf(" %2s %8s %s\n", "-G", "", "Run with self-gravity"); printf(" %2s %8s %s\n", "-G", "", "Run with self-gravity");
printf(" %2s %8s %s\n", "-n", "{int}", "Execute a fixed number of time steps");
printf(" %2s %8s %s\n", "-s", "", "Run with SPH"); printf(" %2s %8s %s\n", "-s", "", "Run with SPH");
printf(" %2s %8s %s\n", "-t", "{int}", printf(" %2s %8s %s\n", "-t", "{int}",
"The number of threads to use on each MPI rank. Defaults to 1 if not " "The number of threads to use on each MPI rank. Defaults to 1 if not "
...@@ -138,6 +139,7 @@ int main(int argc, char *argv[]) { ...@@ -138,6 +139,7 @@ int main(int argc, char *argv[]) {
int with_aff = 0; int with_aff = 0;
int dry_run = 0; int dry_run = 0;
int dump_tasks = 0; int dump_tasks = 0;
int nsteps = -1;
int with_cosmology = 0; int with_cosmology = 0;
int with_external_gravity = 0; int with_external_gravity = 0;
int with_self_gravity = 0; int with_self_gravity = 0;
...@@ -150,7 +152,7 @@ int main(int argc, char *argv[]) { ...@@ -150,7 +152,7 @@ int main(int argc, char *argv[]) {
/* Parse the parameters */ /* Parse the parameters */
int c; int c;
while ((c = getopt(argc, argv, "acdef:gGhst:v:y:")) != -1) switch (c) { while ((c = getopt(argc, argv, "acdef:gGhn:st:v:y:")) != -1) switch (c) {
case 'a': case 'a':
with_aff = 1; with_aff = 1;
break; break;
...@@ -179,6 +181,13 @@ int main(int argc, char *argv[]) { ...@@ -179,6 +181,13 @@ int main(int argc, char *argv[]) {
case 'h': case 'h':
if (myrank == 0) print_help_message(); if (myrank == 0) print_help_message();
return 0; return 0;
case 'n':
if (sscanf(optarg, "%d", &nsteps) != 1) {
if (myrank == 0) printf("Error parsing fixed number of steps.\n");
if (myrank == 0) print_help_message();
return 1;
}
break;
case 's': case 's':
with_hydro = 1; with_hydro = 1;
break; break;
...@@ -474,7 +483,7 @@ int main(int argc, char *argv[]) { ...@@ -474,7 +483,7 @@ int main(int argc, char *argv[]) {
"Updates", "g-Updates", "Wall-clock time", clocks_getunit()); "Updates", "g-Updates", "Wall-clock time", clocks_getunit());
/* Main simulation loop */ /* Main simulation loop */
for (int j = 0; !engine_is_done(&e); j++) { for (int j = 0; !engine_is_done(&e) && e.step != nsteps; j++) {
/* Repartition the space amongst the nodes? */ /* Repartition the space amongst the nodes? */
#ifdef WITH_MPI #ifdef WITH_MPI
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment