coderunner 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.0
1
+ 0.13.1
data/coderunner.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "coderunner"
8
- s.version = "0.13.0"
8
+ s.version = "0.13.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
12
- s.date = "2013-08-09"
12
+ s.date = "2013-08-13"
13
13
  s.description = "CodeRunner is a framework for the automated running and analysis of simulations. It automatically generates any necessary input files, organises the output data and analyses it. Because it is a modular system, it can easily be customised to work with any system and any simulation code. One of its greatest strengths is that it is independent of any one simulation code; thus it can easily plot and compare the data from different codes."
14
14
  s.email = "edmundhighcock@sourceforge.net"
15
15
  s.executables = ["coderunner"]
@@ -882,15 +882,16 @@ end
882
882
 
883
883
  # This method takes the help written into this module for the various input parameters and writes it in a format suitable for the mediawiki page on input parameters.
884
884
 
885
- def self.write_mediawiki_documentation
886
- puts <<EOF
885
+ def self.write_mediawiki_documentation(filename = "#{rcp.code}_mediawiki.txt")
886
+ File.open(filename, 'w') do |file|
887
+ file.puts <<EOF
887
888
  =Introduction=
888
889
 
889
- This page lists every GS2 input parameter currently known about, along with any help available. It is intended as a reference, not an introduction. Note: some parameters are highly specialised and not intended for general use.
890
+ This page lists every #{rcp.code} input parameter currently known about, along with any help available. It is intended as a reference, not an introduction. Note: some parameters are highly specialised and not intended for general use.
890
891
 
891
892
  A full introduction to writing input files is to be written, but until then, this is an old example input file. Be aware that not every section should be included.
892
893
 
893
- [[GS2 Reference Input File]]
894
+ [[#{rcp.code} Reference Input File]]
894
895
 
895
896
  ==Format==
896
897
 
@@ -900,8 +901,8 @@ The parameters are divided into namelists. Each parameter has type information a
900
901
  ! Name !! Type !! Def !! CR Name !! Description
901
902
  |-
902
903
  |-
903
- |Name as it appears in GS2 || Fortran Data Type || Autoscanned Default(s): guesses at what the default value of this parameter will be if you do not specify it in the input file. They are usually correct.
904
- || CodeRunner Name: is the variable name used by [http://coderunner.sourceforge.net CodeRunner] to refer to the quantity (only given if it is different to the GS2 name).
904
+ |Name as it appears in #{rcp.code} || Fortran Data Type || Autoscanned Default(s): guesses at what the default value of this parameter will be if you do not specify it in the input file. They are usually correct.
905
+ || CodeRunner Name: is the variable name used by [http://coderunner.sourceforge.net CodeRunner] to refer to the quantity (only given if it is different to the #{rcp.code} name).
905
906
  |
906
907
  Long and detailed help for the variable
907
908
  |}
@@ -913,25 +914,26 @@ This page is automatically generated by [http://coderunner.sourceforge.net CodeR
913
914
 
914
915
  =Namelists=
915
916
 
916
- Each GS2 module is controlled by its own namelist. For typical applications, not all 32+ namelists should appear in a single file. For a run called runname, this file should be called <tt>runname.in</tt>. In most cases, defaults are loaded for each namelist element, so that if a namelist or element does not appear, the run will not automatically stop. (It may still be forced to stop if the defaults are incompatible with your other choices.) The namelists and defaults appear below.
917
+ Each #{rcp.code} module is controlled by its own namelist. For typical applications, not all 32+ namelists should appear in a single file. For a run called runname, this file should be called <tt>runname.in</tt>. In most cases, defaults are loaded for each namelist element, so that if a namelist or element does not appear, the run will not automatically stop. (It may still be forced to stop if the defaults are incompatible with your other choices.) The namelists and defaults appear below.
917
918
  EOF
918
919
 
919
920
  rcp.namelists.each do |namelist, hash|
920
- puts "==#{namelist}=="
921
- puts "<!--begin namelist help-->#{hash[:help]}<!--end namelist help-->"
922
- puts "\n{| border=\"2\" cellpadding=\"5\"\n! Name !! Type !! Def !! CR Name !! Description \n|-"
921
+ file.puts "==#{namelist}=="
922
+ file.puts "<!--begin namelist help-->#{hash[:help]}<!--end namelist help-->"
923
+ file.puts "\n{| border=\"2\" cellpadding=\"5\"\n! Name !! Type !! Def !! CR Name !! Description \n|-"
923
924
  hash[:variables].keys.sort.each do |var|
924
925
  var_hash = hash[:variables][var]
925
926
  #puts "==='''[[#{(var_hash[:code_name] or var)}]]'''==="
926
- puts "|-\n|'''[[#{(var_hash[:code_name] or var)}]]''' || #{var_hash[:type]} || #{(var_hash[:autoscanned_defaults]||[]).map{|v| v.to_s}.join(",")} || #{var} \n|\n<!--begin help-->* #{hash[:variables][var][:help]} <!-- end help -->"
927
+ file.puts "|-\n|'''[[#{(var_hash[:code_name] or var)}]]''' || #{var_hash[:type]} || #{(var_hash[:autoscanned_defaults]||[]).map{|v| v.to_s}.join(",")} || #{var} \n|\n<!--begin help-->* #{hash[:variables][var][:help]} <!-- end help -->"
927
928
  #puts "''Type'': #{var_hash[:type]} "
928
929
  #puts "''Autoscanned Defaults'': #{var_hash[:autoscanned_defaults]} "
929
930
  #puts "''CodeRunner name'': #{var} "
930
931
  #puts "\n", "#{hash[:variables][var][:help]}".sub(/\A\s+/, '') if hash[:variables][var][:help]
931
932
  #puts " #{(var_hash[:code_name] or var)} Properties:"
932
933
  end
933
- puts "|}"
934
+ file.puts "|}"
934
935
  end
936
+ end #file.open
935
937
  end
936
938
 
937
939
  # This method takes the help written into this module for the various input parameters and writes it in a format suitable for the mediawiki page on input parameters.
@@ -15,7 +15,6 @@ class FortranNamelistC < FortranNamelist
15
15
  #source.scan(/^\s*namelist\s*\/(?<namelist>\w+)\/(?<variables>(?:(?:&\s*[\n\r]+)|[^!\n\r])*)/) do
16
16
  #source.scan(Regexp.new("#{/^\s*namelist\s*\/\s*(?<namelist>\w+)\s*\//}(?<variables>#{FORTRAN_SINGLE_LINE})")) do
17
17
  source.scan(rcp.fortran_namelist_variable_match_regex) do
18
- #p $~
19
18
  namelist = $~[:namelist].to_s.downcase.to_sym
20
19
  #variables = $~[:variables].gsub(/!.*/, '')
21
20
  #eputs namelist, variables
@@ -41,13 +40,23 @@ class FortranNamelistC < FortranNamelist
41
40
  def self.get_sample_value(source, var)
42
41
  sample_val = nil
43
42
  source.scan(rcp.fortran_namelist_variable_match_regex) do
43
+ #p $~
44
44
 
45
45
  next unless var == $~[:variable].to_sym
46
- sample_val = eval($~[:default])
46
+ sample_val = eval($~[:default].sub(/(\d\.)$/, '\10').sub(/^(\.\d)/, '0\1').sub(/(\d\.)[eE]/, '\10e'))
47
47
  end
48
48
  raise "Couldn't get a sample value for #{var.inspect}" unless sample_val
49
49
  return sample_val
50
50
  end
51
+ def self.update_defaults_from_source_code(source_code_folder = ARGV[-1])
52
+ source = get_aggregated_source_code_text(source_code_folder)
53
+ rcp.namelists.each do |nml, nmlhash|
54
+ nmlhash[:variables].each do |var, varhash|
55
+ varhash[:autoscanned_defaults] = [get_sample_value(source, varhash[:code_name]||var)] rescue []
56
+ save_namelists
57
+ end
58
+ end
59
+ end
51
60
 
52
61
  end
53
62
  end
@@ -10,7 +10,8 @@
10
10
  :must_pass=>
11
11
  [{:test=>"kind_of? Integer",
12
12
  :explanation=>"This variable must be an integer."}],
13
- :type=>:Integer},
13
+ :type=>:Integer,
14
+ :autoscanned_defaults=>[0]},
14
15
  :must_sleep=>
15
16
  {:should_include=>"true",
16
17
  :description=>nil,
@@ -19,7 +20,8 @@
19
20
  :must_pass=>
20
21
  [{:test=>"kind_of? Integer",
21
22
  :explanation=>"This variable must be an integer."}],
22
- :type=>:Integer},
23
+ :type=>:Integer,
24
+ :autoscanned_defaults=>[0]},
23
25
  :width=>
24
26
  {:should_include=>"true",
25
27
  :description=>nil,
@@ -29,7 +31,8 @@
29
31
  [{:test=>"kind_of? Numeric",
30
32
  :explanation=>
31
33
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
32
- :type=>:Float},
34
+ :type=>:Float,
35
+ :autoscanned_defaults=>[1.0]},
33
36
  :depth=>
34
37
  {:should_include=>"true",
35
38
  :description=>nil,
@@ -39,7 +42,8 @@
39
42
  [{:test=>"kind_of? Numeric",
40
43
  :explanation=>
41
44
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
42
- :type=>:Float},
45
+ :type=>:Float,
46
+ :autoscanned_defaults=>[1.0]},
43
47
  :height=>
44
48
  {:should_include=>"true",
45
49
  :description=>nil,
@@ -49,4 +53,5 @@
49
53
  [{:test=>"kind_of? Numeric",
50
54
  :explanation=>
51
55
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
52
- :type=>:Float}}}}
56
+ :type=>:Float,
57
+ :autoscanned_defaults=>[1.0]}}}}
@@ -372,6 +372,12 @@ class TestFortranNamelistC < Test::Unit::TestCase
372
372
  CodeRunner.setup_run_class('cubecalc', modlet: 'with_namelist')
373
373
  assert_equal(File.read('test/cubecalc_namelist.cc').size+1, CodeRunner::Cubecalc::WithNamelist.get_aggregated_source_code_text('test').size)
374
374
  CodeRunner::Cubecalc::WithNamelist.synchronise_variables('test')
375
+ CodeRunner::Cubecalc::WithNamelist.update_defaults_from_source_code('test')
376
+ end
377
+ def test_mediawiki_write
378
+ CodeRunner.setup_run_class('cubecalc', modlet: 'with_namelist')
379
+ CodeRunner::Cubecalc::WithNamelist.write_mediawiki_documentation
380
+ FileUtils.rm 'cubecalc_mediawiki.txt'
375
381
  end
376
382
  def tfolder
377
383
  'test/submit_with_namelist'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-09 00:00:00.000000000 Z
12
+ date: 2013-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphkit