Why does the following code, compiled with mpicc
and executed with mpiexec -n 4 prg
prints prg and not mpiexec. How can I make my program print mpiexec ?
#include <stdio.h>
#include <mpi.h>
int main(int argc, char *argv[])
{
printf("Command executed : %s\n",argv[0]);
MPI_Init(NULL, NULL);
/* some code */
MPI_Finalize();
}
It is impossible to tell how your binary was called (in a general, portable way). MPI offers no way to determine that. Even mpiexec
itself is only loosely specified.
It's generally impossible even without MPI and multiple systems being involved. prg
could have been called in any number of ways such as:
/bin/env prg
bash -c 'prg'
./my_prg_wrapper.sh
x='() { :;}; prg'