1

I have a question regarding linux parallel scripts:

Context: I need to process many .dat files

Code I have so far:

#!/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 myemail@somewhere.com
#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

need to retain results ??

Kusalananda
  • 333,661
Dan
  • 11

1 Answers1

3

I think you should look at GNU Parallel https://www.gnu.org/software/parallel/.

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

And you probably want to use the option --joblog and --sshloginfile too.

hschou
  • 2,910
  • 13
  • 15