#
CFLAGS		 = 
FFLAGS		 = 
CPPFLAGS         =
FPPFLAGS         =
MANSEC           = Vec
LOCDIR		 = src/vec/vec/examples/tutorials/
EXAMPLESC	 = ex1.c ex1e.c ex2.c ex3.c ex5.c ex6.c ex7.c ex8.c ex9.c ex10.c ex11.c ex12.c ex13.c ex16.c ex17.c
EXAMPLESF	 = ex1f.F ex2f.F ex3f.F ex4f.F ex7f.F ex1f90.F ex4f90.F ex9f.F ex11f.F ex14f.F

include ${PETSC_DIR}/bmake/common/base

ex1: ex1.o  chkopts 
	-${CLINKER} -o ex1 ex1.o ${PETSC_VEC_LIB}
	${RM} -f ex1.o

ex1e: ex1e.o  chkopts 
	-${CLINKER} -o ex1e ex1e.o ${PETSC_VEC_LIB}
	${RM} -f ex1e.o

ex1f: ex1f.o  chkopts
	-${FLINKER} -o ex1f ex1f.o ${PETSC_VEC_LIB}
	${RM} -f ex1f.o

ex1f90: ex1f90.o  chkopts
	-${FLINKER} -o ex1f90 ex1f90.o ${PETSC_VEC_LIB}
	${RM} -f ex1f90.o

ex2: ex2.o  chkopts
	-${CLINKER} -o ex2 ex2.o  ${PETSC_VEC_LIB}
	${RM} -f ex2.o

ex2f: ex2f.o  chkopts
	-${FLINKER} -o ex2f ex2f.o ${PETSC_VEC_LIB}
	${RM} -f ex2f.o

ex3: ex3.o  chkopts
	-${CLINKER} -o ex3 ex3.o  ${PETSC_VEC_LIB}
	${RM} -f ex3.o

ex3f: ex3f.o  chkopts
	-${FLINKER} -o ex3f ex3f.o ${PETSC_VEC_LIB}
	${RM} -f ex3f.o

ex4: ex4.o  chkopts
	-${CLINKER} -o ex4 ex4.o  ${PETSC_VEC_LIB}
	${RM} -f ex4.o

ex4f: ex4f.o  chkopts
	-${FLINKER} -o ex4f ex4f.o ${PETSC_VEC_LIB}
	${RM} -f ex4f.o

ex4f90: ex4f90.o  chkopts
	-${FLINKER} -o ex4f90 ex4f90.o ${PETSC_VEC_LIB}
	${RM} -f ex4f90.o

ex5: ex5.o  chkopts
	-${CLINKER} -o ex5 ex5.o  ${PETSC_VEC_LIB}
	${RM} -f ex5.o

ex6: ex6.o  chkopts
	-${CLINKER} -o ex6 ex6.o  ${PETSC_VEC_LIB}
	${RM} -f ex6.o

ex7: ex7.o ex7f.o chkopts
	-${CLINKER} -o ex7 ex7.o ex7f.o ${PETSC_VEC_LIB} 
	${RM} -f ex7.o ex7f.o

ex8: ex8.o  chkopts
	-${CLINKER} -o ex8 ex8.o  ${PETSC_VEC_LIB}
	${RM} -f ex8.o

ex9: ex9.o  chkopts
	-${CLINKER} -o ex9 ex9.o  ${PETSC_VEC_LIB}
	${RM} -f ex9.o

ex9f: ex9f.o  chkopts
	-${FLINKER} -o ex9f ex9f.o ${PETSC_VEC_LIB}
	${RM} -f ex9f.o

ex10: ex10.o  chkopts
	-${CLINKER} -o ex10 ex10.o  ${PETSC_VEC_LIB}
	${RM} -f ex10.o

ex11: ex11.o  chkopts
	-${CLINKER} -o ex11 ex11.o  ${PETSC_VEC_LIB}
	${RM} -f ex11.o

ex11f: ex11f.o  chkopts
	-${FLINKER} -o ex11f ex11f.o ${PETSC_VEC_LIB}
	${RM} -f ex11f.o

ex12: ex12.o  chkopts
	-${CLINKER} -o ex12 ex12.o  ${PETSC_VEC_LIB}
	${RM} -f ex12.o

ex13: ex13.o  chkopts
	-${CLINKER} -o ex13 ex13.o  ${PETSC_VEC_LIB}
	${RM} -f ex13.o

ex14f: ex14f.o  chkopts
	-${FLINKER} -o ex14f ex14f.o ${PETSC_VEC_LIB}
	${RM} -f ex14f.o

ex15: ex15.o  chkopts
	-${CLINKER} -o $@ $@.o  ${PETSC_KSP_LIB}
	${RM} -f $@.o

ex16: ex16.o  chkopts
	-${CLINKER} -o $@ $@.o  ${PETSC_KSP_LIB}
	${RM} -f $@.o

ex17: ex17.o  chkopts
	-${CLINKER} -o $@ $@.o  ${PETSC_KSP_LIB}
	${RM} -f $@.o

#-------------------------------------------------------------------------------------------
#   This section is used for testing examples and can be ignored 
#-------------------------------------------------------------------------------------------
runex1:
	-@${MPIRUN} -np 1 ./ex1 > ex1_1.tmp 2>&1;   \
	   if (${DIFF} output/ex1_1.out ex1_1.tmp) then true; \
	   else echo "Possible problem with ex1_1, diffs above"; fi; \
	   ${RM} -f ex1_1.tmp
runex1_2:
	-@${MPIRUN}  -np 2 ./ex1 > ex1_2.tmp 2>&1;\
	   if (${DIFF} output/ex1_2.out ex1_2.tmp) then true ;  \
	   else echo "Possible problem with ex1_2, diffs above"; fi ;\
	   ${RM} -f ex1_2.tmp
runex1e:
	-@${MPIRUN} -np 1 ./ex1e > ex1_1.tmp 2>&1;   \
	   if (${DIFF} output/ex1_1.out ex1_1.tmp) then true; \
	   else echo "Possible problem with ex1e_1, diffs above"; fi; \
	   ${RM} -f ex1_1.tmp
runex1e_2:
	-@${MPIRUN}  -np 2 ./ex1e > ex1_2.tmp 2>&1;\
	   if (${DIFF} output/ex1_2.out ex1_2.tmp) then true ;  \
	   else echo "Possible problem with ex1e_2, diffs above"; fi ;\
	   ${RM} -f ex1_2.tmp
runex1f:
	-@${MPIRUN} -np 1  ./ex1f > ex1f_1.tmp 2>&1;   \
	   if (${DIFF} output/ex1f_1.out ex1f_1.tmp) then true; \
	   else echo "Possible problem with ex1f_1, diffs above"; fi; \
	   ${RM} -f ex1f_1.tmp
runex1f_2:
	-@${MPIRUN}  -np 2 ./ex1f > ex1f_2.tmp 2>&1;\
	   if (${DIFF} output/ex1f_2.out ex1f_2.tmp) then true ;  \
	   else echo "Possible problem with ex1f_2, diffs above"; fi ;\
	   ${RM} -f ex1f_2.tmp
runex1f90:
	-@${MPIRUN}  -np 2 ./ex1f90 > ex1f90_1.tmp 2>&1;\
	   if (${DIFF} output/ex1f90_1.out ex1f90_1.tmp) then true ;  \
	   else echo "Possible problem with ex1f90_1, diffs above"; fi ;\
	   ${RM} -f ex1f90_1.tmp
runex2:
	-@${MPIRUN} -np 2 ./ex2 > ex2_1.tmp 2>&1;\
	   if (${DIFF} output/ex2_1.out ex2_1.tmp) then true; \
	   else echo "Possible problem with ex2_1, diffs above"; fi;\
	   ${RM} -f ex2_1.tmp
runex2f:
	-@${MPIRUN}  -np 2 ./ex2f > ex2f_1.tmp 2>&1;\
	   if (${DIFF} output/ex2f_1.out ex2f_1.tmp) then true; \
	   else echo "Possible problem with ex2f_1, diffs above"; fi;\
	   ${RM} -f ex2f_1.tmp
runex3:
	-@${MPIRUN}  -np 2 ./ex3 > ex3_1.tmp 2>&1;\
	   if (${DIFF} output/ex3_1.out ex3_1.tmp) then true; \
	   else echo "Possible problem with ex3_1, diffs above"; fi;\
	   ${RM} -f ex3_1.tmp
runex3f:
	-@${MPIRUN}  -np 2 ./ex3f > ex3f_1.tmp 2>&1;\
	   if (${DIFF} output/ex3f_1.out ex3f_1.tmp) then true; \
	   else echo "Possible problem with ex3f_1, diffs above"; fi;\
	   ${RM} -f ex3f_1.tmp
runex4f:
	-@${MPIRUN} -np 1 ./ex4f > ex4f_1.tmp 2>&1;\
	   if (${DIFF} output/ex4f_1.out ex4f_1.tmp) then true; \
	   else echo "Possible problem with ex4f_1, diffs above"; fi;\
	   ${RM} -f ex4f_1.tmp
runex4f90:
	-@${MPIRUN} -np 1 ./ex4f90 > ex4f90_1.tmp 2>&1;\
	   if (${DIFF} output/ex4f90_1.out ex4f90_1.tmp) then true; \
	   else echo "Possible problem with ex4f90_1, diffs above"; fi;\
	   ${RM} -f ex4f90_1.tmp
runex5:
	-@${RM} -f vector.dat.info vector.dat
	-@${MPIRUN} -np 1 ./ex5 > ex5_1.tmp 2>&1;\
	   if (${DIFF} output/ex5_1.out ex5_1.tmp) then true; \
	   else echo "Possible problem with ex5_1, diffs above"; fi
	-@${RM} -f ex5_1.tmp vector.dat vector.dat.info
runex5_2:
	-@${RM} -f vector.dat.info vector.dat
	-@${MPIRUN} -np 2 ./ex5 > ex5_2.tmp 2>&1;\
	   if (${DIFF} output/ex5_2.out ex5_2.tmp) then true; \
	   else echo "Possible problem with ex5_2, diffs above"; fi
	-@${RM} -f ex5_2.tmp vector.dat vector.dat.info
runex6:
	-@${RM} -f input.dat input.dat.info
	-@${MPIRUN} -np 1 ./ex6 > ex6_1.tmp 2>&1;\
	   if (${DIFF} output/ex6_1.out ex6_1.tmp) then true; \
	   else echo "Possible problem with ex6_1, diffs above"; fi
	-@${RM} -f ex6_1.tmp input.dat input.dat.info
runex7:
	-@${RM} -f input.dat input.dat.info
	-@${MPIRUN} -np 3 ./ex7 | sort > ex7_1.tmp 2>&1;\
	   if (${DIFF} output/ex7_1.out ex7_1.tmp) then true; \
	   else echo "Possible problem with ex7_1, diffs above"; fi
	-@${RM} -f ex7_1.tmp input.dat input.dat.info
runex8:
	-@${MPIRUN} -np 4 ./ex8 > ex8_1.tmp 2>&1;\
	   if (${DIFF} output/ex8_1.out ex8_1.tmp) then true; \
	   else echo "Possible problem with ex8_1, diffs above"; fi;\
	   ${RM} -f ex8_1.tmp
runex9:
	-@${MPIRUN} -np 2 ./ex9 > ex9_1.tmp 2>&1;\
	   if (${DIFF} output/ex9_1.out ex9_1.tmp) then true; \
	   else echo "Possible problem with ex9_1, diffs above"; fi;\
	   ${RM} -f ex9_1.tmp
runex9_2:
	-@${MPIRUN} -np 2 ./ex9 -allocate > ex9_2.tmp 2>&1;\
	   if (${DIFF} output/ex9_1.out ex9_2.tmp) then true; \
	   else echo "Possible problem with ex9_2, diffs above"; fi;\
	   ${RM} -f ex9_2.tmp
runex9f:
	-@${MPIRUN} -np 2 ./ex9f | sort > ex9f_1.tmp 2>&1;\
	   if (${DIFF} output/ex9f_1.out ex9f_1.tmp) then true; \
	   else echo "Possible problem with ex9f_1, diffs above"; fi;\
	   ${RM} -f ex9f_1.tmp
runex9f_2:
	-@${MPIRUN} -np 2 ./ex9f -allocate | sort > ex9f_1.tmp 2>&1;\
	   if (${DIFF} output/ex9f_1.out ex9f_1.tmp) then true; \
	   else echo "Possible problem with ex9f_2, diffs above"; fi;\
	   ${RM} -f ex9f_1.tmp
runex11:
	-@${MPIRUN}  -np 2 ./ex11 > ex11_1.tmp 2>&1;\
	   if (${DIFF} output/ex11_1.out ex11_1.tmp) then true ;  \
	   else echo "Possible problem with ex11_1, diffs above"; fi ;\
	   ${RM} -f ex11_1.tmp
runex11f:
	-@${MPIRUN}  -np 2 ./ex11f > ex11f_1.tmp 2>&1;\
	   if (${DIFF} output/ex11f_1.out ex11f_1.tmp) then true ;  \
	   else echo "Possible problem with ex11f_1, diffs above"; fi ;\
	   ${RM} -f ex11f_1.tmp
runex12:
	-@${MPIRUN}  -np 2 ./ex12 > ex12_1.tmp 2>&1;\
	   if (${DIFF} output/ex12_1.out ex12_1.tmp) then true ;  \
	   else echo "Possible problem with ex12_1, diffs above"; fi ;\
	   ${RM} -f ex12_1.tmp

runex17:
	-@${MPIRUN} -np 1 ./ex17 > ex17_1.tmp 2>&1;\
	   if (${DIFF} output/ex17_1.out ex17_1.tmp) then true; \
	   else echo "Possible problem with ex17_1, diffs above"; fi;\
	   ${RM} -f ex17_1.tmp

TESTEXAMPLES_C		    = ex1.PETSc runex1 runex1_2 ex1.rm ex1e.PETSc runex1e runex1e_2 ex1e.rm \
                              ex2.PETSc runex2 ex2.rm ex5.PETSc runex5 runex5_2 ex5.rm ex6.PETSc \
                              runex6 ex6.rm ex8.PETSc runex8 ex8.rm ex11.PETSc runex11 ex11.rm \
                              ex12.PETSc runex12 ex12.rm ex9.PETSc runex9 runex9_2 ex9.rm ex16.PETSc \
                              ex16.rm ex17.PETSc runex17 ex17.rm
TESTEXAMPLES_C_X11	    = ex3.PETSc runex3 ex3.rm
TESTEXAMPLES_FORTRAN	    = ex1f.PETSc runex1f runex1f_2 ex1f.rm ex2f.PETSc runex2f ex2f.rm ex4f.PETSc \
                              runex4f ex4f.rm ex3f.PETSc ex3f.rm ex7.PETSc runex7 ex7.rm ex9f.PETSc runex9f \
                              runex9f_2 ex9f.rm ex11f.PETSc runex11f ex11f.rm ex14f.PETSc ex14f.rm
TESTEXAMPLES_C_X11_MPIUNI   = ex1.PETSc runex1 ex1.rm ex5.PETSc runex5 ex5.rm
TESTEXAMPLES_FORTRAN_MPIUNI = ex1f.PETSc runex1f ex1f.rm ex4f.PETSc runex4f ex4f.rm ex7.PETSc ex7.rm
TESTEXAMPLES_F90	    = ex1f90.PETSc runex1f90 ex1f90.rm ex4f90.PETSc runex4f90 ex4f90.rm
TESTEXAMPLES_13		    = ex10.PETSc ex10.rm

include ${PETSC_DIR}/bmake/common/test