trinitycrdriver 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +7 -2
- data/Rakefile +10 -0
- data/VERSION +1 -1
- data/clean.sh +9 -0
- data/ext/trinitycrdriver/extconf.rb +42 -0
- data/ext/trinitycrdriver/trinitycrdriver.c +69 -0
- data/lib/trinitycrdriver/optimisation.rb +100 -0
- data/lib/trinitycrdriver.rb +35 -0
- data/lib/trinoptcrmod/trinopt.rb +174 -0
- data/lib/trinoptcrmod.rb +1 -0
- data/trinitycrdriver.gemspec +92 -0
- metadata +88 -12
- data/test/helper.rb +0 -34
- data/test/test_trinitycrdriver.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49e4039f446adecc1130738a3d689af2a3193c61
|
4
|
+
data.tar.gz: 65142591fe93ea98359f1edf1bd2cdb9043745d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84b29e1c9e3272fba5a1b4fb5815fc4cfcfec9e8a352b8195d5b0289e2881cfe8d9beaa459083433ace8f63bd8fd38d5aebcfdf922c3bd1dca4052706a4c1353
|
7
|
+
data.tar.gz: ac3d4cf4163d2be4bf1459bf2ef7d8b9d20e478958e0ba82f634704458bfec2cd20e650140ba3acb53d7abd4ef227ae173344d3ef7c550a40b0aaabdc09f4dbe
|
data/Gemfile
CHANGED
@@ -5,12 +5,17 @@ source "http://rubygems.org"
|
|
5
5
|
gem "text-data-tools", ">= 1.1.3"
|
6
6
|
gem "gs2crmod", ">=0.11.33"
|
7
7
|
gem "trinitycrmod", ">= 0.4.7"
|
8
|
+
gem "ruby-mpi", ">=0.2.0"
|
9
|
+
gem "cheasecrmod", ">=0.1.0"
|
8
10
|
|
9
11
|
# Add dependencies to develop your gem here.
|
10
12
|
# Include everything needed to run rake, tests, features, etc.
|
11
13
|
group :development do
|
12
|
-
gem "shoulda", "
|
14
|
+
gem "shoulda", " 3.0.1"
|
13
15
|
gem "rdoc", "~> 3.12"
|
14
16
|
gem "bundler", "> 1.0.0"
|
15
|
-
gem "jeweler", ">= 2.0.
|
17
|
+
gem "jeweler", ">= 2.0.1"
|
18
|
+
gem "simplecov", ">=0"
|
19
|
+
gem "minitest", "~> 4"
|
20
|
+
gem "rake-compiler"
|
16
21
|
end
|
data/Rakefile
CHANGED
@@ -21,6 +21,8 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.description = %Q{A gem to allow coderunner to run the trinity code directly.}
|
22
22
|
gem.email = "edmundhighcock@users.sourceforge.net"
|
23
23
|
gem.authors = ["Edmund Highcock"]
|
24
|
+
gem.files.exclude 'test/**/*'
|
25
|
+
gem.extensions = %w[ext/trinitycrdriver/extconf.rb]
|
24
26
|
# dependencies defined in Gemfile
|
25
27
|
end
|
26
28
|
Jeweler::RubygemsDotOrgTasks.new
|
@@ -49,3 +51,11 @@ Rake::RDocTask.new do |rdoc|
|
|
49
51
|
rdoc.rdoc_files.include('README*')
|
50
52
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
53
|
end
|
54
|
+
|
55
|
+
NAME = 'trinitycrdriver'
|
56
|
+
|
57
|
+
require "rake/extensiontask"
|
58
|
+
|
59
|
+
Rake::ExtensionTask.new "trinitycrdriver" do |ext|
|
60
|
+
ext.lib_dir = "lib/trinitycrdriver"
|
61
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/clean.sh
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
rm -rf lib/trinitycrdriver/trinitycrdriver.so
|
2
|
+
rm -rf rake_test_opt_chease_defaults.rb
|
3
|
+
rm -rf rake_test_opt_defaults.rb
|
4
|
+
rm -rf test/chease_opt/.CODE_RUNNER_TEMP_RUN_LIST_CACHE
|
5
|
+
rm -rf test/chease_opt/ogyropsi.dat
|
6
|
+
rm -rf test/chease_opt/v/
|
7
|
+
rm -rf test/chease_opt_chease/.CODE_RUNNER_TEMP_RUN_LIST_CACHE
|
8
|
+
rm -rf test/chease_opt_chease/v/
|
9
|
+
rm -rf test/trinopt/
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
#Need to link with C GSL libraries to use in C extensions
|
4
|
+
#gsl_inc = `gsl-config --cflags`
|
5
|
+
|
6
|
+
#$CFLAGS = " -Wall -I../include #{gsl_inc}"
|
7
|
+
|
8
|
+
#srcs = Dir.glob("*.c")
|
9
|
+
|
10
|
+
#p ['srcs', srcs]
|
11
|
+
|
12
|
+
#$objs = srcs.collect { |f| f.sub(".c", ".o") }
|
13
|
+
RbConfig::CONFIG['CC'] = CONFIG['CC'] = ENV['CC'] || "mpicc"
|
14
|
+
RbConfig::CONFIG['CPP'] = CONFIG['CPP'] = ENV['CPP'] || "mpicc -E"
|
15
|
+
p 'CONFIG[CC]', CONFIG['CC']
|
16
|
+
crgemspec=Gem::Specification.find_by_name('coderunner')
|
17
|
+
crconfig = crgemspec.full_gem_path
|
18
|
+
$CPPFLAGS = " -I#{File.join(crconfig, 'include')} "+$CPPFLAGS
|
19
|
+
p ['CPPFLAGS', $CPPFLAGS]
|
20
|
+
raise "Please set the environment variable TRINITY_DIR" unless ENV['TRINITY_DIR']
|
21
|
+
$LOCAL_LIBS = " -L#{ENV['TRINITY_DIR']} " + $LOCAL_LIBS
|
22
|
+
$LOCAL_LIBS = " -L#{ENV['GS2']} " + $LOCAL_LIBS
|
23
|
+
have_library("gfortran")
|
24
|
+
have_library("netcdf")
|
25
|
+
have_library("netcdff")
|
26
|
+
have_library("fftw3")
|
27
|
+
have_library("fftw3f")
|
28
|
+
have_library("fftw3_mpi")
|
29
|
+
have_library("fftw3f_mpi")
|
30
|
+
have_library("simpledataio")
|
31
|
+
|
32
|
+
#have_library("gs2", "__gs2_main_MOD_gs2spec_from_trin")
|
33
|
+
have_library("gs2")
|
34
|
+
have_library("trinity")
|
35
|
+
|
36
|
+
dir_config('mpi')
|
37
|
+
have_header("mpi.h")
|
38
|
+
have_library("mpi")
|
39
|
+
have_library("mpi_f90")
|
40
|
+
have_library("mpi_f77")
|
41
|
+
|
42
|
+
create_makefile("trinitycrdriver/trinitycrdriver")
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#include <math.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include "code_runner_ext.h"
|
4
|
+
#include <mpi.h>
|
5
|
+
#include <stdbool.h>
|
6
|
+
|
7
|
+
/* Taken from the ruby-mpi gem*/
|
8
|
+
struct _Comm {
|
9
|
+
MPI_Comm Comm;
|
10
|
+
bool free;
|
11
|
+
};
|
12
|
+
|
13
|
+
static VALUE trinitycrdriver_run_trinity(VALUE class, VALUE input_file_name, VALUE mpi_comm){
|
14
|
+
printf("RUNNING TRINITY!!!\n\n");
|
15
|
+
|
16
|
+
struct _Comm *comm;
|
17
|
+
char * input_file_name_c;
|
18
|
+
|
19
|
+
Data_Get_Struct(mpi_comm, struct _Comm, comm);
|
20
|
+
input_file_name_c = StringValueCStr(input_file_name);
|
21
|
+
run_trinity_c(input_file_name_c, comm->Comm);
|
22
|
+
|
23
|
+
/*printf("input file name was %s\n", input_file_name_c);*/
|
24
|
+
/**/
|
25
|
+
/*free(input_file_name_c);*/
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
return Qnil;
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
void Init_trinitycrdriver()
|
34
|
+
{
|
35
|
+
|
36
|
+
VALUE ctrinity;
|
37
|
+
|
38
|
+
cgraph_kit = Qnil;
|
39
|
+
ccode_runner_gs2 = Qnil;
|
40
|
+
ccode_runner_ext = Qnil;
|
41
|
+
printf("HERE!!!\n\n");
|
42
|
+
ccode_runner = RGET_CLASS_TOP("CodeRunner");
|
43
|
+
/*VALUE ctrinity = RGET_CLASS_TOP("CodeRunner");*/
|
44
|
+
ctrinity = RGET_CLASS(ccode_runner, "Trinity");
|
45
|
+
rb_define_method(ctrinity, "run_trinity", trinitycrdriver_run_trinity, 2);
|
46
|
+
/*rb_define_class_under(ccode_runner, "Trinity",*/
|
47
|
+
/*RGET_CLASS(*/
|
48
|
+
/*RGET_CLASS(ccode_runner, "Run"), */
|
49
|
+
/*"FortranNamelist"*/
|
50
|
+
/*)*/
|
51
|
+
/*);*/
|
52
|
+
|
53
|
+
/*ccode_runner_gs2_gsl_tensor_complexes = rb_define_module_under(ccode_runner_gs2, "GSLComplexTensors");*/
|
54
|
+
/*rb_include_module(ccode_runner_gs2, ccode_runner_gs2_gsl_tensor_complexes);*/
|
55
|
+
|
56
|
+
/*ccode_runner_gs2_gsl_tensors = rb_define_module_under(ccode_runner_gs2, "GSLTensors"); */
|
57
|
+
/*rb_include_module(ccode_runner_gs2, ccode_runner_gs2_gsl_tensors);*/
|
58
|
+
|
59
|
+
/*cgsl = RGET_CLASS_TOP("GSL");*/
|
60
|
+
/*cgsl_vector = RGET_CLASS(cgsl, "Vector");*/
|
61
|
+
/*cgsl_vector_complex = RGET_CLASS(cgsl_vector, "Complex");*/
|
62
|
+
|
63
|
+
/*rb_define_method(ccode_runner_gs2_gsl_tensor_complexes, "field_gsl_tensor_complex_2", gs2crmod_tensor_complexes_field_gsl_tensor_complex_2, 1);*/
|
64
|
+
/*rb_define_method(ccode_runner_gs2_gsl_tensors, "field_real_space_gsl_tensor", gs2crmod_tensor_field_gsl_tensor, 1);*/
|
65
|
+
/*rb_define_method(ccode_runner_gs2_gsl_tensors, "field_correlation_gsl_tensor", gs2crmod_tensor_field_correlation_gsl_tensor, 1);*/
|
66
|
+
|
67
|
+
/*rb_define_method(ccode_runner_ext, "hello_world", code_runner_ext_hello_world, 0);*/
|
68
|
+
}
|
69
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
class CodeRunner::Trinity::Optimisation
|
3
|
+
include GSL::MultiMin
|
4
|
+
# optimisation_spec is a hash of {:code_name => {:variable => [initial_guess, dimension_scale_factor]}}
|
5
|
+
# dimension_scale_factor is just some estimate of the length scale in which the result
|
6
|
+
# varies significantly
|
7
|
+
# code_name is either trinity or chease (both can be used simultaneously)
|
8
|
+
attr_reader :optimisation_spec
|
9
|
+
attr_reader :optimisation_variables
|
10
|
+
attr_accessor :trinity_runner
|
11
|
+
attr_accessor :chease_runner
|
12
|
+
def initialize(optimised_quantity, optimisation_spec)
|
13
|
+
#@folder = folder
|
14
|
+
@optimised_quantity = optimised_quantity
|
15
|
+
@optimisation_spec = optimisation_spec
|
16
|
+
@optimisation_variables = optimisation_spec.map{|code, hash| hash.map{|var, pars| [code, var]}}.flatten(1)
|
17
|
+
@optimisation_starts = optimisation_spec.map{|code, hash| hash.map{|var, pars| pars[0]}}.flatten(1)
|
18
|
+
@optimisation_steps = optimisation_spec.map{|code, hash| hash.map{|var, pars| pars[1]}}.flatten(1)
|
19
|
+
#@runner = CodeRunner.fetch_runner(
|
20
|
+
#p ['optimisation_variables', @optimisation_variables]
|
21
|
+
end
|
22
|
+
def dimension
|
23
|
+
@optimisation_variables.size
|
24
|
+
end
|
25
|
+
def serial_optimise(optimisation_method, parameters_obj)
|
26
|
+
optimisation_meth = case optimisation_method
|
27
|
+
when :simplex
|
28
|
+
FMinimizer::NMSIMPLEX
|
29
|
+
else
|
30
|
+
raise "Unknown optimisation_method"
|
31
|
+
end
|
32
|
+
opt = FMinimizer.alloc(optimisation_meth, @optimisation_variables.size)
|
33
|
+
func = Proc.new{|v, optimiser| optimiser.func(v)}
|
34
|
+
gsl_func = Function.alloc(func, dimension)
|
35
|
+
gsl_func.set_params(self)
|
36
|
+
opt.set(gsl_func, @optimisation_starts.to_gslv, @optimisation_steps.to_gslv)
|
37
|
+
parameters_obj.nit.times do |i|
|
38
|
+
opt.iterate
|
39
|
+
p ['status', opt.x, opt.minimum, i, parameters_obj.nit]
|
40
|
+
end
|
41
|
+
|
42
|
+
p 'heellllllo'
|
43
|
+
MPI.Finalize
|
44
|
+
|
45
|
+
end
|
46
|
+
def func(v)
|
47
|
+
pars = {}
|
48
|
+
pars[:chease] = {}
|
49
|
+
pars[:trinity] = {}
|
50
|
+
for i in 0...v.size
|
51
|
+
code, varname = @optimisation_variables[i]
|
52
|
+
val = v[i]
|
53
|
+
pars[code][varname] = val
|
54
|
+
end
|
55
|
+
if not @first_run_done
|
56
|
+
pars[:trinity][:ntstep] = 300
|
57
|
+
#@first_run_done = true
|
58
|
+
#else
|
59
|
+
#pars[:trinity][:ntstep] = 100
|
60
|
+
end
|
61
|
+
|
62
|
+
pars[:chease][:ap] = [0.3,0.5,0.4,0.0,0.4,0.0,0.0]
|
63
|
+
pars[:chease][:at] = [0.16,1.0,1.0,-1.1,-1.1]
|
64
|
+
|
65
|
+
|
66
|
+
trinity_runner.run_class.instance_variable_set(:@mpi_communicator, MPI::Comm::WORLD)
|
67
|
+
if false and trinity_runner.run_list.size > 0
|
68
|
+
else
|
69
|
+
crun = chease_runner.run_class.new(chease_runner)
|
70
|
+
crun.update_submission_parameters(pars[:chease].inspect)
|
71
|
+
if chease_runner.run_list.size > 0
|
72
|
+
crun.restart_id = @cid
|
73
|
+
end
|
74
|
+
chease_runner.submit(crun)
|
75
|
+
crun = chease_runner.run_list[@cid = chease_runner.max_id]
|
76
|
+
crun.recheck
|
77
|
+
chease_runner.update
|
78
|
+
#chease_runner.print_out(0)
|
79
|
+
FileUtils.cp(crun.directory + '/ogyropsi.dat', trinity_runner.root_folder + '/.')
|
80
|
+
|
81
|
+
run = trinity_runner.run_class.new(trinity_runner)
|
82
|
+
run.update_submission_parameters(pars[:trinity].inspect)
|
83
|
+
#trinity_runner.run_class.instance_variable_set(:@delay_execution, true)
|
84
|
+
if trinity_runner.run_list.size > 0
|
85
|
+
#run.restart_id = @id
|
86
|
+
end
|
87
|
+
trinity_runner.submit(run)
|
88
|
+
run = trinity_runner.run_list[@id = trinity_runner.max_id]
|
89
|
+
run.recheck
|
90
|
+
trinity_runner.update
|
91
|
+
#trinity_runner.print_out(0)
|
92
|
+
result = run.send(@optimised_quantity)
|
93
|
+
p ['result is ', result]
|
94
|
+
return -result
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
#v.square.sum
|
99
|
+
end
|
100
|
+
end
|
data/lib/trinitycrdriver.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
require 'trinitycrdriver/trinitycrdriver'
|
3
|
+
require 'mpi'
|
4
|
+
|
5
|
+
class CodeRunner::Trinity
|
6
|
+
# We overwrite the system module's implemenation of this command.
|
7
|
+
# Instead of running trinity via a bash command or a batch script,
|
8
|
+
# we run it directly via its API.
|
9
|
+
@delay_execution = false
|
10
|
+
def execute
|
11
|
+
if rcp.delay_execution
|
12
|
+
return
|
13
|
+
else
|
14
|
+
execute_actual
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def execute_actual
|
18
|
+
Dir.chdir(@directory){
|
19
|
+
if rcp.mpi_communicator?
|
20
|
+
start_mpi = false
|
21
|
+
mpicomm = rcp.mpi_communicator
|
22
|
+
else
|
23
|
+
start_mpi = true
|
24
|
+
MPI.Init
|
25
|
+
mpicomm = MPI::Comm::WORLD
|
26
|
+
puts ["INITIALISED MPI", mpicomm.size ]
|
27
|
+
end
|
28
|
+
run_trinity(@run_name + ".trin", mpicomm)
|
29
|
+
if start_mpi
|
30
|
+
MPI.Finalize
|
31
|
+
end
|
32
|
+
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
|
2
|
+
class CodeRunner
|
3
|
+
# This is a customised subclass of the CodeRunner::Run class which is designed to run the CodeRunner/Trinity optimisation framework
|
4
|
+
#
|
5
|
+
class Trinopt < Run
|
6
|
+
|
7
|
+
# Where this file is
|
8
|
+
@code_module_folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
|
9
|
+
|
10
|
+
|
11
|
+
################################################
|
12
|
+
# Quantities that are read or determined by CodeRunner
|
13
|
+
# after the simulation has ended
|
14
|
+
###################################################
|
15
|
+
|
16
|
+
@results = [
|
17
|
+
]
|
18
|
+
|
19
|
+
@code_long="CodeRunner/Trinity Optimisation Framework"
|
20
|
+
|
21
|
+
@run_info=[:time, :is_a_restart, :restart_id, :restart_run_name, :completed_steps, :percent_complete]
|
22
|
+
|
23
|
+
@variables = [
|
24
|
+
:chease_exec,
|
25
|
+
:output,
|
26
|
+
:search,
|
27
|
+
:trinity_defaults,
|
28
|
+
:gs_defaults,
|
29
|
+
:nit
|
30
|
+
]
|
31
|
+
|
32
|
+
@uses_mpi = true
|
33
|
+
|
34
|
+
@modlet_required = false
|
35
|
+
|
36
|
+
@naming_pars = []
|
37
|
+
|
38
|
+
# Any folders which are a number will contain the results from flux simulations.
|
39
|
+
@excluded_sub_folders = ['trinity_runs', 'chease_runs', 'ecom_runs']
|
40
|
+
|
41
|
+
# A hook which gets called when printing the standard run information to the screen using the status command.
|
42
|
+
def print_out_line
|
43
|
+
#p ['id', id, 'ctd', ctd]
|
44
|
+
#p rcp.results.zip(rcp.results.map{|r| send(r)})
|
45
|
+
name = @run_name
|
46
|
+
name += " (res: #@restart_id)" if @restart_id
|
47
|
+
beginning = sprintf("%2d:%d %-60s %1s:%2.1f(%s) %3s%1s", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, "%")
|
48
|
+
if ctd
|
49
|
+
#beginning += sprintf("Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20", fusionQ, pfus, ti0, te0, ne0)
|
50
|
+
end
|
51
|
+
beginning += " ---#{@comment}" if @comment
|
52
|
+
beginning
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# Modify new_run so that it becomes a restart of self. Adusts
|
58
|
+
# all the parameters of the new run to be equal to the parameters
|
59
|
+
# of the run that calls this function, and sets up its run name
|
60
|
+
# correctly
|
61
|
+
def restart(new_run)
|
62
|
+
#new_run = self.dup
|
63
|
+
(rcp.variables).each{|v| new_run.set(v, send(v)) if send(v)}
|
64
|
+
new_run.is_a_restart = true
|
65
|
+
new_run.restart_id = @id
|
66
|
+
new_run.restart_run_name = @run_name
|
67
|
+
new_run.nopt = -1
|
68
|
+
new_run.run_name = nil
|
69
|
+
new_run.naming_pars = @naming_pars
|
70
|
+
new_run.update_submission_parameters(new_run.parameter_hash.inspect, false) if new_run.parameter_hash
|
71
|
+
new_run.naming_pars.delete(:restart_id)
|
72
|
+
new_run.generate_run_name
|
73
|
+
raise "This function is not complete"
|
74
|
+
end
|
75
|
+
# This is a hook which gets called just before submitting a simulation. It sets up the folder and generates any necessary input files.
|
76
|
+
def generate_input_file
|
77
|
+
check_parameters
|
78
|
+
if @restart_id
|
79
|
+
@runner.run_list[@restart_id].restart(self)
|
80
|
+
end
|
81
|
+
File.open("driver_script.rb", "w"){|f| f.puts optimisation_script}
|
82
|
+
FileUtils.makedirs('trinity_runs')
|
83
|
+
FileUtils.makedirs('gs_runs')
|
84
|
+
FileUtils.ln_s("../../#{@trinity_defaults}_defaults.rb", "trinity_runs")
|
85
|
+
FileUtils.ln_s("../../#{@gs_defaults}_defaults.rb", "gs_runs")
|
86
|
+
save
|
87
|
+
end
|
88
|
+
|
89
|
+
def optimisation_script
|
90
|
+
return <<EOF
|
91
|
+
require 'coderunner'
|
92
|
+
CodeRunner.setup_run_class('trinity')
|
93
|
+
CodeRunner.setup_run_class('trinopt')
|
94
|
+
require 'trinitycrdriver'
|
95
|
+
require 'trinitycrdriver/optimisation'
|
96
|
+
CodeRunner::Trinopt.run_optimisation(#@id)
|
97
|
+
EOF
|
98
|
+
end
|
99
|
+
|
100
|
+
def check_parameters
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
def self.run_optimisation(id = ARGV[-1])
|
105
|
+
MPI.Init
|
106
|
+
@runner = CodeRunner.fetch_runner(Y: '../../', U: true)
|
107
|
+
#@run = @runner.run_list[id.to_i]
|
108
|
+
@run = self.load(Dir.pwd, @runner)
|
109
|
+
#raise "Can't find run with id #{id}; #{@runner.run_list.keys}" unless @run
|
110
|
+
opt = CodeRunner::Trinity::Optimisation.new(
|
111
|
+
@run.output, @run.search
|
112
|
+
)
|
113
|
+
@trinity_runner = CodeRunner.fetch_runner(Y: 'trinity_runs', X: '/dev/null', C: 'trinity', D: @run.trinity_defaults)
|
114
|
+
@trinity_runner.nprocs = MPI::Comm::WORLD.size
|
115
|
+
@chease_runner = CodeRunner.fetch_runner(Y: 'gs_runs', X: @run.chease_exec, C: 'chease', D: @run.gs_defaults)
|
116
|
+
@chease_runner.nprocs = '1'
|
117
|
+
#Dir.chdir('trinity_runs'){@trinity_runner.run_class.use_new_defaults_file('rake_test_opt', 'ifspppl_chease_input.trin')}
|
118
|
+
#Dir.chdir(tfolderchease){@chease_runner.run_class.use_new_defaults_file('rake_test_opt_chease', 'chease_example.in')}
|
119
|
+
#assert_equal([:trinity, :powerin], opt.optimisation_variables[0])
|
120
|
+
opt.trinity_runner = @trinity_runner
|
121
|
+
opt.chease_runner = @chease_runner
|
122
|
+
opt.serial_optimise(:simplex, @run)
|
123
|
+
MPI.Finalize
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
def vim_output
|
129
|
+
system "vim -Ro #{output_file} #{error_file}"
|
130
|
+
end
|
131
|
+
alias :vo :vim_output
|
132
|
+
|
133
|
+
|
134
|
+
# Parameters which follow the Trinity executable, in this case just the input file.
|
135
|
+
def parameter_string
|
136
|
+
" driver_script.rb #@id"
|
137
|
+
end
|
138
|
+
|
139
|
+
def parameter_transition
|
140
|
+
end
|
141
|
+
|
142
|
+
def generate_component_runs
|
143
|
+
#puts "HERE"
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
@source_code_subfolders = []
|
149
|
+
|
150
|
+
# This method, as its name suggests, is called whenever CodeRunner is asked to analyse a run directory. This happens if the run status is not :Complete, or if the user has specified recalc_all(-A on the command line) or reprocess_all (-a on the command line).
|
151
|
+
#
|
152
|
+
def process_directory_code_specific
|
153
|
+
get_status
|
154
|
+
#p ['id is', id, 'ctd is ', ctd]
|
155
|
+
#if ctd
|
156
|
+
#get_global_results
|
157
|
+
#end
|
158
|
+
#p ['fusionQ is ', fusionQ]
|
159
|
+
#@percent_complete = completed_timesteps.to_f / ntstep.to_f * 100.0
|
160
|
+
@percent_complete = 0.0
|
161
|
+
end
|
162
|
+
|
163
|
+
def get_status
|
164
|
+
return :Unknown
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
def input_file_extension
|
169
|
+
''
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
data/lib/trinoptcrmod.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'trinoptcrmod/trinopt'
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: trinitycrdriver 0.1.0 ruby lib
|
6
|
+
# stub: ext/trinitycrdriver/extconf.rb
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "trinitycrdriver"
|
10
|
+
s.version = "0.1.0"
|
11
|
+
|
12
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.authors = ["Edmund Highcock"]
|
15
|
+
s.date = "2015-07-23"
|
16
|
+
s.description = "A gem to allow coderunner to run the trinity code directly."
|
17
|
+
s.email = "edmundhighcock@users.sourceforge.net"
|
18
|
+
s.extensions = ["ext/trinitycrdriver/extconf.rb"]
|
19
|
+
s.extra_rdoc_files = [
|
20
|
+
"LICENSE.txt",
|
21
|
+
"README.rdoc"
|
22
|
+
]
|
23
|
+
s.files = [
|
24
|
+
".document",
|
25
|
+
"Gemfile",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"clean.sh",
|
31
|
+
"ext/trinitycrdriver/extconf.rb",
|
32
|
+
"ext/trinitycrdriver/trinitycrdriver.c",
|
33
|
+
"lib/trinitycrdriver.rb",
|
34
|
+
"lib/trinitycrdriver/optimisation.rb",
|
35
|
+
"lib/trinoptcrmod.rb",
|
36
|
+
"lib/trinoptcrmod/trinopt.rb",
|
37
|
+
"trinitycrdriver.gemspec"
|
38
|
+
]
|
39
|
+
s.homepage = "http://github.com/edmundhighcock/trinitycrdriver"
|
40
|
+
s.licenses = ["GPLv3"]
|
41
|
+
s.rubygems_version = "2.4.8"
|
42
|
+
s.summary = "A gem to allow coderunner to run the trinity code directly via a C interface."
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 4
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<coderunner>, [">= 0.14.2"])
|
49
|
+
s.add_runtime_dependency(%q<text-data-tools>, [">= 1.1.3"])
|
50
|
+
s.add_runtime_dependency(%q<gs2crmod>, [">= 0.11.33"])
|
51
|
+
s.add_runtime_dependency(%q<trinitycrmod>, [">= 0.4.7"])
|
52
|
+
s.add_runtime_dependency(%q<ruby-mpi>, [">= 0.2.0"])
|
53
|
+
s.add_runtime_dependency(%q<cheasecrmod>, [">= 0.1.0"])
|
54
|
+
s.add_development_dependency(%q<shoulda>, ["= 3.0.1"])
|
55
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
56
|
+
s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
|
57
|
+
s.add_development_dependency(%q<jeweler>, [">= 2.0.1"])
|
58
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<minitest>, ["~> 4"])
|
60
|
+
s.add_development_dependency(%q<rake-compiler>, [">= 0"])
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<coderunner>, [">= 0.14.2"])
|
63
|
+
s.add_dependency(%q<text-data-tools>, [">= 1.1.3"])
|
64
|
+
s.add_dependency(%q<gs2crmod>, [">= 0.11.33"])
|
65
|
+
s.add_dependency(%q<trinitycrmod>, [">= 0.4.7"])
|
66
|
+
s.add_dependency(%q<ruby-mpi>, [">= 0.2.0"])
|
67
|
+
s.add_dependency(%q<cheasecrmod>, [">= 0.1.0"])
|
68
|
+
s.add_dependency(%q<shoulda>, ["= 3.0.1"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
71
|
+
s.add_dependency(%q<jeweler>, [">= 2.0.1"])
|
72
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
73
|
+
s.add_dependency(%q<minitest>, ["~> 4"])
|
74
|
+
s.add_dependency(%q<rake-compiler>, [">= 0"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<coderunner>, [">= 0.14.2"])
|
78
|
+
s.add_dependency(%q<text-data-tools>, [">= 1.1.3"])
|
79
|
+
s.add_dependency(%q<gs2crmod>, [">= 0.11.33"])
|
80
|
+
s.add_dependency(%q<trinitycrmod>, [">= 0.4.7"])
|
81
|
+
s.add_dependency(%q<ruby-mpi>, [">= 0.2.0"])
|
82
|
+
s.add_dependency(%q<cheasecrmod>, [">= 0.1.0"])
|
83
|
+
s.add_dependency(%q<shoulda>, ["= 3.0.1"])
|
84
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
85
|
+
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
86
|
+
s.add_dependency(%q<jeweler>, [">= 2.0.1"])
|
87
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
88
|
+
s.add_dependency(%q<minitest>, ["~> 4"])
|
89
|
+
s.add_dependency(%q<rake-compiler>, [">= 0"])
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinitycrdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.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:
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderunner
|
@@ -67,19 +67,47 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.4.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: ruby-mpi
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
-
type: :
|
75
|
+
version: 0.2.0
|
76
|
+
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.2.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cheasecrmod
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: shoulda
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.0.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.0.1
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: rdoc
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,18 +142,61 @@ dependencies:
|
|
114
142
|
requirements:
|
115
143
|
- - ">="
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.0.
|
145
|
+
version: 2.0.1
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.0.
|
152
|
+
version: 2.0.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: minitest
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '4'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '4'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rake-compiler
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
125
195
|
description: A gem to allow coderunner to run the trinity code directly.
|
126
196
|
email: edmundhighcock@users.sourceforge.net
|
127
197
|
executables: []
|
128
|
-
extensions:
|
198
|
+
extensions:
|
199
|
+
- ext/trinitycrdriver/extconf.rb
|
129
200
|
extra_rdoc_files:
|
130
201
|
- LICENSE.txt
|
131
202
|
- README.rdoc
|
@@ -136,9 +207,14 @@ files:
|
|
136
207
|
- README.rdoc
|
137
208
|
- Rakefile
|
138
209
|
- VERSION
|
210
|
+
- clean.sh
|
211
|
+
- ext/trinitycrdriver/extconf.rb
|
212
|
+
- ext/trinitycrdriver/trinitycrdriver.c
|
139
213
|
- lib/trinitycrdriver.rb
|
140
|
-
-
|
141
|
-
-
|
214
|
+
- lib/trinitycrdriver/optimisation.rb
|
215
|
+
- lib/trinoptcrmod.rb
|
216
|
+
- lib/trinoptcrmod/trinopt.rb
|
217
|
+
- trinitycrdriver.gemspec
|
142
218
|
homepage: http://github.com/edmundhighcock/trinitycrdriver
|
143
219
|
licenses:
|
144
220
|
- GPLv3
|
@@ -159,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
235
|
version: '0'
|
160
236
|
requirements: []
|
161
237
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
238
|
+
rubygems_version: 2.4.8
|
163
239
|
signing_key:
|
164
240
|
specification_version: 4
|
165
241
|
summary: A gem to allow coderunner to run the trinity code directly via a C interface.
|
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 'trinitycrdriver'
|
32
|
-
|
33
|
-
class Test::Unit::TestCase
|
34
|
-
end
|