command
name of program to be spawned (string, significant only at root)
argv
arguments to command (array of strings, significant only at root)
maxprocs
maximum number of processes to start (integer, significant only at root)
info
a set of key-value pairs telling the runtime system where and how to start the processes. This is not yet fully supported.
rank
rank of process in which previous arguments are examined
comm
intracommunicator containing group of spawning processes
The output from mpi_comm_spawn is an intercommunicator between original group and the mpi_comm_spawn returns an intercommunicator between original group and the newly spawned group.
There is an auxiliary routine, mpi_array_of_errcodes, that is not part of MPI.
mpi_array_of_errcodes()
Returns an array of error codes associated with launching the new tasks.
There are some constants that can be used with mpi_comm_spawn:
MPI_ARGV_NULL
Passing an argv of MPI_ARGV_NULL to MPI_COMM_SPAWN results in main receiving argc of 1 and an argv whose element 0 is (conventionally) the name of the program.
MPI_INFO_NULL
Used in place of the info key-value pairs.
MPI-2 defines a constant MPI_ROOT that can be used with MPI_Comm_spawn. I have found using MPI_ROOT can cause problems. In some instances MPI_Comm_spawn will return an error. Use MPI_ROOT with caution. This has been reported to the developers.
The Python version of mpi_comm_spawn will also take a zero length string in place of argv. This is equivalent to passing MPI_ARGV_NULL. Also, if you pass in a single string, this is equivalent to passing in an array of strings. The single string gets replicated and passed to each new process.