File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,19 @@ int main(int argc, char **argv) {
64
64
num_simulations = total_simulations / num_max_proc ;
65
65
}
66
66
67
- int last_rank_extra = total_simulations % num_max_proc ;
67
+ //We have to calculate the simulation start offset before adding the rest to the last process
68
+ simulation_number_start = rank * num_simulations ;
68
69
69
- if (rank == num_max_proc - 1 ) {
70
- num_simulations += last_rank_extra ;
70
+ //The last process will have the rest of the simulations
71
+ int rest = total_simulations % num_max_proc ;
72
+ if (rest != 0 && rank == num_max_proc - 1 ) {
73
+ num_simulations += rest ;
71
74
}
72
75
73
- simulation_number_start = rank * num_simulations ;
76
+ if (num_simulations == 0 ) {
77
+ MPI_Finalize ();
78
+ return EXIT_SUCCESS ;
79
+ }
74
80
75
81
struct user_options * options ;
76
82
options = new_user_options ();
@@ -98,12 +104,7 @@ int main(int argc, char **argv) {
98
104
options -> show_gui = false;
99
105
100
106
MPI_Barrier (MPI_COMM_WORLD );
101
-
102
- if (num_simulations == 0 ) {
103
- MPI_Finalize ();
104
- return EXIT_SUCCESS ;
105
- }
106
-
107
+
107
108
for (int s = simulation_number_start ; s < simulation_number_start + num_simulations ; s ++ ) {
108
109
109
110
the_grid = new_grid ();
You can’t perform that action at this time.
0 commit comments