coderunner 0.13.12 → 0.13.13

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.12
1
+ 0.13.13
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "coderunner"
8
- s.version = "0.13.12"
8
+ s.version = "0.13.13"
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-25"
12
+ s.date = "2013-08-27"
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"]
@@ -605,6 +605,19 @@ def input_file_text
605
605
  text
606
606
  end
607
607
 
608
+ def formatted_variable_output(value)
609
+ if String::FORTRAN_BOOLS.include? value # var is a Fortran Bool, not really a string
610
+ output = value.to_s
611
+ elsif value.kind_of? Complex
612
+ output = "(#{value.real}, #{value.imag})"
613
+ #elsif value.kind_of? Array
614
+ #output = "(/#{value.map{|v| formatted_variable_output(v)}.join(",")}/)"
615
+ else
616
+ #p cr_var, cr_var.class
617
+ output = value.inspect
618
+ end
619
+ output
620
+ end
608
621
  # Generate the input file text for the given namelist. Called by input_file_text.
609
622
 
610
623
  def namelist_text(namelist, enum = nil)
@@ -616,16 +629,17 @@ def namelist_text(namelist, enum = nil)
616
629
  hash[:variables].each do |var, var_hash|
617
630
  code_var = (var_hash[:code_name] or var)
618
631
  cr_var = var+ext.to_sym
632
+ value = send(cr_var)
619
633
  if send(cr_var) and (not var_hash[:should_include] or eval(var_hash[:should_include]))
620
- if String::FORTRAN_BOOLS.include? send(cr_var) # var is a Fortran Bool, not really a string
621
- output = send(cr_var).to_s
622
- elsif (v = send(cr_var)).kind_of? Complex
623
- output = "(#{v.real}, #{v.imag})"
634
+ if value.kind_of? Array
635
+ value.each_with_index do |v, i|
636
+ output = formatted_variable_output(v)
637
+ text << " #{code_var}(#{i+1}) = #{output} #{var_hash[:description] ? "! #{var_hash[:description]}": ""}\n"
638
+ end
624
639
  else
625
- #p cr_var, cr_var.class
626
- output = send(cr_var).inspect
640
+ output = formatted_variable_output(value)
641
+ text << " #{code_var} = #{output} #{var_hash[:description] ? "! #{var_hash[:description]}": ""}\n"
627
642
  end
628
- text << " #{code_var} = #{output} #{var_hash[:description] ? "! #{var_hash[:description]}": ""}\n"
629
643
  end
630
644
  end
631
645
  text << "/\n\n"
@@ -4,7 +4,7 @@ class FortranNamelistC < FortranNamelist
4
4
 
5
5
  @fortran_namelist_source_file_match = /(\.c|\.cpp|\.cu|\.cc)$/
6
6
 
7
- @fortran_namelist_variable_match_regex = /^[^\/]*?fnr_get_(?<type>\w+)\(\&?[\w\s]+\s*,\s*["'](?<namelist>\w+)[\d()]*?['"]\s*,\s*['"](?<variable>\w+)['"],[^)]+\)\)\s*[\w\[\]\d]+\s*=\s*(?<default>\S+)\s*;/
7
+ @fortran_namelist_variable_match_regex = /^[^\/]*?fnr_get_(?<type>\w+)\(\&?[\w\s]+\s*,\s*["'](?<namelist>\w+)[\d()]*?['"]\s*,\s*['"](?<variable>\w+)[()0-9]*['"],[^)]+\)\)\s*[\w\[\]\d]+\s*=\s*(?<default>\S+)\s*;/
8
8
  #
9
9
  # Find all input namelists and variables by scanning the source code
10
10
  #
@@ -381,4 +381,15 @@
381
381
  :must_pass=>
382
382
  [{:test=>"kind_of? Integer",
383
383
  :explanation=>"This variable must be an integer."}],
384
- :type=>:Integer}}
384
+ :type=>:Integer},
385
+ :dummy_for_arrays=>
386
+ {:should_include=>"true",
387
+ :description=>"",
388
+ :help=>"Tests whether the routines for writing arrays work",
389
+ :code_name=>:dummy_for_arrays,
390
+ :must_pass=>
391
+ [{:test=>"kind_of? Numeric",
392
+ :explanation=>
393
+ "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
394
+ :type=>:Float,
395
+ :autoscanned_defaults=>[]}}
@@ -54,6 +54,17 @@
54
54
  :explanation=>
55
55
  "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
56
56
  :type=>:Float,
57
+ :autoscanned_defaults=>[1.0]},
58
+ :dummy_for_arrays=>
59
+ {:should_include=>"true",
60
+ :description=>"",
61
+ :help=>"",
62
+ :code_name=>:dummy_for_arrays,
63
+ :must_pass=>
64
+ [{:test=>"kind_of? Numeric",
65
+ :explanation=>
66
+ "This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
67
+ :type=>:Float,
57
68
  :autoscanned_defaults=>[1.0]}}},
58
69
  :parameters=>{:description=>"", :should_include=>"true", :variables=>{}},
59
70
  :kt_grids_knobs=>{:description=>"", :should_include=>"true", :variables=>{}},
@@ -4,4 +4,5 @@
4
4
  width = 2.7
5
5
  depth = 3.9
6
6
  height = 8.2
7
+ dummy_for_arrays = 1.0
7
8
  /
@@ -736,9 +736,11 @@ int main(int argc, char* argv[]){
736
736
  }
737
737
 
738
738
  float* edges = new float[3];
739
+ float dummy_for_arrays;
739
740
  if (fnr_get_float(&namelist_file, "cubecalc", "width", &edges[0])) edges[0] = 1.0;
740
741
  if (fnr_get_float(&namelist_file, "cubecalc", "depth", &edges[1])) edges[1] = 1.0;
741
742
  if (fnr_get_float(&namelist_file, "cubecalc", "height", &edges[2])) edges[2] = 1.0;
743
+ if (fnr_get_float(&namelist_file, "cubecalc", "dummy_for_arrays(1)", &dummy_for_arrays)) dummy_for_arrays = 1.0;
742
744
  printf("edges[0] %f\n", edges[0]);
743
745
 
744
746
 
@@ -21,7 +21,7 @@ $coderunner_command = "#{$ruby_command} -I lib/ lib/coderunner.rb"
21
21
  #raise "Couldn't build test program using #{string}" unless system string
22
22
  #end
23
23
 
24
- if false
24
+ if true
25
25
  class TestSubmission < Test::Unit::TestCase
26
26
  def setup
27
27
  string = $cpp_command + ' ../cubecalc.cc -o cubecalc'
@@ -363,7 +363,7 @@ end # if false/true
363
363
  #end
364
364
  #
365
365
  #
366
- #ENV['CR_NON_INTERACTIVE'] = 'true'
366
+ ENV['CR_NON_INTERACTIVE'] = 'true'
367
367
  class TestFortranNamelistC < Test::Unit::TestCase
368
368
  def setup
369
369
  end
@@ -389,7 +389,7 @@ class TestFortranNamelistC < Test::Unit::TestCase
389
389
  CodeRunner::Cubecalc::WithNamelist.make_new_defaults_file('cubecalctest', 'test/cubecalc.in')
390
390
  FileUtils.mv('cubecalctest_defaults.rb', CodeRunner::Cubecalc::WithNamelist.rcp.user_defaults_location + '/cubecalctest_defaults.rb')
391
391
  FileUtils.makedirs(tfolder)
392
- CodeRunner.submit(C: 'cubecalc', m: 'with_namelist', Y: tfolder, X: Dir.pwd + '/test/cubecalc_namelist', D: 'cubecalctest')
392
+ CodeRunner.submit(C: 'cubecalc', m: 'with_namelist', Y: tfolder, X: Dir.pwd + '/test/cubecalc_namelist', D: 'cubecalctest', p: '{dummy_for_arrays: [0.5, 0.6]}')
393
393
  CodeRunner.status(Y: tfolder)
394
394
  runner = CodeRunner.fetch_runner(Y: tfolder)
395
395
  assert_equal(86.35, runner.run_list[1].volume.round(2))
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.12
4
+ version: 0.13.13
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-25 00:00:00.000000000 Z
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphkit