#! /bin/sh
#
# This is a simple script that makes sure that checkbuilds can be
# created and then runs it.
# The cb suffix is for "check build"
# Set defaults for the MPICH2 home
srcdir=/home/MPI/testing/mpich2/mpich2
if [ ! -d $srcdir ] ; then
if [ -d /homes/MPI/testing/mpich2/mpich2 ] ; then
srcdir=/homes/MPI/testing/mpich2/mpich2
else
# We'll check for it later, after the args
srcdir=
fi
fi
outdir=/home/MPI/nightly
if [ ! -d $outdir ] ; then
if [ -d /homes/MPI/nightly ] ; then
outdir=/homes/MPI/nightly
else
# We'll check for it later, after the args
outdir=
fi
fi
if [ -d "/home/MPI/testing/tsuites" ] ; then
projectsdir="/home/MPI/testing/tsuites"
elif [ -d "/homes/MPI/testing/tsuites" ] ; then
projectsdir="/homes/MPI/testing/tsuites"
elif [ -d "/Users/$LOGNAME/projects/software/testing" ] ; then
projectsdir="/Users/$LOGNAME/projects/software/testing"
fi
date=`date "+%Y-%m-%d"`
# default outfile
outfile=testbuild.xml
tests="mpich:mpicxx:intel:testmpio" # Optional: mpich2
#
# Option options to checkbuild
other_opts=""
# Keep track of which compilers are set
ccset=no
cxxset=no
fcset=no
f90set=no
#
# Get options
for arg in "$@" ; do
argval=""
case $arg in
-*=*) argval=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
esac
case $arg in
-outfile=*) outfile=$argval ;;
-outdir=*) outdir=$argval ;;
-srcdir=*) srcdir=$argval ;;
-tests=*) tests=$argval ;;
-tmpdir=*) tmpdir=$argval ;;
-projectsdir=*) projectsdir=$argval ;; # directory containing test sources
-echo) set -x ;;
*) other_opts="$other_opts '$arg'"
envset=`echo A$arg | sed -e 's/A-env=\([A-Z]*\).*/\1/'`
if [ "$envset" != "$arg" ] ; then
case $envset in
CC) ccset=yes ;;
FC) fcset=yes ;;
CXX) cxxset=yes ;;
F90) f90set=yes ;;
esac
fi
;;
esac
done
if [ -z "$rundir" ] ; then rundir=$tmpdir/cb/mpich2 ; fi
if [ -z "$mpichtestdir" ] ; then mpichtestdir=$tmpdir/cb/mpitest ; fi
if [ -z "$mpicxxtestdir" ] ; then mpicxxtestdir=$tmpdir/cb/mpicxxtest ; fi
if [ -z "$inteltestdir" ] ; then inteltestdir=$tmpdir/cb/MPITEST ; fi
if [ -z "$testmpiodir" ] ; then testmpiodir=$tmpdir/cb/testmpio ; fi
if [ -z "$tmpdir" ] ; then tmpdir=/sandbox/$LOGNAME ; fi
# Construct the full outfile name from the dir and file
outfile="$outdir/$outfile"
if [ -z "$srcdir" ] ; then
echo "Source directory for MPICH not specified!"
exit 1
fi
if [ ! -d "$srcdir" ] ; then
echo "Could not find MPICH2 source dir $srcdir"
exit 1
fi
if [ ! -d $rundir ] ; then
# Assume that we have mkdir -p
mkdir -p $rundir
fi
if [ ! -d $outdir ] ; then
# Assume that we have mkdir -p
mkdir -p $outdir
fi
if [ ! -d "$rundir/maint" ] ; then
mkdir "$rundir/maint"
fi
if [ ! -d $mpichtestdir ] ; then
mkdir $mpichtestdir
fi
if [ ! -d $mpicxxtestdir ] ; then
mkdir $mpicxxtestdir
fi
if [ ! -d $testmpiodir ] ; then
mkdir $testmpiodir
fi
if [ ! -d $inteltestdir ] ; then
mkdir $inteltestdir
fi
# We don't need to build the mpich2testdir because it is part of the mpich2
# distribution
# Build the current version of checkbuilds
(cd $rundir/maint && $srcdir/maint/configure 2>&1 >/dev/null)
if [ ! -x $rundir/maint/checkbuilds ] ; then
echo "Could not build checkbuilds"
exit 1
fi
#
#
# -tests="mpich:mpicxx:intel"
# Use -tests="mpich:mpicxx" to get a smaller list of tests.
# Use eval to make sure that quoted arguments containing spaces are handled
# correctly
# Set the default values of the CC and FC environment variables
#envargs='-envopt="CC;cc;gcc" -envopt="FC;f77;g77"'
envargs=""
if [ "$ccset" = no ] ; then
envargs='-envopt="CC;cc;gcc"'
fi
if [ "$fcset" = no ] ; then
# envargs="$envargs '-envopt="'"'"FC;f77;g77"'"'"'"
envargs="$envargs -envopt="'"'"FC;f77;g77"'"'
fi
# '-envopt="CC;cc;gcc"' '-envopt="FC;f77;g77"'
eval $rundir/maint/checkbuilds -rundir=$rundir \
--srcdir=$srcdir \
--projectsdir=$projectsdir \
$envargs \
"-tests='""$tests""'" -tmpdir=$tmpdir \
-xml -maxcount=1 -outfile=$outfile $other_opts