#!/usr/bin/ksh

##  Run SMCGPropMP for SMC61250 global part.
##  Usage:  ./runSMCGProp  ./PropMPInput.txt 
##
##  First created:   Jian-Guo Li    28 Apr 2021
##  Last modified:   Jian-Guo Li    25 Feb 2022
##

##  Use default input file unless a given file is provided. 
 
echo $# $*
if [ $# -ge 1 ]
   then
   Inputfile=$1
else
   Inputfile='PropInput.txt'
fi

Wrkdir='..'
GridName=`head -n 1  $Inputfile` 
echo " GridName from $Inputfile file is $GridName "

cd $Wrkdir/tmpfls/
rm $Wrkdir/tmpfls/*

##  OpenMP threads for parallelization. 
export OMP_NUM_THREADS=2

cat $Wrkdir/Linuxs/$Inputfile > ./PropInput.txt 

 $Wrkdir/F90SMC/PropOMP/SMCGProp  

# Check run finished and save output files
  CC=$?
  if test $CC -ne 0
  then
    echo " *** SMCGPropMP crashed !!! *** "
  else
##  Save output files
    echo " *** SMCGPropMP finished !!! *** "
  fi
  echo " Done for grid $GridName "

 echo " *** END *** "

 exit 0

