When writing MPI 3.0 code, should I pass
argv to the
MPI_Init call or not, and why?
EDIT: Since Bill Barth's answer raised some questions I want to make some remarks:
argvis not required since MPI 1.1.
- The question is specifically about why should/shouldn't one pass
argv(why shouldn't you is then not really an answer).
- Still, sometimes you cannot pass
MPI_Init(writing a library that uses static initialization to start MPI if main is outside your control and MPI is an implementation detail).
EDIT2: The question why wouldn't you use
MPI_Init(argc, argv) has come too often now. Some reasons:
Doing it for the sake of compatibility with older/non-compliant/compliant MPI < 1.1 implementations is not possible since if you are using MPI2 or MPI3 features those won't work anyways.
MPI_Init()initializes the MPI runtime in the same way as
MPI_Init(argc, argv)removes arguments passed to the MPI run-time from
argvand initializes MPI. AFAIK it is the only way to clean
argvso if you need these to have no MPI arguments you need to use it.
MPI_Init()can be used in more situations that
MPI_Init(argc, argv). For example your library using MPI as an implementation detail can test if MPI is initialized, and if not, call
MPI_Init()and the right thing will happen. Your user doesn't know that you are using mpi, doesn't need to pass
argvto your library, doesn't need to change their main (in case it is taking no arguments) to use your library....