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
}