set +x off
echo ""
echo "  Thank you for installing psi4. Additional resources:"
# It is recommended that you run script"
#echo "    >>> ${PREFIX}/share/psi/scripts/setenv.py"
#echo "  to configure the runtime environment. 
#echo "  Additional resources:"
echo "    Website: www.psicode.org"
echo "    GitHub:  https://github.com/psi4/psi4public/wiki"
echo "    Binstar: https://binstar.org/psi4"
echo "    Manual:  bit.ly/psi4manual"
echo "    Inputs:  ${PREFIX}/share/psi/samples"

ps=$PSI_SCRATCH

echo ""
echo "  # For csh/tcsh command-line use, add to shell or ~/.tcshrc file:"
echo "    setenv PATH ${PREFIX}/bin:\$PATH"

if [ -z ${ps+x} ]
then 
  export PSI_SCRATCH=/tmp
  echo "    setenv PSI_SCRATCH /path/to/existing/writable/local-not-network-disk/for/scratch/files"
else
  echo "    # current setting; should be existing, writable, local (not network) dir for scratch files"
  echo "    setenv PSI_SCRATCH $ps"
fi

echo ""
echo "  # For sh/bash command-line use, add to shell or ~/.bashrc file:"
echo "    export PATH=${PREFIX}/bin:\$PATH"

if [ -z ${ps+x} ]
then 
  echo "    export PSI_SCRATCH=/path/to/existing/writable/local-not-network-disk/for/scratch/files"
else
  echo "    # current setting; should be existing, writable, local (not network) dir for scratch files"
  echo "    export PSI_SCRATCH=$ps"
fi

cat > linktest.in << EOL
memory 250 mb

molecule dimer {
0 1
C   0.000000  -0.667578  -2.124659
C   0.000000   0.667578  -2.124659
H   0.923621  -1.232253  -2.126185
H  -0.923621  -1.232253  -2.126185
H  -0.923621   1.232253  -2.126185
H   0.923621   1.232253  -2.126185
--
0 1
C   0.000000   0.000000   2.900503
C   0.000000   0.000000   1.693240
H   0.000000   0.000000   0.627352
H   0.000000   0.000000   3.963929
}

set {
  BASIS jun-cc-pVDZ
  SCF_TYPE DF
  FREEZE_CORE True
}

energy('sapt0')

compare_values(85.189064196429, dimer.nuclear_repulsion_energy(), 9, "Nuclear Repulsion Energy")
compare_values(-0.003378388762, psi4.get_variable("SAPT ELST ENERGY"), 6, "SAPT0 Eelst")
compare_values( 0.003704416103, psi4.get_variable("SAPT EXCH ENERGY"), 6, "SAPT0 Eexch")
compare_values(-0.000889316601, psi4.get_variable("SAPT IND ENERGY"), 6, "SAPT0 Eind")
compare_values(-0.001672292164, psi4.get_variable("SAPT DISP ENERGY"), 6, "SAPT0 Edisp")
compare_values(-0.002235581423, psi4.get_variable("SAPT SAPT0 ENERGY"), 6, "SAPT0 Etotal")
EOL

#PSIOUT=`${PREFIX}/bin/psi4 ${PREFIX}/share/psi/samples/tu1-h2o-energy/input.dat`
PSIOUT=`PSI_SCRATCH=/tmp ${PREFIX}/bin/psi4 ${PREFIX}/share/psi/samples/tu1-h2o-energy/input.dat`
echo $PSIOUT

