2

I have a Python script that can be executed from the shell either as:

mpirun run.py

or as:

python run.py

Is it possible, in run.py, to find out if the code was called with the mpirun or python command?

  • The script always ends up executed by `python` no matter how it's invoked from the command line. You could make `mpirun` an alias that adds an extra command line or sets an environment variable or something of the sort, however, specifically for this detection. – kindall Feb 05 '16 at 19:00
  • Thanks kindall for pointing me to that answer and for the explanation. Yes, looking at an evironmental variable, e.g., `os.environ.has_key("OMPI_COMM_WORLD_SIZE")` solves my problem. – Patricio Cubillos Feb 06 '16 at 10:21

0 Answers0