/
msub-llandeilo
executable file
·434 lines (356 loc) · 11.6 KB
/
msub-llandeilo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
#!/usr/bin/perl
#
# This script is used to submit Molpro calculations on the Llandeilo.
#
# The full set of available switches can be seen by running perldoc on this
# script, which will interpret the POD block that follows these comments.
# Specifically, run the following at the command line:
# perldoc msub
#
# Lee M. Thompson
# University of Louisville
# lee.thompson.1@louisville.edu
#
# This script is modified for Llandeilo from gsub for pinconning written by
# Hrant P. Hratchian
# University of California, Merced
# hhratchian@ucmerced.edu
#
#
#
# Set-up communication with modules.
#
use Cwd;
#
# Get the executing username and then set option defaults, including some
# that may be user-dependent.
#
$username = getpwuid( $< );
chomp($username);
$do_submission = 1;
$run_in_scratch = 0;
$queue_flag = "workq";
$mem_amount = "0G";
$nproc = 0;
$walltime = "00:00:00";
$m_module = "molpro/molpro-19.1";
if($username eq ""){
$m_module = "molpro/molpro";
}
#
# Load option switches and file names from the command line. Then, set
# the .sub file name.
#
foreach $temp (@ARGV){
chomp($temp);
#
# General program options...
if($temp =~ /^-h$/i){
exec("perldoc","msub");
exit 0;
}elsif($temp =~ /^-v$/i){
print "\nmsub for Llandeilo.\n";
print "Last modified by LMT on November 15, 2019.\n\n";
exit 0;
#
# Molpro job setting controls...
}elsif($temp =~ /^-mem=(\d+[a-zA-Z])$/i){
$mem_amount = $1;
}elsif($temp =~ /^-nproc=(\d+)$/i){
$nproc=$1;
}elsif($temp =~ /^-walltime=(\d+:\d+:\d+)$/i){
$walltime=$1;
}elsif($temp =~ /^-m19_1$/i){
$m_module = "molpro/molpro-19.1";
}elsif($temp =~ /^-m18_2$/i){
$m_module = "molpro/molpro-18.2";
}elsif($temp =~ /^-m18_1$/i){
$m_module = "molpro/molpro-18.1";
}elsif($temp =~ /^-m15_1$/i){
$m_module = "molpro/molpro-15.1";
#
# Submission & queue controls...
}elsif($temp =~ /^-sub$/i){
$do_submission = 1;
}elsif($temp =~ /^-nosub$/i){
$do_submission = 0;
}elsif($temp =~ /^-workq$/i){
$queue_flag = "workq";
}elsif($temp =~ /^-runscratch$/i){
$run_in_scratch = 1;
}elsif($temp =~ /^-norunscratch$/i){
$run_in_scratch = 0;
}elsif($temp =~ /^-name=([a-zA-Z]\S+)$/i){
$qstat_name=$1;
#
# Unknown switch...
}elsif($temp =~ /^-(.*)/){
die "\n\nUnknown switch sent to msub: $temp\n\n";
#
# Input file found...
}else{
push(@filelist,$temp);
}
}
if(@filelist < 1){die "\nNo MOLPRO input files given!\nn
\n"}
$qsub_file = $filelist[0];
unless($qsub_file =~ s/\.com/.sub/){
print "\n\nNOTE: Appending .sub\n\n";
$qsub_file .= ".sub";
}
#
# Set NProcShared and Memory defaults based on the selected queue.
#
if($walltime=="00:00:00"){
if($queue_flag =~ "workq"){
$walltime = "48:00:00";
}else{
$walltime = "48:00:00";
}
}
if($nproc==0){
if($queue_flag =~ "workq"){
$nproc = 20;
}else{
$nproc = 20;
}
}
if($mem_amount=="0G"){
if($queue_flag =~ "workq"){
$mem_amount = "90G";
}else{
$mem_amount = "90G";
}
}
#
# Set the name of the .err file and the qstat job name.
#
$qerr_file = $filelist[0];
unless($qerr_file =~ s/\.com/.err/){
print "\n\nNOTE: Appending .err\n\n";
$qerr_file .= ".err";
}
unless($qstat_name){$qstat_name = "$filelist[0]";}
print "qsub JOB NAME is $qstat_name.\n";
#
# Determine the memory setting to send to SGE.
#
$mem_requirement = $mem_amount;
$mem_requirement =~ s/mb$/M/i;
$mem_requirement =~ s/gb$/G/i;
#
# Put together the list of Molpro command line switches controlling
# resource use.
#
$m_resources = "-m $mem_amount -n $nproc";
#
# Process the list of input files and build the %working_directory hash,
# which gives the working directory to use when submitting each Molpro
# job via remote_submit.
#
chomp($my_cwd = cwd);
$my_cwd =~ s/\/\//\//g;
for ($i=0;$i<@filelist;$i++){
$filelist[$i] =~ s/$my_cwd\///;
if($filelist[$i] =~ /\//){
die "\n\nInput files must be in the CWD.\n\n";
}
}
#
# Loop through @filelist and process each job one-at-a-time. This loop
# compiles a complete list of CHK, RWF, MAT and @ files that must be moved to
# the local node's disk and then moved back after the Molpro work is
# complete. This is also the block of code that ensures the input files
# are compliant with our submission requirements.
#
foreach $input_file (@filelist){
chomp($input_file);
push(@inputfiles,$input_file);
$log_file = $input_file;
unless($log_file =~ s/\.com/.log/){
$log_file .= ".log";
}
$output_file = $input_file;
unless($output_file =~ s/\.com/.out/){
$output_file .= ".out";
}
$xml_file = $input_file;
unless($xml_file =~ s/\.com/.xml/){
$xml_file .= ".xml";
}
#
# Add this job to the command list of Molpro executions.
push(@molpro_run,"molpro -s -d \$MY_SCRATCH $m_resources -o $output_file < $input_file > $log_file");
}
#
# Build two arrays that are used to handle file transfer to/from the
# compute node's local disk. The first array, @sendfiles, lists all the
# files that must be moved TO the local disk before Molpro is executed.
# The second array, @removefiles, lists all of the files that should be
# removed from the temperary directory before copying all files back to
# the submission working directory.
#
@sendfiles = @inputfiles;
@removefiles = @inputfiles;
#
# Write the submission file...
#
open QSUBFILE,"> $qsub_file";
print QSUBFILE "#! /bin/bash\n";
print QSUBFILE "#PBS -q $queue_flag\n";
print QSUBFILE "#PBS -N Job-$qstat_name\n";
print QSUBFILE "#PBS -j oe\n";
print QSUBFILE "#PBS -o $qstat_name.qlog\n";
print QSUBFILE "#PBS -l mem=$mem_requirement\n";
print QSUBFILE "#PBS -l walltime=$walltime\n";
print QSUBFILE "#PBS -l ncpus=$nproc\n";
print QSUBFILE "#\n";
print QSUBFILE "# Set up the Molpro environment and prevent core files.\n";
print QSUBFILE "module load $m_module\n";
print QSUBFILE "ulimit -c 0\n";
print QSUBFILE "#\n";
print QSUBFILE "# Set the Molpro scratch directory to the job-specific SCRATCH directory.\n";
print QSUBFILE "export MY_SCRATCH=\"/tmp\"\n";
if($run_in_scratch){
print QSUBFILE "#\n";
print QSUBFILE "# Copy files to the scratch directory and then move there.\n";
print QSUBFILE "cd \$PBS_O_WORKDIR\n";
foreach $temp (@sendfiles){
print QSUBFILE "cp $temp \$MY_SCRATCH\/\n";
}
print QSUBFILE "cd \$MY_SCRATCH\n";
}else{
print QSUBFILE "#\n";
print QSUBFILE "# Move to the submission script directory.\n";
print QSUBFILE "cd \$PBS_O_WORKDIR\n";
}
print QSUBFILE "#\n";
print QSUBFILE "# Run Molpro...\n";
foreach $temp (@molpro_run){
chomp($temp);
print QSUBFILE "$temp\n";
}
if($run_in_scratch){
print QSUBFILE "#\n";
print QSUBFILE "# Remove files that we don't want to copy back to the original submission working directory.\n";
foreach $temp (@removefiles){
chomp($temp);
print QSUBFILE "rm -f $temp\n";
}
print QSUBFILE "#\n";
print QSUBFILE "# Return to the original working directory and copy back all of the Molpro files.\n";
print QSUBFILE "cd \$PBS_O_WORKDIR\n";
print QSUBFILE "cp -f \$MY_SCRATCH\/\* .\n";
}
close QSUBFILE;
#
# Set-up command line to submit the job to PBS and then submit it...
#
if($do_submission){
$sys_cmd = "qsub $qsub_file";
exec "$sys_cmd";
print "Job $qstat_name submitted to the queue.\n";
}else{
print "Job NOT submitted. QSub file $qsub_file has been prepared.\n";
}
#
# POD block...
#
=head1 NAME
B<gsub> - This script is used to submit Molpro calculations on Llandeilo.
=head1 SYNOPSIS
B<msub> [I<option_list>] F<molpro_input_files>
=head1 DESCRIPTION
This script takes one or more Molpro input file names as input and
prepares a Portable Batch Script input file to submit to the CRC's queue system.
By default, the job is then submitted to the queue. To supress submission,
use the -nosub option described below.
=head1 OPTIONS
=head2 General Program Options
=over
=item B<-h>
Print help information.
=item B<-v>
Print version and modification information.
=back
=head2 Molpro Job Options
=over
=item B<-mem=F<N>>
This switch is used to set the memory requested by Molpro to the value
F<N>. When specified with this switch, the memory amount specified should
include a unit label. For example, to request 32 GB of memory use
B<-mem=32G>. The default value is determined by the script version.
=item B<-nproc=F<N>>
This switch is used to set the number of shared-memory processors requested
by Molpro to the value B<F<N>>. The default value is determined by the
script version.
=item B<-m19_1>
=item B<-m18_2>
=item B<-g18_1>
=item B<-g15_1>
These switches control the version of Molpro to use, as well as the subversion.
Molpro 19.1 is run by default. Other switches are available to request specific
older versions of Molpro.
=back
=head2 Submission & Queue Control
=over
=item B<-sub>
=item B<-nosub>
These switches enable (B<-sub>) or disable (B<-nosub>) submission of the
processed Molpro jobs to the queue system. In both cases, a submission
file (*.sub) is generated. A typical reason for disabling queue submission
is for debugging or to add custom blocks of code to the submission script.
By default, submission is enabled.
=item B<-workq>
These switches are used to assign the queue to which the processed Molpro
jobs are submitted.
=over
1. The work queue (known to the queue system as F<workq> and requested with the
switch B<-workq>). This queue has a 48 hour wall clock limit and a maximum of
10 jobs per user in the queue.
=back
By default, jobs are submitted to the work queue.
=item B<-runscratch>
=item B<-norunscratch>
These switches determine whether the job is run from within the local
compute node scratch directory (B<-runscratch>) or from the /home/
partition (B<-norunscratch>). When a job is run in the local scratch
directory, all files necessary for the calculations to run are copied to
the scratch directory before running Molpro and then copied back after
all of the jobs complete. In either case, Molpro scratch files are kept
on the local scratch partition. By default, jobs are run in the local
scratch directory.
=item B<-name=F<A>>
This switch is used to specify the name label given in the qstat (and
related) tables while a job is active in the queue system. The name given
must begin with a letter.
=back
=head1 VERSION SPECIFIC DEFAULTS
Defaults specific to the B<CRC> version of B<gsub> include:
=over
=item B<-mem>
The default memory requested is 90 GB. This is equivalent to using B<-mem=90G>.
=item B<-nproc>
The default number of shared-memory processors is 20. This is equivalent to
using B<-nproc=20>.
=item B<-walltime>
The default walltime is 48 hours. This is equivalent to using B<-walltime="48:00:00">.
=back
=head1 CURRENT VERSION
Version: B<msub> for B<F<Llandeilo>> submissions.
Latest Modification(s): November 15, 2019.
=head1 MODIFICATION HISTORY
=over
=item November 15, 2019
Initial version.
=back
=head1 AUTHOR
=over
=item Lee M. Thompson
=item University of Louisville
=item Louisville, KY 40208
=item lee.thompson.1@louisville.edu
=back
=cut
###########################################################################