lib/coderunner/class_methods.rb in coderunner-0.17.5 vs lib/coderunner/class_methods.rb in coderunner-0.17.6

- old
+ new

@@ -75,10 +75,42 @@ end runner.continue_in_new_folder(folder, options) end + # Change the id of a given run to another integer + def self.change_run_id(new_ids, copts={}) + return unless Feedback.get_boolean("Warning: changing the id of a run does "\ + "NOT change the restart information "\ + "of any run which was restarted from "\ + "it! Please confirm.") + + runner_all = fetch_runner() + runs_all = runner_all.filtered_ids.map{|id| runner.combined_run_list[id]} + runner = fetch_runner(copts) + runs = runner.filtered_ids.map{|id| runner.combined_run_list[id]} + + new_ids = new_ids.split(',').map(&:to_i) + + if new_ids.length != runs.length + eputs "Error: New ids and list of runs are not the same length." + return + end + + existing_ids = [] + runs_all.each{|r| existing_ids << r.id} + + runs.each_with_index do |r, i| + if existing_ids.include?new_ids[i] + eputs "Error: id #{new_ids[i]} already exists! Skipping..." + next + end + + r.change_id(new_ids[i]) + end + end + # Method which concatenates NetCDF output files def self.concat(name, copts={}) begin require "numru/netcdf" rescue LoadError @@ -1042,8 +1074,8 @@ } EOF #help.gsub(/(.{63,73} |.{73})/){"#$1\n\t"}.paginate help.paginate - end + end end