#!/bin/bash
#!
#! Copyright (C) 2013 Andrea Dal Corso 
#! This file is distributed under the terms of the
#! GNU General Public License. See the file `License'
#! in the root directory of the present distribution,
#! or http://www.gnu.org/copyleft/gpl.txt .
#!

. ../QE_path
element='all'

# do not change after this line. Uncomment the appropriate line if
# you want to test the additional PPs or to use a version of 
# QE < 5.0 (at your own risk).

work=./TEST
#  For QE < 5.0 
#. $PWDIR/example/environment_variables
#
. $PWDIR/environment_variables
BIN_DIR=$PWDIR/bin

mkdir $work >& /dev/null

. ../paw_ps_test_high.job
. ../us_ps_test_high.job
. ../paw_ps_test_low.job
. ../us_ps_test_low.job

#  Uncomment the following lines to test the old pslibrary.0.3.1 PPs
#
#. ../paw_ps_test.job
#. ../us_ps_test.job

#  Uncomment the following line to test the NC-PPs. 
#
#. ../nc_ps_test.job

#  Uncomment the following line to test additional PAW data sets. 
#
#. ../paw_ps_test_tot.job

#  Uncomment the following line to test alternative PAW data sets. 
#
#. ../paw_ps_test_alt.job

#
#  Old tests of the PAW data-sets for Lanthanides. 
#  Require an atomic code with svn version older than 10324.
#  This file is obsolete. The test have been moved in paw_ps_test_low.job
#
#. ../paw_lan_test.job

#  Uncomment the following line to test additional US-PPs. 
#
#. ../us_ps_test_tot.job

#  Uncomment the following line to test alternative US-PPs. 
#
#. ../us_ps_test_alt.job

#  Old tests of the PAW data-sets for Lanthanides. 
#  Require an atomic code with svn version older than 10324.
#  This file is obsolete. The test have been moved in us_ps_test_low.job
#
#. ../us_lan_test.job

ld1_command="$PARA_PREFIX $BIN_DIR/ld1.x $PARA_POSTFIX"

echo "ld1_command =" $ld1_command

for elem in $element ; do
    if [ $elem = "all" ] ;
    then
       for atom in *.in ; do
          echo -e "Making   $atom  ...\c"
          $ld1_command < ./$atom > $work/$atom.out
          warn=`grep ! $work/$atom.out | head -1 |cut -c 36-40`
          if [ "$warn" = "" ] ;
          then
             echo '  Done' 
          else
             echo '  Done !' 
             grep ! $work/$atom.out
          fi
       done
   else
       for atom in "$elem"*.in ; do
          echo -e "Making   $atom  ...\c"
          $ld1_command < ./$atom > $work/$atom.out
          warn=`grep ! $work/$atom.out | head -1 |cut -c 36-40`
          if [ "$warn" = "" ] ;
          then
             echo '  Done' 
          else
             echo '  Done !' 
             grep ! $work/$atom.out
          fi
       done

   fi
done

\mv *.in $work
