Module: CodeRunner::Moab
Instance Method Summary
collapse
Methods included from Launcher
#cancel_job_launcher, #error_file_launcher, #execute_launcher, #launcher_prefix, #output_file_launcher, #queue_status_launcher, #use_launcher
Instance Method Details
#batch_script ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/coderunner/system_modules/moab.rb', line 85
def batch_script
ppn_checks
hours, mins, secs = hours_minutes_seconds
<<EOF
#!/bin/bash --login
#PBS -N #{executable_name}.#{job_identifier}
#PBS -l mppwidth=#{nprocstot}
#PBS -l mppnppn=#{ppn}
#PBS -l walltime=#{sprintf("%02d:%02d:%02d", hours, mins, secs)}
#{@project ? "#PBS -A #@project" : ""}
#{@queue ? "#PBS -q #@queue" : ""}
### start of jobscript
cd $PBS_O_WORKDIR
echo "workdir: $PBS_O_WORKDIR"
#{code_run_environment}
echo "Submitting #{nodes}x#{ppn} job on #{CodeRunner::SYS} for project #@project..."
EOF
end
|
#batch_script_file ⇒ Object
61
62
63
|
# File 'lib/coderunner/system_modules/moab.rb', line 61
def batch_script_file
"#{executable_name}.#{job_identifier}.sh"
end
|
#cancel_job ⇒ Object
106
107
108
|
# File 'lib/coderunner/system_modules/moab.rb', line 106
def cancel_job
use_launcher ? cancel_job_launcher : `qdel #{@job_no}`
end
|
#error_file ⇒ Object
110
111
112
113
|
# File 'lib/coderunner/system_modules/moab.rb', line 110
def error_file
use_launcher ? error_file_launcher :
"#{executable_name}.#{job_identifier}.e#@job_no"
end
|
52
53
54
55
56
57
58
59
|
# File 'lib/coderunner/system_modules/moab.rb', line 52
def execute
if use_launcher
return execute_launcher
else
File.open(batch_script_file, 'w'){|file| file.puts batch_script + run_command + "\n"}
_pid = %x[qsub #{batch_script_file}].to_i
end
end
|
#get_run_status(job_no, current_status) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/coderunner/system_modules/moab.rb', line 120
def get_run_status(job_no, current_status)
if use_launcher
return :Unknown
end
line = current_status.split(/\n/).grep(Regexp.new(job_no.to_s))[0]
unless line
return :Unknown
else
if line =~ /\sQ\s/
return :Queueing
elsif line =~ /\sR\s/
return :Running
elsif line =~ /\sH\s/
return :Queueing
elsif line =~ /\sC\s/
@running=false
return :Unknown
else
ep 'line', line
raise 'Could not get run status'
end
end
end
|
#hours_minutes_seconds ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/coderunner/system_modules/moab.rb', line 69
def hours_minutes_seconds
if @wall_mins
ep @wall_mins
hours = (@wall_mins / 60).floor
mins = @wall_mins.to_i % 60
secs = ((@wall_mins - @wall_mins.to_i) * 60).to_i
else
raise "Please specify wall mins using the W flag"
end
eputs "Allotted wall time is " + sprintf("%02d:%02d:%02d", hours, mins, secs)
return [hours, mins, secs]
end
|
65
66
67
|
# File 'lib/coderunner/system_modules/moab.rb', line 65
def max_ppn
raise "Please define max_ppn for your system"
end
|
25
26
27
|
# File 'lib/coderunner/system_modules/moab.rb', line 25
def mpi_prog
"aprun -n #{nprocstot} -N #{ppn}"
end
|
29
30
31
32
|
# File 'lib/coderunner/system_modules/moab.rb', line 29
def nodes
nodes, _ppn = @nprocs.split(/:/)[0].split(/x/)
nodes.to_i
end
|
#nprocstot ⇒ Object
37
38
39
40
41
|
# File 'lib/coderunner/system_modules/moab.rb', line 37
def nprocstot
_nprocstot = nodes.to_i * ppn.to_i
end
|
#output_file ⇒ Object
115
116
117
118
|
# File 'lib/coderunner/system_modules/moab.rb', line 115
def output_file
use_launcher ? output_file_launcher :
"#{executable_name}.#{job_identifier}.o#@job_no"
end
|
33
34
35
36
|
# File 'lib/coderunner/system_modules/moab.rb', line 33
def ppn
_nodes, ppn = @nprocs.split(/:/)[0].split(/x/)
ppn.to_i
end
|
#ppn_checks ⇒ Object
81
82
83
84
|
# File 'lib/coderunner/system_modules/moab.rb', line 81
def ppn_checks
eputs "Warning: Underuse of nodes (#{ppn} cores per node instead of #{max_ppn})" if ppn.to_i < max_ppn
raise "Error: cores per node cannot excede #{max_ppn}" if ppn.to_i > max_ppn
end
|
#queue_status ⇒ Object
Kernel.change_environment_with_shell_script(conf) end
17
18
19
20
21
22
23
|
# File 'lib/coderunner/system_modules/moab.rb', line 17
def queue_status
if use_launcher
queue_status_launcher
else
%x[qstat | grep $USER]
end
end
|
#run_command ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/coderunner/system_modules/moab.rb', line 42
def run_command
if use_launcher
return %[#{code_run_environment}
#{mpi_prog} #{executable_location}/#{executable_name} #{parameter_string} > #{output_file} 2> #{error_file}]
else
"#{mpi_prog} #{executable_location}/#{executable_name} #{parameter_string}"
end
end
|