# -*- mode: makefile -*-
#
#  testexamples_X - Runs various PETSc test suites

#    6 - C examples that don't work with complex numbers, require PETSc matrices
#    8 - Fortran .F examples that don't work with complex numbers
#   13 - Examples that should only be compiled.
#   17 - requires PYTHON or wget and Unix (uses urlget) and popen()

testexamples_C: ${TESTEXAMPLES_C}
testexamples_C_Info: ${TESTEXAMPLES_C_INFO}
testexamples_C_NotSingle: ${TESTEXAMPLES_C_NOTSINGLE}
testexamples_Cxx: ${TESTEXAMPLES_CXX}
testexamples_C_X: ${TESTEXAMPLES_C_X}
testexamples_Fortran: ${TESTEXAMPLES_FORTRAN}
testexamples_Fortran_NotSingle: ${TESTEXAMPLES_FORTRAN_NOTSINGLE}
testexamples_C_X_MPIUni: ${TESTEXAMPLES_C_X_MPIUNI}
testexamples_C_Complex: ${TESTEXAMPLES_C_COMPLEX}
testexamples_C_NoComplex: ${TESTEXAMPLES_C_NOCOMPLEX}
testexamples_C_NoComplex_NotSingle: ${TESTEXAMPLES_C_NOCOMPLEX_NOTSINGLE}
testexamples_DATAFILESPATH: ${TESTEXAMPLES_DATAFILESPATH}
testexamples_Cxx_DATAFILESPATH: ${TESTEXAMPLES_CXX_DATAFILESPATH}
testexamples_DOUBLEINT32: ${TESTEXAMPLES_DOUBLEINT32}

testexamples_F90_DataTypes: ${TESTEXAMPLES_F90_DATATYPES}
testexamples_Fortran_NoComplex: ${TESTEXAMPLES_FORTRAN_NOCOMPLEX}
testexamples_Fortran_NoComplex_NotSingle: ${TESTEXAMPLES_FORTRAN_NOCOMPLEX_NOTSINGLE}
testexamples_Fortran_MPIUni: ${TESTEXAMPLES_FORTRAN_MPIUNI}
testexamples_Fortran_Complex: ${TESTEXAMPLES_FORTRAN_COMPLEX}
testexamples_C_Complex_MPIUni: ${TESTEXAMPLES_C_CCOMPLEX_MPIUNI}
testexamples_F90: ${TESTEXAMPLES_F90}
testexamples_F90_NotSingle: ${TESTEXAMPLES_F90_NOTSINGLE}
testexamples_F90_Complex: ${TESTEXAMPLES_F90_COMPLEX}
testexamples_F90_NoComplex: ${TESTEXAMPLES_F90_NOCOMPLEX}
testexamples_F2003: ${TESTEXAMPLES_F2003}
testexamples_13: ${TESTEXAMPLES_13}
testexamples_17: ${TESTEXAMPLES_17}
testexamples_18: ${TESTEXAMPLES_18}
testexamples_PARMETIS: ${TESTEXAMPLES_PARMETIS}
testexamples_METIS: ${TESTEXAMPLES_METIS}
testexamples_SPAI: ${TESTEXAMPLES_SPAI}
testexamples_ADIFOR: ${TESTEXAMPLES_ADIFOR}
testexamples_FFTW: ${TESTEXAMPLES_FFTW}
testexamples_FFTW_COMPLEX: ${TESTEXAMPLES_FFTW_COMPLEX}
testexamples_SAWS: ${TESTEXAMPLES_SAWS}
testexamples_VALGRIND: ${TESTEXAMPLES_VALGRIND}
testexamples_MATLAB: ${TESTEXAMPLES_MATLAB}
testexamples_MATLAB_ENGINE: ${TESTEXAMPLES_MATLAB_ENGINE}
testexamples_MUMPS: ${TESTEXAMPLES_MUMPS}
testexamples_MUMPS_DATAFILESPATH: ${TESTEXAMPLES_MUMPS_DATAFILESPATH}
testexamples_SUPERLU: ${TESTEXAMPLES_SUPERLU}
testexamples_SUPERLU_DATAFILESPATH: ${TESTEXAMPLES_SUPERLU_DATAFILESPATH}
testexamples_PARMETIS_DATAFILESPATH: ${TESTEXAMPLES_PARMETIS_DATAFILESPATH}
testexamples_ELEMENTAL: ${TESTEXAMPLES_ELEMENTAL}
testexamples_SUNDIALS: ${TESTEXAMPLES_SUNDIALS}
testexamples_SUITESPARSE: ${TESTEXAMPLES_SUITESPARSE}
testexamples_SUITESPARSE_DATAFILESPATH: ${TESTEXAMPLES_SUITESPARSE_DATAFILESPATH}
testexamples_MKL_PARDISO: ${TESTEXAMPLES_MKL_PARDISO}
testexamples_SUPERLU_DIST: ${TESTEXAMPLES_SUPERLU_DIST}
testexamples_SUPERLU_DIST_DATAFILESPATH: ${TESTEXAMPLES_SUPERLU_DIST_DATAFILESPATH}
testexamples_SUPERLU_DIST_COMPLEX: ${TESTEXAMPLES_SUPERLU_DIST_COMPLEX}
testexamples_HYPRE: ${TESTEXAMPLES_HYPRE}
testexamples_HYPRE_DATAFILESPATH: ${TESTEXAMPLES_HYPRE_DATAFILESPATH}
testexamples_HDF5: ${TESTEXAMPLES_HDF5}
testexamples_CHACO: ${TESTEXAMPLES_CHACO}
testexamples_CHOMBO: ${TESTEXAMPLES_CHOMBO}
testexamples_TRIANGLE: ${TESTEXAMPLES_TRIANGLE}
testexamples_CTETGEN: ${TESTEXAMPLES_CTETGEN}
testexamples_SSL: ${TESTEXAMPLES_SSL}
testexamples_PARMS: ${TESTEXAMPLES_PARMS}
testexamples_TCHEM: ${TESTEXAMPLES_TCHEM}

testexamples_BOOST: ${TESTEXAMPLES_BOOST}
testexamples_TETGEN: ${TESTEXAMPLES_TETGEN}
testexamples_PTSCOTCH: ${TESTEXAMPLES_PTSCOTCH}
testexamples_PASTIX: ${TESTEXAMPLES_PASTIX}
testexamples_PASTIX_DATAFILESPATH: ${TESTEXAMPLES_PASTIX_DATAFILESPATH}
testexamples_ML: ${TESTEXAMPLES_ML}
testexamples_CUSP: ${TESTEXAMPLES_CUSP}
testexamples_CUDA: ${TESTEXAMPLES_CUDA}
testexamples_CUDA_DATAFILESPATH: ${TESTEXAMPLES_CUDA_DATAFILESPATH}
testexamples_YAML: ${TESTEXAMPLES_YAML}
testexamples_MOAB: ${TESTEXAMPLES_MOAB}
testexamples_MOAB_HDF5: ${TESTEXAMPLES_MOAB_HDF5}
testexamples_TRILINOS: ${TESTEXAMPLES_TRILINOS}
testexamples_REVOLVE: ${TESTEXAMPLES_REVOLVE}
testexamples_X:
testexamples_OPENGL:
testexamples_MPE:
testexamples_ESSL:
testexamples_MPI:
testexamples_BLASLAPACK:
testexamples_SOWING:
testexamples_C2HTML:
testexamples_BLACS:
testexamples_SCALAPACK:
testexamples_CMAKE:
testexamples_AFTERIMAGE:
testexamples_OPENMP:
testexamples_NETCDF:
testexamples_EXODUSII:

buildexamples_C:
	-@${OMAKE} testexamples_C TESTEXAMPLES_C=`echo ${TESTEXAMPLES_C} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_Cxx:
	-@${OMAKE} testexamples_Cxx TESTEXAMPLES_CXX=`echo ${TESTEXAMPLES_CXX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_C_X:
	-@${OMAKE} testexamples_C_X TESTEXAMPLES_C_X=`echo ${TESTEXAMPLES_C_X} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_Fortran:
	-@${OMAKE} testexamples_Fortran TESTEXAMPLES_FORTRAN=`echo ${TESTEXAMPLES_FORTRAN} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_C_X_MPIUni:
	-@${OMAKE} testexamples_C_X_MPIUni TESTEXAMPLES_C_X_MPIUNI=`echo ${TESTEXAMPLES_C_X_MPIUNI} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_C_Complex:
	-@${OMAKE} testexamples_C_Complex TESTEXAMPLES_C_COMPLEX=`echo ${TESTEXAMPLES_C_COMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_C_NoComplex:
	-@${OMAKE} testexamples_C_NoComplex TESTEXAMPLES_C_NOCOMPLEX=`echo ${TESTEXAMPLES_C_NOCOMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_DATAFILESPATH:
	-@${OMAKE} testexamples_DATAFILESPATH TESTEXAMPLES_DATAFILESPATH=`echo ${TESTEXAMPLES_DATAFILESPATH} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_Cxx_DATAFILESPATH:
	-@${OMAKE} testexamples_Cxx_DATAFILESPATH TESTEXAMPLES_CXX_DATAFILESPATH=`echo ${TESTEXAMPLES_CXX_DATAFILESPATH} | sed s/runex[0-9]*[a-z0-9_]*//g`

buildexamples_F90_DataTypes:
	-@${OMAKE} testexamples_F90_DataTypes TESTEXAMPLES_F90_DATATYPES=`echo ${TESTEXAMPLES_F90_DATATYPES} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_Fortran_NoComplex:
	-@${OMAKE} testexamples_Fortran_NoComplex TESTEXAMPLES_FORTRAN_NOCOMPLEX=`echo ${TESTEXAMPLES_FORTRAN_NOCOMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_Fortran_MPIUni:
	-@${OMAKE} testexamples_Fortran_MPIUni TESTEXAMPLES_FORTRAN_MPIUNI=`echo ${TESTEXAMPLES_FORTRAN_MPIUNI} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_Fortran_Complex:
	-@${OMAKE} testexamples_Fortran_Complex TESTEXAMPLES_FORTRAN_COMPLEX=`echo ${TESTEXAMPLES_FORTRAN_COMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_C_Complex_MPIUni:
	-@${OMAKE} testexamples_C_Complex_MPIUni TESTEXAMPLES_C_COMPLEX_MPIUNI=`echo ${TESTEXAMPLES_C_COMPLEX_MPIUNI} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_F90:
	-@${OMAKE} testexamples_F90 TESTEXAMPLES_F90=`echo ${TESTEXAMPLES_F90} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_F90_Complex:
	-@${OMAKE} testexamples_F90_Complex TESTEXAMPLES_F90_COMPLEX=`echo ${TESTEXAMPLES_F90_COMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_F90_NoComplex:
	-@${OMAKE} testexamples_F90_NoComplex TESTEXAMPLES_F90_NOCOMPLEX=`echo ${TESTEXAMPLES_F90_NOCOMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_F2003:
	-@${OMAKE} testexamples_F2003 TESTEXAMPLES_2003=`echo ${TESTEXAMPLES_F2003} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_13:
	-@${OMAKE} testexamples_13 TESTEXAMPLES_13=`echo ${TESTEXAMPLES_13} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_17:
	-@${OMAKE} testexamples_17 TESTEXAMPLES_17=`echo ${TESTEXAMPLES_17} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_18:
	-@${OMAKE} testexamples_18 TESTEXAMPLES_18=`echo ${TESTEXAMPLES_18} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_PARMETIS:
	-@${OMAKE} testexamples_PARMETIS TESTEXAMPLES_PARMETIS=`echo ${TESTEXAMPLES_PARMETIS} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_METIS:
	-@${OMAKE} testexamples_METIS TESTEXAMPLES_METIS=`echo ${TESTEXAMPLES_METIS} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SPAI:
	-@${OMAKE} testexamples_SPAI TESTEXAMPLES_SPAI=`echo ${TESTEXAMPLES_SPAI} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_ADIFOR:
	-@${OMAKE} testexamples_ADIFOR TESTEXAMPLES_ADIFOR=`echo ${TESTEXAMPLES_ADIFOR} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_FFTW:
	-@${OMAKE} testexamples_FFTW TESTEXAMPLES_FFTW=`echo ${TESTEXAMPLES_FFTW} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_FFTW_COMPLEX:
	-@${OMAKE} testexamples_FFTW_COMPLEX TESTEXAMPLES_FFTW_COMPLEX=`echo ${TESTEXAMPLES_FFTW_COMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SAWS:
	-@${OMAKE} testexamples_SAWS TESTEXAMPLES_SAWS=`echo ${TESTEXAMPLES_SAWS} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_VALGRIND:
	-@${OMAKE} testexamples_VALGRIND TESTEXAMPLES_VALGRIND=`echo ${TESTEXAMPLES_VALGRIND} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_MATLAB:
	-@${OMAKE} testexamples_MATLAB TESTEXAMPLES_MATLAB=`echo ${TESTEXAMPLES_MATLAB} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_MATLAB_ENGINE:
	-@${OMAKE} testexamples_MATLAB_ENGINE TESTEXAMPLES_MATLAB_ENGINE=`echo ${TESTEXAMPLES_MATLAB_ENGINE} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_MUMPS:
	-@${OMAKE} testexamples_MUMPS TESTEXAMPLES_MUMPS=`echo ${TESTEXAMPLES_MUMPS} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SUPERLU:
	-@${OMAKE} testexamples_SUPERLU TESTEXAMPLES_SUPERLU=`echo ${TESTEXAMPLES_SUPERLU} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SUNDIALS:
	-@${OMAKE} testexamples_SUNDIALS TESTEXAMPLES_SUNDIALS=`echo ${TESTEXAMPLES_SUNDIALS} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SUITESPARSE:
	-@${OMAKE} testexamples_SUITESPARSE TESTEXAMPLES_SUITESPARSE=`echo ${TESTEXAMPLES_SUITESPARSE} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_MKL_PARDISO:
	-@${OMAKE} testexamples_MKL_PARDISO TESTEXAMPLES_MKL_PARDISO=`echo ${TESTEXAMPLES_MKL_PARDISO} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SUPERLU_DIST:
	-@${OMAKE} testexamples_SUPERLU_DIST TESTEXAMPLES_SUPERLU_DIST=`echo ${TESTEXAMPLES_SUPERLU_DIST} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_SUPERLU_DIST_COMPLEX:
	-@${OMAKE} testexamples_SUPERLU_DIST_COMPLEX TESTEXAMPLES_SUPERLU_DIST_COMPLEX=`echo ${TESTEXAMPLES_SUPERLU_DIST_COMPLEX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_HYPRE_DATAFILESPATH:
	-@${OMAKE} testexamples_HYPRE_DATAFILESPATH TESTEXAMPLES_HYPRE_DATAFILESPATH=`echo ${TESTEXAMPLES_HYPRE_DATAFILESPATH} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_HYPRE:
	-@${OMAKE} testexamples_HYPRE TESTEXAMPLES_HYPRE=`echo ${TESTEXAMPLES_HYPRE} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_HDF5:
	-@${OMAKE} testexamples_HDF5 TESTEXAMPLES_HDF5=`echo ${TESTEXAMPLES_HDF5} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_CHACO:
	-@${OMAKE} testexamples_CHACO TESTEXAMPLES_CHACO=`echo ${TESTEXAMPLES_CHACO} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_CHOMBO:
	-@${OMAKE} testexamples_CHOMBO TESTEXAMPLES_CHOMBO=`echo ${TESTEXAMPLES_CHOMBO} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_TRIANGLE:
	-@${OMAKE} testexamples_TRIANGLE TESTEXAMPLES_TRIANGLE=`echo ${TESTEXAMPLES_TRIANGLE} | sed s/runex[0-9]*[a-z0-9_]*//g`

buildexamples_BOOST:
	-@${OMAKE} testexamples_BOOST TESTEXAMPLES_BOOST=`echo ${TESTEXAMPLES_BOOST} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_TETGEN:
	-@${OMAKE} testexamples_TETGEN TESTEXAMPLES_TETGEN=`echo ${TESTEXAMPLES_TETGEN} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_PTSCOTCH:
	-@${OMAKE} testexamples_PTSCOTCH TESTEXAMPLES_PTSCOTCH=`echo ${TESTEXAMPLES_PTSCOTCH} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_PASTIX:
	-@${OMAKE} testexamples_PASTIX TESTEXAMPLES_PASTIX=`echo ${TESTEXAMPLES_PASTIX} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_ML:
	-@${OMAKE} testexamples_ML TESTEXAMPLES_ML=`echo ${TESTEXAMPLES_ML} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_CUSP:
	-@${OMAKE} testexamples_CUSP TESTEXAMPLES_CUSP=`echo ${TESTEXAMPLES_CUSP} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_CUDA:
	-@${OMAKE} testexamples_CUDA TESTEXAMPLES_CUDA=`echo ${TESTEXAMPLES_CUDA} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_YAML:
	-@${OMAKE} testexamples_YAML TESTEXAMPLES_YAML=`echo ${TESTEXAMPLES_YAML} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_MOAB:
	-@${OMAKE} testexamples_MOAB TESTEXAMPLES_MOAB=`echo ${TESTEXAMPLES_MOAB} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_REVOLVE:
	-@${OMAKE} testexamples_REVOLVE TESTEXAMPLES_REVOLVE=`echo ${TESTEXAMPLES_REVOLVE} | sed s/runex[0-9]*[a-z0-9_]*//g`
buildexamples_X:
buildexamples_OPENGL:
buildexamples_MPE:
buildexamples_ESSL:
buildexamples_MPI:
buildexamples_BLASLAPACK:
buildexamples_SOWING:
buildexamples_C2HTML:
buildexamples_BLACS:
buildexamples_SCALAPACK:
buildexamples_CMAKE:
buildexamples_AFTERIMAGE:
buildexamples_OPENMP:

TESTMODE = testexamples

alltests:
	-@${RM} ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log
	-@ln -s ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log
	-@${OMAKE} alltest DIFF=${PETSC_DIR}/bin/petscdiff PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} MPIEXEC="${MPIEXEC}" DATAFILESPATH=${DATAFILESPATH} 2>&1 | tee ${PETSC_ARCH}/lib/petsc/conf/alltests.log

alltest:
	-@date
	-@for i in ${TEST_RUNS} ; do \
          echo "******* Testing: ${TESTMODE}_$$i *******"; \
	  ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=${TESTMODE}_$$i MPIEXEC="${MPIEXEC}" NO_PRINT_DIR=yes tree ; \
	done
	-@date

#
#  parallel make of examples by directory
#  The MAKEFLAGS= MFLAGS=  are so that the sub make processes don't know about the parallel make server of the main make process
#  split the larger test directories up for more parallelism
SUBDIRS =    src/ts/examples/tutorials src/snes/examples/tutorials src/ksp/ksp/examples/tutorials src/dm src/sys src/mat src/vec src/ksp/ksp/examples/tests src/ksp/ksp/examples/tests src/ts/examples/tests src/ksp/pc

$(SUBDIRS)::
	MAKEFLAGS= MFLAGS= $(OMAKE) -j 1 -C $@ alltest  > $@/alltests.log  2>&1 

palltests:
	-@${RM} ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log
	-@ln -s ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log
	-@${OMAKE} -j ${MAKE_NP} $(SUBDIRS)
	-@cat src/*/alltests.log src/*/examples/*/alltests.log  src/ksp/pc/alltests.log  > ${PETSC_ARCH}/lib/petsc/conf/alltests.log


tests_DATAFILESPATH:
	make ACTION=testexamples_DATAFILESPATH tree DATAFILESPATH=${DATAFILESPATH}


