Question

I'm really struggling in redoing a bash for loop to run in parallel.

The loop is as such:

for i in `cat names`
do
    cp $i.pqr dum.pqr
    apbs parameters.in
    mv dum.grd $i.grd
    rm dum.grd
done

I tried this without success. It tells me that 'an argument for -c is required'

for i in `cat names`
do
    cp $i.pqr dum.pqr
    parallel -j8 apbs parameters.in
    mv dum.grd $i.grd
    rm dum.grd
done

Can anyone advise me on my mistake?

Was it helpful?

Solution

I assume apbs takes 'dum.pqr' and turns it into 'dum.grd'. So if 2 apbs run at the same time they will overwrite dum.grd. You somehow need to make sure that the names are unique. Maybe using dirs:

func my_apbs {
  mkdir $1
  cp $1.pqr $1/dum.pqr
  cd $1
  apbs parameters.in
  mv dum.grd ../$1.grd
  cd ..
  rm -r $1
}
export -f my_apbs
parallel my_apbs :::: names

You did not write whether you have watched the intro videos https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1 or walked through the tutorial: http://www.gnu.org/software/parallel/parallel_tutorial.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top