@@ -77,25 +77,38 @@ If one wants to launch the current job, one simply have to type:
77
77
oarsub -S ./sub.sh
78
78
79
79
and a single job with name *lmp-myvariable-0 * will be send.
80
- To launch multiple simulations with different values of *myvariable *, one
81
- can create a second bash script containing:
80
+ To launch multiple simulations with different values of *myvariable *,
81
+ say 0, 1, and 2, one can create a second bash script, named *multi-sub.sh *,
82
+ and containing:
82
83
83
84
.. code :: bash
84
85
85
86
#! /bin/bash
86
- set -e # Exit immediately if error
87
+ set -e
87
88
88
- # Loop over a desired set of values for myvariable
89
89
for myvariable in 0 1 2
90
90
do
91
- # Create a new line that will replace the line containing `myvariable` in the script sub.sh
91
+ # deal with OAR -n
92
+ newline=' #OAR -n lmp-myvariable-' $myvariable
93
+ oldline=$( cat sub.sh | grep ' #OAR -n lmp-myvariable-' )
94
+ sed -i ' /' " $oldline " ' /c\' " $newline " sub.sh
95
+ # deal with myvariable
92
96
newline=' myvariable=' $myvariable
93
- # Find the current line in sub.sh that contains 'myvariable =', storing it in the variable oldline
94
- # This assumes there is exactly one such line, otherwise the behavior may be unexpected
95
97
oldline=$( cat sub.sh | grep ' myvariable =' )
96
- # Use sed to replace the old line with the new line (newline) in sub.sh
97
- # This command searches for the line containing the value in oldline and replaces it with newline
98
98
sed -i ' /' " $oldline " ' /c\' " $newline " sub.sh
99
99
chmod +x sub.sh
100
100
oarsub -S ./sub.sh
101
101
done
102
+
103
+ The *newline * command creates a new line that will replace the line
104
+ containing *myvariable * in the script sub.sh
105
+ The *oldline= * command finds the current line in sub.sh that contains 'myvariable =',
106
+ storing it in the variable oldline. This assumes there is exactly one such line,
107
+ otherwise the behavior may be unexpected. Then, sed is used to replace the old
108
+ line with the new line (newline) in *sub.sh *.
109
+
110
+ Then, simply run *multi-sub.sh * by typing:
111
+
112
+ .. code :: bash
113
+
114
+ bash multi-sub.sh
0 commit comments