Skip to content
Snippets Groups Projects
retest 2.76 KiB
Newer Older
Reuben D. Budiardja's avatar
Reuben D. Budiardja committed
#!/bin/ksh

############################## standard interface to /sw tools
# Input:
#   Environment variables
#     SW_BLDDIR    current directory (PWD) minus /autofs/na1_ stuff
#     SW_ENVFILE   file to be sourced which has alternate prog environment
#                     only to be used in special circumstances
#     SW_WORKDIR   work dir that local script can use
# Output:
#   Return code of 0=success or 1=failure   or 2=job submitted
#
# Notes:
#   If this script is called from swtest, then swtest requires 
#   SW_WORKDIR to be set.  Then swtest adds a unique path to what 
#   user gave swtest (action+timestamp+build) and provides this
#   script with a uniquely valued SW_WORKDIR.  swtest will
#   automatically remove this unique workspace when retest is done.
##################################################################


if [ -z $SW_BLDDIR ]; then
  echo "Error: SW_BLDDIR not set!"
  exit 1
else
  cd $SW_BLDDIR
fi

if [ -z $SW_ENVFILE ]; then
  ### Set Environment (do not remove this line only change what is in between)
  . ${MODULESHOME}/init/ksh
  . ${SW_BLDDIR}/remodule
  ### End Environment (do not remove this line only change what is in between)
else
  . $SW_ENVFILE
fi
          
############################## app specific section
#  
set -o verbose

#clear out status file
rm -f status

cp /sw/testcases/nwchem/* $SW_WORKDIR/

cp -a $SW_BLDDIR/data $SW_WORKDIR/
cp -a $SW_BLDDIR/etc $SW_WORKDIR/

cd $SW_WORKDIR

cat > ${PACKAGE}.pbs << EOF
#!/bin/bash
#PBS -N ${PACKAGE}
#PBS -j oe
#PBS -l nodes=8:ppn=32,walltime=2:00:00
Reuben D. Budiardja's avatar
Reuben D. Budiardja committed

cd \$PBS_O_WORKDIR

export PATH=${SW_BLDDIR}/bin:\${PATH}
export NWCHEM_EXECUTABLE=${SW_BLDDIR}/bin/nwchem
export NWCHEM_TOP=${NWCHEM_TOP}
export NWCHEM_TARGET=LINUX64
export MPIRUN_PATH=\`which aprun\`
export MPIRUN_NPOPT=-n

export NWCHEM_NWPW_LIBRARY=${SW_WORKDIR}/data/libraryps/
export NWCHEM_BASIS_LIBRARY=${SW_WORKDIR}/data/libraries/
export HOME_NWCHEMRC=${SW_WORKDIR}/etc

aprun -n 256 nwchem Input_c240_pbe0.nw 2>&1 > nwchem.log

if [[ "\$?" -eq 0 ]]; then  
  echo verified > $SW_BLDDIR/status
else
  echo unverified > $SW_BLDDIR/status
fi
chmod 664 $SW_BLDDIR/status

tail -n 2 nwchem.log | grep wall | awk '{print "YVALUE=",\$6}' \
  | sed 's/ //g' | sed 's/s//g' > ${SW_BLDDIR}/wallclock
grep "Max memory" nwchem.log | awk '{print "YVALUE=",\$9}' \
  | sed 's/ //g' > ${SW_BLDDIR}/memory

JOBID=\`echo \$PBS_JOBID | cut -d "." -f1 \`
cat nwchem.log >> ${SW_BLDDIR}/test.log
cat \$PBS_JOBNAME.o\$JOBID >> ${SW_BLDDIR}/test.log
chmod 664 ${SW_BLDDIR}/test.log

rm -f ${SW_BLDDIR}/.running
EOF

qsub ${PACKAGE}.pbs > ${SW_BLDDIR}/.running
if [ $? -ne 0 ] ; then
  echo "Error submitting job"
  rm -f .running
  exit 1
else
  echo "Job submitted"
  cat ${SW_BLDDIR}/.running
  exit 2
fi
  
################################ if this far, return 0
exit 0