gs2crmod 0.11.80 → 0.11.81

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6783798fe31935c88eed681707a8ce7399d6a4ba
4
- data.tar.gz: ec68da31f8910b3820651081ed73625cfe843836
3
+ metadata.gz: dd002075eaac9b4c29d88b0aebd361dda5af3ab5
4
+ data.tar.gz: 8e4ca849e1ea872ac714da047a819f0fda8a5f87
5
5
  SHA512:
6
- metadata.gz: 5dfe476db0de6a33076e0a6816f7fd6d8ff458447a90d7383b9ec5cfe7e6653e7f5532d2456d9aea842487197e4296da9d6b4ba302bb47229fbaec04d138b889
7
- data.tar.gz: 8f40c2c3447cd60a7f4254de0518c7299867936198257d990c0b7d019fed7d84dcf29eb011022925481049f572c32e0bd595bc1461012962672ef0ee909d9a39
6
+ metadata.gz: 8540f760d4cbe56a57a5d11ae5a28b5dd708f33558b189d40171d012b30d30569fe02252c47f9da934f887b710909c46cede919bc7198f879e6f09a32168dbf2
7
+ data.tar.gz: 07821b20d76a4baf24380e3370e32c958db355c28bb7e210be0c4cfa8d382c9bcc073a1a02ec50ebf2e9a2cf3b84614abc2aa90ec0f814c63f2c8b11aab2d422
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "coderunner", ">= 0.14.15"
4
+ gem "coderunner", ">= 0.15.5"
5
5
  gem "rubyhacks", ">= 0.1.2"
6
6
  # It seems necessary to have the following line un-commented on some systems but commented out on other systems:
7
7
  gem "ruby-netcdf-updated", ">= 0.6.6.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.80
1
+ 0.11.81
data/gs2crmod.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: gs2crmod 0.11.80 ruby lib
5
+ # stub: gs2crmod 0.11.81 ruby lib
6
6
  # stub: ext/extconf.rb
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "gs2crmod"
10
- s.version = "0.11.80"
10
+ s.version = "0.11.81"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Edmund Highcock", "Ferdinand van Wyk"]
15
- s.date = "2014-10-24"
15
+ s.date = "2014-12-04"
16
16
  s.description = "GS2 is a gyrokinetic flux tube initial value turbulence code which can be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated running and analysis of large simulations. This module allows GS2 (and its sister code AstroGK) to harness the power of the CodeRunner framework."
17
17
  s.email = "edmundhighcock@sourceforge.net"
18
18
  s.extensions = ["ext/extconf.rb"]
@@ -86,7 +86,7 @@ Gem::Specification.new do |s|
86
86
  s.specification_version = 4
87
87
 
88
88
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
89
- s.add_runtime_dependency(%q<coderunner>, [">= 0.14.15"])
89
+ s.add_runtime_dependency(%q<coderunner>, [">= 0.15.5"])
90
90
  s.add_runtime_dependency(%q<rubyhacks>, [">= 0.1.2"])
91
91
  s.add_runtime_dependency(%q<ruby-netcdf-updated>, [">= 0.6.6.1"])
92
92
  s.add_development_dependency(%q<shoulda>, ["= 3.0.1"])
@@ -95,7 +95,7 @@ Gem::Specification.new do |s|
95
95
  s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
96
96
  s.add_development_dependency(%q<minitest>, ["~> 4"])
97
97
  else
98
- s.add_dependency(%q<coderunner>, [">= 0.14.15"])
98
+ s.add_dependency(%q<coderunner>, [">= 0.15.5"])
99
99
  s.add_dependency(%q<rubyhacks>, [">= 0.1.2"])
100
100
  s.add_dependency(%q<ruby-netcdf-updated>, [">= 0.6.6.1"])
101
101
  s.add_dependency(%q<shoulda>, ["= 3.0.1"])
@@ -105,7 +105,7 @@ Gem::Specification.new do |s|
105
105
  s.add_dependency(%q<minitest>, ["~> 4"])
106
106
  end
107
107
  else
108
- s.add_dependency(%q<coderunner>, [">= 0.14.15"])
108
+ s.add_dependency(%q<coderunner>, [">= 0.15.5"])
109
109
  s.add_dependency(%q<rubyhacks>, [">= 0.1.2"])
110
110
  s.add_dependency(%q<ruby-netcdf-updated>, [">= 0.6.6.1"])
111
111
  s.add_dependency(%q<shoulda>, ["= 3.0.1"])
data/lib/gs2crmod/gs2.rb CHANGED
@@ -86,38 +86,6 @@ require folder + '/read_netcdf.rb'
86
86
  NaN = GSL::NAN
87
87
  # GSL::Neg
88
88
 
89
-
90
- def code_run_environment
91
- case CodeRunner::SYS
92
- when /iridis/
93
- <<EOF
94
- module load openmpi
95
- EOF
96
- when /helios/
97
- <<EOF
98
- module purge
99
- module load intel
100
- module load bullxmpi
101
- module load netcdf_p
102
- module load hdf5_p
103
- module load fftw/3.3.3
104
- module load bullxde papi
105
- module load scalasca
106
- EOF
107
- #when /archer/
108
- #<<EOF
109
- #module swap PrgEnv-cray PrgEnv-intel
110
- #module load intel/14.0.0.080
111
- #module load fftw
112
- #module load netcdf-hdf5parallel
113
- #module load cray-hdf5-parallel
114
- #EOF
115
- else
116
-
117
- @code_run_environment
118
- end
119
- end
120
-
121
89
  eval(%[
122
90
  ], GLOBAL_BINDING)
123
91
 
@@ -182,7 +150,7 @@ eval(%[
182
150
  # Other useful information about the run
183
151
  ###############################################
184
152
 
185
- @gs2_run_info = [:time, :percent_of_total_time, :checked_converged, :is_a_restart, :restart_id, :restart_run_name, :completed_timesteps]
153
+ @gs2_run_info = [:time, :percent_of_total_time, :checked_converged, :is_a_restart, :restart_id, :restart_run_name, :completed_timesteps, :response_id]
186
154
 
187
155
  @run_info = @gs2_run_info.dup
188
156
 
@@ -533,54 +501,112 @@ end
533
501
 
534
502
 
535
503
  def restart(new_run)
536
- #new_run = self.dup
537
504
  (rcp.variables).each{|v| new_run.set(v, send(v)) if send(v)}
538
505
  @naming_pars.delete(:preamble)
539
506
  SUBMIT_OPTIONS.each{|v| new_run.set(v, self.send(v)) unless new_run.send(v)}
540
- #(rcp.results + rcp.gs2_run_info).each{|result| new_run.set(result, nil)}
541
507
  new_run.is_a_restart = true
542
508
  new_run.ginit_option = "many"
543
509
  new_run.delt_option = "check_restart"
544
- #if Dir.entries(@directory).include? "nc"
545
- #old_restart_run_name = (@restart_run_name or Dir.entries(@directory + '/nc').grep(/\.nc/)[0].sub(/\.nc\.\d+$/, ''))
546
- #new_run.restart_file = File.expand_path("#@directory/nc/#{old_restart_run_name}.nc")
547
- #else
548
- #new_run.restart_file = File.expand_path("#@directory/#@run_name.nc")
549
- #end
550
510
  new_run.restart_id = @id
551
511
  new_run.restart_run_name = @run_name
552
- @runner.nprocs = @nprocs if @runner.nprocs == "1" # 1 is the default so this means the user probably didn't specify nprocs
553
- raise "Restart must be on the same number of processors as the previous run: new is #{new_run.nprocs.inspect} and old is #{@nprocs.inspect}" if !new_run.nprocs or new_run.nprocs != @nprocs
554
- # @runner.parameters.each{|var, value| new_run.set(var,value)} if @runner.parameters
555
- # ep @runner.parameters
512
+ @runner.nprocs = @nprocs if @runner.nprocs == "1" # 1 is the default
513
+
514
+ if !new_run.nprocs or new_run.nprocs != @nprocs
515
+ raise "Restart must be on the same number of processors as the previous "\
516
+ "run: new is #{new_run.nprocs.inspect} and old is #{@nprocs.inspect}"
517
+ end
556
518
  new_run.run_name = nil
557
519
  new_run.naming_pars = @naming_pars
558
- new_run.update_submission_parameters(new_run.parameter_hash_string, false) if new_run.parameter_hash
520
+ new_run.update_submission_parameters(new_run.parameter_hash_string, false) if
521
+ new_run.parameter_hash
559
522
  new_run.naming_pars.delete(:restart_id)
560
523
  new_run.generate_run_name
561
- eputs 'Copying Restart files', ''
524
+ copy_restart_files(new_run)
525
+
526
+ if new_run.read_response and new_run.read_response.fortran_true?
527
+ new_run.response_id = new_run.restart_id
528
+ copy_response_files(new_run)
529
+ end
530
+
531
+ new_run
532
+ end
533
+
534
+ def copy_restart_files(new_run)
535
+ eputs 'Copying restart files...', ''
562
536
  FileUtils.makedirs(new_run.directory + '/nc')
563
537
  #old_dir = File.dirname(@restart_file)
564
- new_run.restart_file = "#@run_name.nc" #+ File.basename(@restart_file) #.sub(/\.nc/, '')
538
+ new_run.restart_file = "#@run_name.nc"
565
539
  new_run.restart_dir = "nc"
566
- #files = Dir.entries(old_dir).grep(/\.nc(?:\.\d|_ene)/)
567
- #files = Dir.entries(old_dir).grep(/^\.\d+$/) if files.size == 0
568
540
  files = list_of_restart_files.map do |file|
569
541
  @directory + "/" + file
570
542
  end
571
543
  files.each_with_index do |file , index|
572
- eputs "\033[2A" # Terminal jargon - go back one line
573
544
  eputs "#{index+1} out of #{files.size}"
545
+ eputs "\033[2A" # Terminal jargon - go back one line
574
546
  num = file.scan(/(?:\.\d+|_ene)$/)[0]
575
547
  #FileUtils.cp("#{old_dir}/#{file}", "nc/#@restart_file#{num}")
576
548
  FileUtils.cp(file, new_run.directory + "/nc/#{new_run.restart_file}#{num}")
577
549
  end
578
- #@runner.submit(new_run)
579
- new_run
580
550
  end
581
551
 
582
- # Return a list of restart file paths (relative to the run directory).
552
+ def copy_response_files(run)
553
+ eputs 'Copying response files...', ''
554
+ eputs 'The following run parameters have changed. Are you sure you can use '\
555
+ 'these response files?'
556
+ diff_run_parameters(self, run)
557
+ FileUtils.makedirs(run.directory + '/response')
558
+ run.response_dir = "response"
559
+
560
+ files = list_of_response_files.map do |file|
561
+ @directory + "/" + file
562
+ end
563
+
564
+ files.each_with_index do |file , index|
565
+ eputs "#{index+1} out of #{files.size}"
566
+ eputs "\033[2A" # Terminal jargon - go back one line
567
+ response_ext = file.scan(/_ik_\d+_is_\d+.response/)
568
+ FileUtils.cp(file, run.directory + "/response/#{run.run_name}#{response_ext[0]}")
569
+ end
570
+ end
571
+
572
+ # The following function is essentially the same as the CR differences_between
573
+ # function without the runner loading set up code. This could possibly be moved
574
+ # to a more general function in CR.
575
+ def diff_run_parameters(run_1, run_2)
576
+ runs = [run_1, run_2]
577
+ rcp_fetcher = (runs[0] || @runner.run_class).rcp
578
+ vars = rcp.variables.dup + rcp.run_info.dup
579
+
580
+ # Clean up output by deleting some variables
581
+ vars.delete_if{|var| runs.map{|r| r.send(var)}.uniq.size == 1}
582
+ vars.delete :id
583
+ vars.delete :run_name
584
+ vars.delete :output_file
585
+ vars.delete :error_file
586
+ vars.delete :executable
587
+ vars.delete :comment
588
+ vars.delete :naming_pars
589
+ vars.delete :parameter_hash
590
+ vars.delete :parameter_hash_string
591
+ vars.delete :sys
592
+ vars.delete :status
593
+ vars.delete :job_no
594
+ vars.delete :running
595
+ vars.unshift :id
596
+
597
+ # Fancy table printing
598
+ table = vars.map{|var| [var] + runs.map{|r| str = r.instance_eval(var.to_s).to_s;
599
+ str.size>10?str[0..9]:str} }
600
+ col_widths = table.map{|row| row.map{|v| v.to_s.size}}.
601
+ inject{|o,n| o.zip(n).map{|a| a.max}}
602
+ eputs
603
+ table.each{|row| i=0; eputs row.map{|v| str = sprintf(" %#{col_widths[i]}s ",
604
+ v.to_s); i+=1; str}.join('|'); eputs '-' *
605
+ (col_widths.sum + col_widths.size*3 - 1) }
606
+ end
583
607
 
608
+
609
+ # Return a list of restart file paths (relative to the run directory).
584
610
  def list_of_restart_files
585
611
  Dir.chdir(@directory) do
586
612
  files = Dir.entries.grep(/^\.\d+$/)
@@ -591,7 +617,7 @@ def list_of_restart_files
591
617
  break if files.size == 0
592
618
  end
593
619
  end #if files.size == 0
594
- # This just finds a .nc file (w/o a number) in the nc folder if using single restart file
620
+ # Finds a .nc file (w/o a number) in 'nc' folder if using single restart file
595
621
  if files.size == 0
596
622
  files = Dir.entries('nc').grep(/\.nc/).map{|file| 'nc' + "/" + file}
597
623
  end #if files.size == 0
@@ -601,6 +627,21 @@ end
601
627
 
602
628
  alias :lorf :list_of_restart_files
603
629
 
630
+ # Return list of response files similar to method for restart files
631
+ def list_of_response_files
632
+ Dir.chdir(@directory) do
633
+ files = Dir.entries('response').grep(/\.response/).map{|file| 'response' +
634
+ "/" + file}
635
+ files = Dir.entries.grep(/\.response/) if files.size == 0
636
+ if files.size == 0
637
+ (Dir.entries.find_all{|dir| FileTest.directory? dir} - ['.', '..']).each do |dir|
638
+ files = Dir.entries(dir).grep(/\.response/).map{|file| dir + "/" + file}
639
+ end
640
+ end
641
+ return files
642
+ end
643
+ end
644
+
604
645
  # Put restart files in the conventional location, i.e. nc/run_name.proc
605
646
 
606
647
  def standardize_restart_files
@@ -809,16 +850,34 @@ end
809
850
 
810
851
 
811
852
  def generate_input_file(&block)
812
- raise CRFatal("No Input Module File Given or Module Corrupted") unless methods.include? (:input_file_text)
853
+ raise CRFatal("No Input Module File Given or Module Corrupted") unless
854
+ methods.include? (:input_file_text)
813
855
  run_namelist_backwards_compatibility
814
- if @restart_id and (not @is_a_restart or @resubmit_id) # The second test checks that the restart function has not been called manually earlier (e.g. in Trinity), but we must check that it is not in fact a resubmitted run
856
+
857
+ # If it is a restart default behaviour will be to copy the response files
858
+ # from the run being restarted. Specifying a response_id will override this.
859
+ if not @is_a_restart and @response_id
860
+ @read_response = ".true."
861
+
862
+ @runner.run_list[@response_id].copy_response_files(self)
863
+ elsif @dump_response and @dump_response.fortran_true? and
864
+ (not @read_response or not @read_response.fortran_true?)
865
+ @response_dir = "response"
866
+ FileUtils.makedirs @response_dir
867
+ end
868
+
869
+ # The second test checks that the restart function has not been called
870
+ # manually earlier (e.g. in Trinity), but we must check that it is not in
871
+ # fact a resubmitted run.
872
+ if @restart_id and (not @is_a_restart or @resubmit_id)
815
873
  @runner.run_list[@restart_id].restart(self)
816
- elsif @save_for_restart and @save_for_restart.fortran_true? and (not @is_a_restart or @resubmit_id)
874
+ elsif @save_for_restart and @save_for_restart.fortran_true? and
875
+ (not @is_a_restart or @resubmit_id)
817
876
  @restart_dir = "nc"
818
877
  #if CODE_OPTIONS[:gs2] and CODE_OPTIONS[:gs2][:list]
819
878
  #FileUtils.makedirs "#{@runner.root_folder}/#@restart_dir"
820
879
  #else
821
- FileUtils.makedirs @restart_dir
880
+ FileUtils.makedirs @restart_dir
822
881
  #end
823
882
  @restart_file = "#@run_name.nc"
824
883
 
@@ -831,7 +890,6 @@ def generate_input_file(&block)
831
890
 
832
891
  set_nprocs
833
892
 
834
-
835
893
  if block
836
894
  ##### Allow the user to define their own pre-flight checks and changes
837
895
  instance_eval(&block)
@@ -841,7 +899,6 @@ def generate_input_file(&block)
841
899
  #########
842
900
  end
843
901
 
844
-
845
902
  write_input_file
846
903
 
847
904
  ######### Generate a report using the ingen tool if possible
@@ -849,6 +906,7 @@ def generate_input_file(&block)
849
906
  ########
850
907
  end
851
908
 
909
+
852
910
  def write_input_file
853
911
  File.open(@run_name + ".in", 'w'){|file| file.puts input_file_text}
854
912
  end
@@ -105,7 +105,9 @@ def check_parameters
105
105
  # Diagnostics
106
106
  # Misc
107
107
 
108
- # Namelist Tests
108
+ ##################
109
+ # Namelist Tests #
110
+ ##################
109
111
 
110
112
  rcp.namelists.each do |namelist, hash|
111
113
  next if hash[:should_include].kind_of? String and not eval(hash[:should_include])
@@ -180,6 +182,11 @@ def check_parameters
180
182
 
181
183
  error("ginit_option is 'many' but is_a_restart is false") if @ginit_option == "many" and not @is_a_restart
182
184
 
185
+ error("read_response is 'true' but run is not a restart. Make sure the "\
186
+ "@response_id is set to a run with response files.") if
187
+ @read_response and @read_response.fortran_true? and
188
+ not @is_a_restart and not @response_id
189
+
183
190
  error("chop_side should not be used (remove test if default changes from T to F)") if !@chop_side or @chop_side.fortran_true?
184
191
 
185
192
  #####################