diff --git a/base/workflow/R/start_model_runs.R b/base/workflow/R/start_model_runs.R index 54245d48db8..fe621b0cf20 100644 --- a/base/workflow/R/start_model_runs.R +++ b/base/workflow/R/start_model_runs.R @@ -321,12 +321,7 @@ start_model_runs <- function(settings, write = TRUE, stop.on.error = TRUE) { } # Write finish time to database - #TODO this repeats for every run in `jobids` writing every run's time stamp every time. This actually takes quite a long time with a lot of ensembles and should either 1) not be a for loop (no `for(x in run_list)`) or 2) if `is_modellauncher`, be done outside of the jobids for loop after all jobs are finished. - if (is_modellauncher && write) { - for (x in run_list) { - PEcAn.DB::stamp_finished(con = dbcon, run = x) - } - } else { + if (!is_modellauncher) { if (write) { PEcAn.DB::stamp_finished(con = dbcon, run = run) } @@ -350,6 +345,12 @@ start_model_runs <- function(settings, write = TRUE, stop.on.error = TRUE) { } # end loop over runs } # end while loop checking runs + if (is_modellauncher && write) { + for (x in run_list) { + PEcAn.DB::stamp_finished(con = dbcon, run = x) + } + } + # Copy data back to local if (!is_local) { PEcAn.utils::retry.func(