diff --git a/include/core/Layer.hpp b/include/core/Layer.hpp index 218cd68a95..125c0079b5 100644 --- a/include/core/Layer.hpp +++ b/include/core/Layer.hpp @@ -125,7 +125,10 @@ namespace ngen } //done catchments ++output_time_index; - simulation_time.advance_timestep(); + if ( output_time_index < simulation_time.get_total_output_times() ) + { + simulation_time.advance_timestep(); + } } diff --git a/src/NGen.cpp b/src/NGen.cpp index 2cda737d27..391fa09748 100644 --- a/src/NGen.cpp +++ b/src/NGen.cpp @@ -387,7 +387,8 @@ int main(int argc, char *argv[]) { } //Now loop some time, iterate catchments, do stuff for total number of output times - for( int count = 0; count < manager->Simulation_Time_Object->get_total_output_times(); count++) + auto num_times = manager->Simulation_Time_Object->get_total_output_times(); + for( int count = 0; count < num_times; count++) { // The Inner loop will advance all layers unless doing so will break one of two constraints // 1) A layer may not proceed ahead of the master simulation object's current time @@ -430,7 +431,10 @@ int main(int argc, char *argv[]) { } //done levels } while( layer_min_next_time < next_time ); // rerun the loop until the last layer would pass the master next time - manager->Simulation_Time_Object->advance_timestep(); + if (count + 1 < num_times) + { + manager->Simulation_Time_Object->advance_timestep(); + } } //done time std::cout<<"Finished "<Simulation_Time_Object->get_total_output_times()<<" timesteps."<