Class: CodeRunner::Cronos
- Inherits:
-
Run
- Object
- Run
- CodeRunner::Cronos
show all
- Defined in:
- lib/cronoscrmod/cronos.rb
Defined Under Namespace
Classes: CronosHandler, EngineHandler
Instance Method Summary
collapse
Instance Method Details
#cronos ⇒ Object
184
185
186
187
|
# File 'lib/cronoscrmod/cronos.rb', line 184
def cronos
set_cronos_path
rcp.engine_handler.cronos
end
|
This is a hook which gets called just before submitting a simulation. It sets up the folder and generates any necessary input files.
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/cronoscrmod/cronos.rb', line 140
def generate_input_file
if @duplicate_id
old = @runner.run_list[@duplicate_id]
system "cp #{old.directory}/#{old.run_name}.mat #@directory/#@run_name.mat"
load
elsif @restart_id
old = @runner.run_list[@restart_id]
system "cp #{old.directory}/#{old.run_name}_resultat.mat #@directory/#@run_name.mat"
load
else
sz = Terminal.terminal_size[1]
eputs((str = "When you have created the file press enter. Don't save it (CodeRunner will automatically save it in the right place. You can edit parameters later as well. CodeRunner will not submit the file... submit it manually using a batch or interactive run."; ["-"*sz, str, "-"*sz]))
cronos.puts("zuicreate")
STDIN.gets
end
cronos.puts("param.gene.origine = '#@directory/#@run_name.mat'")
cronos.puts("param.gene.file = '#@directory/#{@run_name}_resultat.mat'")
cronos.puts("param.gene.rapsauve = '#@directory/#{@run_name}_resultat'")
cronos.puts("param.edit.currentfile= '#@directory/#@run_name.mat'")
cronos.puts("param.from.creation.com = '#@comment'")
cronos.puts("zuisavedata('force')")
refresh_gui
end
|
#get_status ⇒ Object
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/cronoscrmod/cronos.rb', line 213
def get_status
Dir.chdir(@directory) do
if FileTest.exist? results_file_name
@status = :Complete
@percent_complete = 100.0
elsif temps = Dir.entries.grep(/resultat_\d+/) and temps.size > 1
@status = :Incomplete
@completed_timesteps = temps.map{|f| f.scan(/resultat_(\d+)/)[0][0].to_i}.max
else
@status = :Unknown
@percent_complete = 0
end
end
end
|
#load ⇒ Object
179
180
181
182
|
# File 'lib/cronoscrmod/cronos.rb', line 179
def load
cronos.puts("zuiload('#@directory/#@run_name.mat')")
refresh_gui
end
|
#parameter_string ⇒ Object
Parameters which follow the Trinity executable, in this case just the input file.
192
193
|
# File 'lib/cronoscrmod/cronos.rb', line 192
def parameter_string
end
|
#parameter_transition ⇒ Object
195
196
|
# File 'lib/cronoscrmod/cronos.rb', line 195
def parameter_transition
end
|
#print_out_line ⇒ Object
A hook which gets called when printing the standard run information to the screen using the status command.
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/cronoscrmod/cronos.rb', line 119
def print_out_line
name = @run_name
name += " (res: #@restart_id)" if @restart_id
name += " real_id: #@real_id" if @real_id
beginning = sprintf("%2d:%d %-60s %1s:%2.1f(%s)", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s)
if @status == :Incomplete and @completed_timesteps
beginning += sprintf(" %d steps ", @completed_timesteps)
elsif @percent_complete
beginning+=sprintf(" %3s%1s ", percent_complete, "%")
end
if ctd
end
beginning += " ---#{@comment}" if @comment
beginning
end
|
#process_directory_code_specific ⇒ Object
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).
203
204
205
206
207
|
# File 'lib/cronoscrmod/cronos.rb', line 203
def process_directory_code_specific
get_status
end
|
#refresh_gui ⇒ Object
169
170
171
172
173
174
175
176
177
|
# File 'lib/cronoscrmod/cronos.rb', line 169
def refresh_gui
cronos.puts(["[hfig,h] = zuiformhandle('direct');",
"if ishandle(hfig)
set(h.text_loadfile, 'string', param.gene.origine)
set(h.text_nom_machine, 'string', param.from.machine)
set(h.text_numchoc, 'string', sprintf('%d', param.from.shot.num))
end"])
end
|
#results_file_name ⇒ Object
209
210
211
|
# File 'lib/cronoscrmod/cronos.rb', line 209
def results_file_name
"#{@run_name}_resultat.mat"
end
|
#run_command ⇒ Object
33
34
35
|
# File 'lib/cronoscrmod/cronos.rb', line 33
def run_command
"echo 'manual run'"
end
|
#set_cronos_path ⇒ Object
82
83
84
|
# File 'lib/cronoscrmod/cronos.rb', line 82
def set_cronos_path
rcp.engine_handler.start_cronos(@runner.executable.sub(/cronos$/, ""))
end
|