export OMPI_MCA_plm_rsh_agent=/bin/false
export OMPI_MCA_rmaps_base_oversubscribe=1

# testing on 5 processes is recommended by mpi4py upstream where possible
# and is safe to oversubscribe with OpenMPI
# (but oversubscribing might be a problem  - runs slow - with mpich)
# But the kspsolve demo requires a power of 2, so use 4 processes not 5.
N_MPI=4

PETSC_DIR=/usr/lib/petsc
echo "Running petsc4py demos using PETSC_DIR=${PETSC_DIR}"

# test demos as installed
cp -r /usr/share/doc/python-petsc4py-doc/examples/demo test-demos
gunzip -r test-demos

echo "Run demos (single processor) with python3"
make PETSC_DIR=${PETSC_DIR} PYTHON=python3 F2PY=f2py3 -C test-demos all

echo "Run demos (MPI) with python3"
make PETSC_DIR=${PETSC_DIR} PYTHON=python3 F2PY=f2py3 MPIEXEC="mpiexec -n ${N_MPI}" -C test-demos all-mpi
