并行运行 for 循环

并行运行 for 循环

我有一个关于linux并行脚本的问题:

上下文:我需要处理许多 .dat 文件

到目前为止我的代码:

#!/bin/bash
#PBS -S /bin/bash
# set parallel parameters 
#PBS -r n 
#PBS -l walltime=2:00:00 
#PBS -l procs=298 
#PBS -l pmem=1600m 
#PBS -m bea 
#PBS -M [email protected]
#PBS -N FileName

cd /home/user/Data/
# start matlab
module load matlab/2015b
# Choose the MCR directory according to the compiler version used
MCR=/global/software/matlab/mcr/v90
# set up matlab compiler
mcc -R -nodisplay -R -singleCompThread -R -logfile,ResultsOutput.txt -K -m -v -w enable FileName.m

# cycle through all files
# does the for loop send it to different nodes?
for fileID in *.dat
do
  echo "Running on host: `hostname`"
  echo "Current working directory is `pwd`"
  echo "Starting run at: `date`" 
  echo "$fileID"

  ./run_FileName.sh $MCR $fileID > Results_${PBS_JOBID}.out &

  echo "Job finished at: `date`"    
done

需要保留结果吗??

答案1

我认为你应该看看GNU Parallel https://www.gnu.org/software/parallel/

parallel "./run_FileName.sh $MCR {} > Results_${PBS_JOBID}.out" ::: *.dat

您可能也想使用该--joblog选项--sshloginfile

相关内容