我有一个 C++ 程序,我使用命令行将两个双精度值作为输入传递给它
int main(int argc, char *argv[]){
double a,b;
a = atof(argv[1]);
b = atof(argv[2]);
further code.....
我使用该实用程序在集群上运行代码,qsub
并且我有一个名为“jobsub.sh”的 Bash 脚本来提交如下所示的作业:
#!/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
在我做的终端qsub jobsub.sh
。
但是,我想为不同的值运行相同的可执行文件,a
并b
在不同的内核上并行运行。是否可以在 Bash 脚本中编写一个for
循环,以便我可以执行类似的操作,
for i=1;i<=10;i++ {
$HOME/codes/3D/autoA100.out 2+i*0.1 2+i*0.2
}