I have a C++ program to which I pass two doubles as inputs from the command line using
int main(int argc, char *argv[]){
double a,b;
a = atof(argv[1]);
b = atof(argv[2]);
further code.....
I run the code on a cluster using the qsub
utility and I have a Bash script named 'jobsub.sh` to submit the jobs which looks like this:
#!/bin/csh -f
hostname
cd /home/roy/codes/3D # Change directory first -- replace Mysubdir
set startdir = `pwd` # Remember the directory we're in
if( ! -d /scratch/$USER ) then
mkdir /scratch/$USER # Create scratch directory
endif # If it does not exist
#cp infile12 /scratch/$USER # Copy input file to scratch directory
cd /scratch/$USER # Change to scratch directory
#rm *.*
$HOME/codes/3D/autoA100.out 2.1 2.2 # Run a program
cp * $startdir # Copy outputfiles back to where we started
At the terminal I do qsub jobsub.sh
.
However, I want to run the same executable for different values of a
and b
in parallel on different cores. Is it possible to write a for
loop in the Bash script so that I can do something like,
for i=1;i<=10;i++ {
$HOME/codes/3D/autoA100.out 2+i*0.1 2+i*0.2
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…