Class: CodeRunner::Cronos

Inherits:
Run
  • Object
show all
Defined in:
lib/cronoscrmod/cronos.rb

Defined Under Namespace

Classes: CronosHandler, EngineHandler

Instance Method Summary collapse

Instance Method Details

#cronosObject



199
200
201
202
# File 'lib/cronoscrmod/cronos.rb', line 199

def cronos
  set_cronos_path
  rcp.engine_handler.cronos
end

#generate_input_fileObject

This is a hook which gets called just before submitting a simulation. It sets up the folder and generates any necessary input files.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/cronoscrmod/cronos.rb', line 150

def generate_input_file
  #FileUtils.touch("#@run_name.mat")
  #cronos.new_file
  #eputs "Make sure you save the file as #@run_name.mat... overwrite the existing empty place holder. When you have saved the file press enter."
  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')")
  #cronos.eval("zuicreate")
  refresh_gui
  
end

#get_statusObject



228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/cronoscrmod/cronos.rb', line 228

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

#loadObject



189
190
191
192
# File 'lib/cronoscrmod/cronos.rb', line 189

def load
  cronos.puts("zuiload('#@directory/#@run_name.mat')")
  refresh_gui
end

#load_resultObject



194
195
196
197
# File 'lib/cronoscrmod/cronos.rb', line 194

def load_result
  cronos.puts("zuiload('#@directory/#{@run_name}_resultat.mat')")
  refresh_gui
end

#parameter_stringObject

Parameters which follow the Trinity executable, in this case just the input file.



207
208
# File 'lib/cronoscrmod/cronos.rb', line 207

def parameter_string
end

#parameter_transitionObject



210
211
# File 'lib/cronoscrmod/cronos.rb', line 210

def parameter_transition
end

A hook which gets called when printing the standard run information to the screen using the status command.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/cronoscrmod/cronos.rb', line 129

def print_out_line
  #p ['id', id, 'ctd', ctd]
  #p rcp.results.zip(rcp.results.map{|r| send(r)})
  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
    #beginning += sprintf("Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20", fusionQ, pfus, ti0, te0, ne0)
  end
  beginning += "  ---#{@comment}" if @comment
  beginning
end

#process_directory_code_specificObject

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).



218
219
220
221
222
# File 'lib/cronoscrmod/cronos.rb', line 218

def process_directory_code_specific
  get_status
  #p ['fusionQ is ', fusionQ]
  #@percent_complete = completed_timesteps.to_f / ntstep.to_f * 100.0
end

#refresh_guiObject



179
180
181
182
183
184
185
186
187
# File 'lib/cronoscrmod/cronos.rb', line 179

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_nameObject



224
225
226
# File 'lib/cronoscrmod/cronos.rb', line 224

def results_file_name
  "#{@run_name}_resultat.mat"
end

#run_commandObject



33
34
35
# File 'lib/cronoscrmod/cronos.rb', line 33

def run_command
  "echo 'manual run'"
end

#set_cronos_pathObject



92
93
94
# File 'lib/cronoscrmod/cronos.rb', line 92

def set_cronos_path
  rcp.engine_handler.start_cronos(@runner.executable.sub(/cronos$/, ""))
end