Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] Problem with mpi_comm_spawn_multiple
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2010-05-25 16:43:23

Ah ha!

It turns out that the MPI spec specifically states that the user's code has to add a blank string at the end of the array to indicate the end. Specifically (as was just quoted to me), MPI-2.2, p310:18-25 defines:

"The argv argument argv is an array of strings containing arguments that are passed to
the program. The first element of argv is the first argument passed to command, not, as
is conventional in some contexts, the command itself. The argument list is terminated by
NULL in C and C++ and an empty string in Fortran. In Fortran, leading and trailing spaces
are always stripped, so that a string consisting of all spaces is considered an empty string.
The constant MPI_ARGV_NULL may be used in C, C++ and Fortran to indicate an empty
argument list. In C and C++, this constant is the same as NULL."

This definition is also valid for MPI_COMM_SPAWN_MULTIPLE.

OMPI does mistakenly assume that all your argv have the same number of tokens; I'll fix that.

On May 25, 2010, at 11:55 AM, Jeff Squyres (jsquyres) wrote:

> (somehow I apparently never sent this mail! It's been sitting in my drafts folder for weeks. To followup what I said below: I sent a question about this issue to the MPI-3 Fortran working group -- to see exactly what *should* be the right thing to do:
> On May 7, 2010, at 6:30 PM, Noam Bernstein wrote:
> > As with every array in Fortran, arrays of strings
> > are contiguous in memory, and presumably the end of string (1,1)
> > is right before the beginning of string(2,1), etc.
> Yep -- got all that -- we have some f2c string translation routines in OMPI for just this purpose.
> But MPI_COMM_SPAWN_MULTIPLE is a little unique in that it takes a 2D array of character strings. We know the first dimension; it has to be the same as the "count" argument to MPI_COMM_SPAWN_MULTIPLE. And by the hidden argument, we know the length of all of the strings. But we don't know the 2nd dimension of the array.
> So OMPI searches for it by looking for an empty string (i.e., all spaces). My gfortran 4.1 isn't doing that, although my ifort 11.1 and pgf90 10.0 are. In my small example that I sent, it *is* apparently doing that for Andrew's ifort 9.0, but it (apparently) isn't in his production tests. Sigh.
> --
> Jeff Squyres
> jsquyres_at_[hidden]
> For corporate legal information go to:
> _______________________________________________
> users mailing list
> users_at_[hidden]

Jeff Squyres
For corporate legal information go to: