#!/bin/sh

input_dir=`pwd`

while [ $# -gt 0 ]
do
  x=`echo $1 | awk -F. '{ print $1 }'`
  echo "starting for $x";
  shift
  
  [ ! -d $G4WORKDIR/$x.dir ] && mkdir $G4WORKDIR/$x.dir;
  (cd $G4WORKDIR/$x.dir; \
    [ -f run.log ] && rm run.log; \
     rm  -f core.* ; \
    $G4BIN/Linux-g++/BinaryLightIonReaction < $input_dir/$x.in > run.log 2>&1; \
    grep -q "Light-ION-SUCESS" run.log && rm core.* \
  )
done
