1 |
#!/bin/sh |
2 |
|
3 |
# $Id$ |
4 |
|
5 |
# The memory and wall time requirements as passed from the job |
6 |
# description file (JDL) need to be passed on to the local batch |
7 |
# system. This script, when installed in /opt/glite/bin, will be |
8 |
# called by BLAH moments before the job is submitted to the Torque |
9 |
# batch system. |
10 |
|
11 |
# The requirements are passed according the tho GLUE schema, and for |
12 |
# the purposes of this script involve the properties |
13 |
# MainMemoryRAMSize, and MaxWallClockTime. |
14 |
|
15 |
# see the GlUE Schema v1.3, http://glueschema.forge.cnaf.infn.it/Spec/V13 |
16 |
|
17 |
# See http://grid.pd.infn.it/cream/field.php?n=Main.ForwardOfRequirementsToTheBatchSystem |
18 |
|
19 |
# The requirements will have been translated from their original Glue |
20 |
# form into shell variables; upper and lower bounds are indicated by |
21 |
# appending _Max or _Min, respectively, to the variable name. |
22 |
|
23 |
# Some care must be taken to pass only sensible values, i.e. numbers, |
24 |
# lest we leave opportunity to befoul the submit script with stray |
25 |
# parameters. |
26 |
|
27 |
# The assumption here is, and it will have to be checked, that all |
28 |
# values are specified as integer decimal numbers. |
29 |
|
30 |
# For a treatise on parameter passing to Torque, see |
31 |
# http://www.clusterresources.com/torquedocs21/2.1jobsubmission.shtml#nodeExamples. |
32 |
|
33 |
# Part 1: memory requirements |
34 |
# The parameter to watch for is called MainMemoryRamSize. |
35 |
# this is specified in megabytes according to Glue. |
36 |
memmin="$GlueHostMainMemoryRAMSize_Min" |
37 |
|
38 |
# If the user was so careless to ask for an exact match instead of |
39 |
# a minimum, the variable name is different. |
40 |
if [ -z "$memmin" ]; then |
41 |
memmin="$GlueHostMainMemoryRAMSize" |
42 |
fi |
43 |
|
44 |
# At this point $memmin is either empty, if no requirement was given, |
45 |
# or some string. It must be a number but let's make sure by using |
46 |
# the test below. |
47 |
if [ "$memmin" -gt 0 ]; then |
48 |
echo "#PBS -l mem=${memmin}mb" |
49 |
fi |
50 |
|
51 |
# Part 2: Wall clock time requirement. |
52 |
# |
53 |
# While the memory specification according to the Glue schema is a |
54 |
# property of a Compute Element, the maximum (wall clock) time a job |
55 |
# can spend is set by policy. A curious aspect of the Glue schema is |
56 |
# the subtle difference between the meaning of MaxWallClockTime and |
57 |
# MaxObtainableWallClockTime. |
58 |
# |
59 |
#+--------------------------+-----------------------------+ |
60 |
#|property |description | |
61 |
#+--------------------------+-----------------------------+ |
62 |
#|MaxWallClockTime |The default maximum wall | |
63 |
#| |clock time allowed to each | |
64 |
#| |job by the batch system if no| |
65 |
#| |limit is requested. Once this| |
66 |
#| |time has expired the job will| |
67 |
#| |most likely be killed or | |
68 |
#| |removed from the queue | |
69 |
#+--------------------------+-----------------------------+ |
70 |
#|MaxObtainableWallClockTime|The maximum obtainable wall | |
71 |
#| |clock time that can be | |
72 |
#| |granted to the job upon user | |
73 |
#| |request | |
74 |
#+--------------------------+-----------------------------+ |
75 |
# |
76 |
|
77 |
# In the new Glue Schema (2.0) the DefaultWallTime and MaxWallTime |
78 |
# properties have a like relationship. |
79 |
|
80 |
# If for some strange reason the JDL file mentions requirements on both |
81 |
# attributes, let's be prudent and take the maximum of the two. |
82 |
|
83 |
# We take the same approach as before; testing for an exact match as well |
84 |
# as a lower bound. |
85 |
maxwall=0 |
86 |
if [ -n "$GlueCEMaxWallClockTime_Min" ]; then |
87 |
maxwall="$GlueCEMaxWallClockTime_Min" |
88 |
elif [ -n "$GlueCEMaxWallClockTime" ] ; then |
89 |
maxwall="$GlueCEMaxWallClockTime" |
90 |
fi |
91 |
|
92 |
maxobtain=0 |
93 |
if [ -n "$GlueCEMaxObtainableWallClockTime_Min" ]; then |
94 |
maxobtain="$GlueCEMaxObtainableWallClockTime_Min" |
95 |
elif [ -n "$GlueCEMaxObtainableWallClockTime" ]; then |
96 |
maxobtain="$GlueCEMaxObtainableWallClockTime" |
97 |
fi |
98 |
|
99 |
# Select the larger of the two values; the use of -gt uses |
100 |
# integer parsing so it effectively enforces input sanitation. |
101 |
if [ "$maxobtain" -gt "$maxwall" ]; then |
102 |
walltime="$maxobtain" |
103 |
else |
104 |
walltime="$maxwall" |
105 |
fi |
106 |
if [ "$walltime" -gt 0 ]; then |
107 |
# The time unit, according to the Glue schema, is one minute |
108 |
# but the Torque parameter is in seconds |
109 |
wallsec=$(($walltime*60)) && echo "#PBS -l walltime=${wallsec}" |
110 |
fi |
111 |
|
112 |
exit 0 |