genecrmod 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/genecrmod.gemspec +9 -5
- data/lib/genecrmod/check_parameters.rb +89 -0
- data/lib/genecrmod/gene.rb +14 -5
- data/lib/genecrmod/hdf5.rb +9 -0
- data/lib/genecrmod/namelists.rb +19 -16
- data/test/linear_run/.CODE_RUNNER_TEMP_RUN_LIST_CACHE +0 -0
- metadata +19 -4
- data/test/helper.rb +0 -34
- data/test/test_genecrmod.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fdad6ba5f5786ffe8c504ccf813636d9860c611
|
4
|
+
data.tar.gz: a56f41d321bc965adc3505062e380750675ea475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce08f04cf24ab01379e81e9aca7c50555d54faf85202793216b72127816ef15ebf1e0c96b5da6eaa5e9ef20506a8592a1efcddcd263f2672c54299ac980ec467
|
7
|
+
data.tar.gz: def19cf656f3291b7ee2ce5f7b3de4425e3a9217e5698baf4fdc7d527228de77e25c8ea088198a8b04c3dcf9a451cdd8bd6a2c40935192317c93c78fc775d642
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -20,6 +20,7 @@ Jeweler::Tasks.new do |gem|
|
|
20
20
|
gem.summary = %Q{A module which allows the GENE gyrokinetic code to be run using the CodeRunner framework. }
|
21
21
|
gem.description = %Q{A module which allows the GENE gyrokinetic code to be run using the CodeRunner framework. }
|
22
22
|
gem.email = "edmundhighcock@users.sourceforge.net"
|
23
|
+
gem.files.exclude 'test/**/*'
|
23
24
|
gem.authors = ["Edmund Highcock"]
|
24
25
|
# dependencies defined in Gemfile
|
25
26
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/genecrmod.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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: genecrmod 0.
|
5
|
+
# stub: genecrmod 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "genecrmod"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Edmund Highcock"]
|
14
|
-
s.date = "2014-07-
|
14
|
+
s.date = "2014-07-23"
|
15
15
|
s.description = "A module which allows the GENE gyrokinetic code to be run using the CodeRunner framework. "
|
16
16
|
s.email = "edmundhighcock@users.sourceforge.net"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -27,12 +27,13 @@ Gem::Specification.new do |s|
|
|
27
27
|
"VERSION",
|
28
28
|
"genecrmod.gemspec",
|
29
29
|
"lib/genecrmod.rb",
|
30
|
+
"lib/genecrmod/check_parameters.rb",
|
30
31
|
"lib/genecrmod/gene.rb",
|
32
|
+
"lib/genecrmod/hdf5.rb",
|
31
33
|
"lib/genecrmod/namelists.rb",
|
32
34
|
"sync_variables/helper.rb",
|
33
35
|
"sync_variables/sync_variables.rb",
|
34
|
-
"test/
|
35
|
-
"test/test_genecrmod.rb"
|
36
|
+
"test/linear_run/.CODE_RUNNER_TEMP_RUN_LIST_CACHE"
|
36
37
|
]
|
37
38
|
s.homepage = "http://github.com/edmundhighcock/genecrmod"
|
38
39
|
s.licenses = ["GPLv3"]
|
@@ -44,6 +45,7 @@ Gem::Specification.new do |s|
|
|
44
45
|
|
45
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
47
|
s.add_runtime_dependency(%q<coderunner>, [">= 0.14.2"])
|
48
|
+
s.add_runtime_dependency(%q<hdf5>, [">= 0"])
|
47
49
|
s.add_development_dependency(%q<shoulda>, ["= 3.0.1"])
|
48
50
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
49
51
|
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
@@ -52,6 +54,7 @@ Gem::Specification.new do |s|
|
|
52
54
|
s.add_development_dependency(%q<minitest>, ["~> 4"])
|
53
55
|
else
|
54
56
|
s.add_dependency(%q<coderunner>, [">= 0.14.2"])
|
57
|
+
s.add_dependency(%q<hdf5>, [">= 0"])
|
55
58
|
s.add_dependency(%q<shoulda>, ["= 3.0.1"])
|
56
59
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
57
60
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
@@ -61,6 +64,7 @@ Gem::Specification.new do |s|
|
|
61
64
|
end
|
62
65
|
else
|
63
66
|
s.add_dependency(%q<coderunner>, [">= 0.14.2"])
|
67
|
+
s.add_dependency(%q<hdf5>, [">= 0"])
|
64
68
|
s.add_dependency(%q<shoulda>, ["= 3.0.1"])
|
65
69
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
66
70
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
class CodeRunner::Gene
|
3
|
+
def run_namelist_tests(namelist, hash, enum = nil)
|
4
|
+
ext = enum ? "_#{enum}" : ""
|
5
|
+
hash[:must_pass].each do |tst|
|
6
|
+
error(namelist_test_failed(namelist, tst)) unless instance_eval(tst[:test])
|
7
|
+
end if hash[:must_pass]
|
8
|
+
hash[:should_pass].each do |tst|
|
9
|
+
warning(namelist_test_failed(namelist, tst)) unless instance_eval(tst[:test])
|
10
|
+
end if hash[:should_pass]
|
11
|
+
hash[:variables].each do |var, var_hash|
|
12
|
+
#gs2_var = (var_hash[:gs2_name] or var)
|
13
|
+
cr_var = var+ext.to_sym
|
14
|
+
value = send(cr_var)
|
15
|
+
if value.kind_of? Array
|
16
|
+
value.each{|v| test_variable(namelist, var, var_hash, ext, v)}
|
17
|
+
else
|
18
|
+
test_variable(namelist, var, var_hash, ext, value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def check_parameters
|
23
|
+
rcp.namelists.each do |namelist, hash|
|
24
|
+
next if hash[:should_include].kind_of? String and not eval(hash[:should_include])
|
25
|
+
if en = hash[:enumerator]
|
26
|
+
#ep 'en', en, namelist
|
27
|
+
next unless send(en[:name])
|
28
|
+
send(en[:name]).times do |i|
|
29
|
+
run_namelist_tests(namelist, hash, i+1)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
run_namelist_tests(namelist, hash)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
warning("Very little analysis will be possible without write_h5 = '.true.'") if not (@write_h5 and @write_h5.fortran_true?)
|
36
|
+
end
|
37
|
+
def test_failed(namelist, var, gs2_var, tst)
|
38
|
+
return <<EOF
|
39
|
+
|
40
|
+
---------------------------
|
41
|
+
Test Failed
|
42
|
+
---------------------------
|
43
|
+
|
44
|
+
Namelist: #{namelist}
|
45
|
+
Variable: #{var}
|
46
|
+
GS2 Name: #{gs2_var}
|
47
|
+
Value: #{send(var)}
|
48
|
+
Test: #{tst[:test]}
|
49
|
+
Explanation: #{tst[:explanation]}
|
50
|
+
|
51
|
+
---------------------------
|
52
|
+
EOF
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def namelist_test_failed(namelist, tst)
|
58
|
+
return <<EOF
|
59
|
+
|
60
|
+
---------------------------
|
61
|
+
Test Failed
|
62
|
+
---------------------------
|
63
|
+
|
64
|
+
Namelist: #{namelist}
|
65
|
+
Test: #{tst[:test]}
|
66
|
+
Explanation: #{tst[:explanation]}
|
67
|
+
|
68
|
+
---------------------------
|
69
|
+
EOF
|
70
|
+
|
71
|
+
end
|
72
|
+
def test_variable(namelist, var, var_hash, ext, value)
|
73
|
+
gs2_var = (var_hash[:gs2_name] or var)
|
74
|
+
cr_var = var+ext.to_sym
|
75
|
+
if value and (not var_hash[:should_include] or eval(var_hash[:should_include]))
|
76
|
+
var_hash[:must_pass].each do |tst|
|
77
|
+
error(test_failed(namelist, cr_var, gs2_var, tst)) unless value.instance_eval(tst[:test])
|
78
|
+
end if var_hash[:must_pass]
|
79
|
+
var_hash[:should_pass].each do |tst|
|
80
|
+
warning(test_failed(namelist, cr_var, gs2_var, tst)) unless value.instance_eval(tst[:test])
|
81
|
+
end if var_hash[:should_pass]
|
82
|
+
if (var_hash[:allowed_values] or var_hash[:text_options])
|
83
|
+
tst = {test: "#{(var_hash[:allowed_values] or var_hash[:text_options]).inspect}.include? self", explanation: "The variable must have one of these values"}
|
84
|
+
error(test_failed(namelist, cr_var, gs2_var, tst)) unless value.instance_eval(tst[:test])
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/genecrmod/gene.rb
CHANGED
@@ -13,6 +13,9 @@ class CodeRunner
|
|
13
13
|
# Where this file is
|
14
14
|
@code_module_folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
|
15
15
|
|
16
|
+
require @code_module_folder + '/hdf5.rb'
|
17
|
+
require @code_module_folder + '/check_parameters.rb'
|
18
|
+
|
16
19
|
# Use the Run::FortranNamelist tools to process the variable database
|
17
20
|
setup_namelists(@code_module_folder)
|
18
21
|
|
@@ -156,8 +159,6 @@ class CodeRunner
|
|
156
159
|
text
|
157
160
|
end
|
158
161
|
|
159
|
-
def check_parameters
|
160
|
-
end
|
161
162
|
|
162
163
|
|
163
164
|
|
@@ -204,7 +205,7 @@ class CodeRunner
|
|
204
205
|
end
|
205
206
|
|
206
207
|
def get_status
|
207
|
-
if @running
|
208
|
+
if @running
|
208
209
|
if @status != :Queueing
|
209
210
|
get_completed_timesteps
|
210
211
|
if completed_timesteps == 0
|
@@ -228,7 +229,11 @@ class CodeRunner
|
|
228
229
|
end
|
229
230
|
def get_completed_timesteps
|
230
231
|
Dir.chdir(@directory) do
|
231
|
-
|
232
|
+
if FileTest.exist?('nrg.dat.h5')
|
233
|
+
@completed_timesteps = get_h5_narray_all('nrg.dat.h5', '/nrgIons/time').shape[0]
|
234
|
+
else
|
235
|
+
@completed_timesteps = %x[grep '^\\s\\+\\S\\+\\s*$' nrg.dat 2>/dev/null].split("\n").size
|
236
|
+
end
|
232
237
|
end
|
233
238
|
end
|
234
239
|
|
@@ -282,7 +287,11 @@ EOF1
|
|
282
287
|
|
283
288
|
def get_growth_rates
|
284
289
|
Dir.chdir(@directory) do
|
285
|
-
if FileTest.exist?('omega.dat')
|
290
|
+
if FileTest.exist?(ofile = 'omega.dat.h5')
|
291
|
+
@kyvals = get_h5_narray_all(ofile, '/ky').to_gslv
|
292
|
+
@growth_rates = get_h5_narray_all(ofile, '/gamma').to_gslv
|
293
|
+
@frequencies = get_h5_narray_all(ofile, '/omega').to_gslv
|
294
|
+
elsif FileTest.exist?('omega.dat')
|
286
295
|
@kyvals, @growth_rates, @frequencies = GSL::Vector.filescan('omega.dat')
|
287
296
|
else
|
288
297
|
@kyvals, @growth_rates, @frequencies = [[]] * 3
|
data/lib/genecrmod/namelists.rb
CHANGED
@@ -461,18 +461,20 @@
|
|
461
461
|
:help=>nil,
|
462
462
|
:code_name=>:kymin,
|
463
463
|
:must_pass=>
|
464
|
-
[{:test=>"kind_of?
|
465
|
-
:explanation=>
|
466
|
-
|
464
|
+
[{:test=>"kind_of? Numeric",
|
465
|
+
:explanation=>
|
466
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
467
|
+
:type=>:Float},
|
467
468
|
:lv=>
|
468
469
|
{:should_include=>"true",
|
469
470
|
:description=>nil,
|
470
471
|
:help=>nil,
|
471
472
|
:code_name=>:lv,
|
472
473
|
:must_pass=>
|
473
|
-
[{:test=>"kind_of?
|
474
|
-
:explanation=>
|
475
|
-
|
474
|
+
[{:test=>"kind_of? Numeric",
|
475
|
+
:explanation=>
|
476
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
477
|
+
:type=>:Float},
|
476
478
|
:lw=>
|
477
479
|
{:should_include=>"true",
|
478
480
|
:description=>nil,
|
@@ -537,9 +539,10 @@
|
|
537
539
|
:help=>nil,
|
538
540
|
:code_name=>:x0,
|
539
541
|
:must_pass=>
|
540
|
-
[{:test=>"kind_of?
|
541
|
-
:explanation=>
|
542
|
-
|
542
|
+
[{:test=>"kind_of? Numeric",
|
543
|
+
:explanation=>
|
544
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
545
|
+
:type=>:Float},
|
543
546
|
:mu_grid_type=>
|
544
547
|
{:should_include=>"true",
|
545
548
|
:description=>nil,
|
@@ -618,10 +621,9 @@
|
|
618
621
|
:help=>nil,
|
619
622
|
:code_name=>:comp_type,
|
620
623
|
:must_pass=>
|
621
|
-
[{:test=>"kind_of? String
|
622
|
-
:explanation=>
|
623
|
-
|
624
|
-
:type=>:Fortran_Bool},
|
624
|
+
[{:test=>"kind_of? String",
|
625
|
+
:explanation=>"This variable must be a string."}],
|
626
|
+
:type=>:String},
|
625
627
|
:perf_vec=>
|
626
628
|
{:should_include=>"true",
|
627
629
|
:description=>nil,
|
@@ -3157,9 +3159,10 @@
|
|
3157
3159
|
:help=>nil,
|
3158
3160
|
:code_name=>:bref,
|
3159
3161
|
:must_pass=>
|
3160
|
-
[{:test=>"kind_of?
|
3161
|
-
:explanation=>
|
3162
|
-
|
3162
|
+
[{:test=>"kind_of? Numeric",
|
3163
|
+
:explanation=>
|
3164
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
3165
|
+
:type=>:Float},
|
3163
3166
|
:mref=>
|
3164
3167
|
{:should_include=>"true",
|
3165
3168
|
:description=>nil,
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genecrmod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edmund Highcock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderunner
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.14.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hdf5
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: shoulda
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,12 +139,13 @@ files:
|
|
125
139
|
- VERSION
|
126
140
|
- genecrmod.gemspec
|
127
141
|
- lib/genecrmod.rb
|
142
|
+
- lib/genecrmod/check_parameters.rb
|
128
143
|
- lib/genecrmod/gene.rb
|
144
|
+
- lib/genecrmod/hdf5.rb
|
129
145
|
- lib/genecrmod/namelists.rb
|
130
146
|
- sync_variables/helper.rb
|
131
147
|
- sync_variables/sync_variables.rb
|
132
|
-
- test/
|
133
|
-
- test/test_genecrmod.rb
|
148
|
+
- test/linear_run/.CODE_RUNNER_TEMP_RUN_LIST_CACHE
|
134
149
|
homepage: http://github.com/edmundhighcock/genecrmod
|
135
150
|
licenses:
|
136
151
|
- GPLv3
|
data/test/helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
module SimpleCov::Configuration
|
4
|
-
def clean_filters
|
5
|
-
@filters = []
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
SimpleCov.configure do
|
10
|
-
clean_filters
|
11
|
-
load_adapter 'test_frameworks'
|
12
|
-
end
|
13
|
-
|
14
|
-
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
-
add_filter "/.rvm/"
|
16
|
-
end
|
17
|
-
require 'rubygems'
|
18
|
-
require 'bundler'
|
19
|
-
begin
|
20
|
-
Bundler.setup(:default, :development)
|
21
|
-
rescue Bundler::BundlerError => e
|
22
|
-
$stderr.puts e.message
|
23
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
-
exit e.status_code
|
25
|
-
end
|
26
|
-
require 'test/unit'
|
27
|
-
require 'shoulda'
|
28
|
-
|
29
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
31
|
-
require 'genecrmod'
|
32
|
-
|
33
|
-
class Test::Unit::TestCase
|
34
|
-
end
|