Execution tracing is easily accomplished using the -mpitrace command line argument while linking:
mpicc -c cpi.c mpicc -o cpi -mpitrace cpi.o