Question: After I issue a mpirun command, I want to get the pid of this process, so that I can kill this process later. How to do this without having to add '&' at the end of the mpirun command to send it to background?

Other condition is that there could be more than one mpirun processes running on the machine.

Answer: 
With Open MPI one could instruct `mpirun` to output its own PID by giving it the `--report-pid` option:

* `--report-pid -` outputs the PID to the standard output;
* `--report-pid +` outputs the PID to the standard error;
* `--report-pid /path/to/filename` writes the PID into `filename`.

To get the PIDs of all your running `mpirun`s, use:

```
$ pgrep -u `whoami` mpirun

```
You can use 'ps' to get pid

```
ps -A | grep process-name

```