[MPIWG Fortran] [Mpi-comments] MPI_Comm_spawn_multiple: parameter description and Fortran bindings

Bill Long longb at cray.com
Fri Feb 9 09:32:31 CST 2018


My reading of example 10.2 (in the 3.0 standard) is that the command array has 2 elements, (same as the value of count),  but that an extra blank element is used to signal the end of the argument lists for each command in the array array_of_argv.  That seems reasonable since the number of arguments would, in general,  be different for each command.

Here is how you do it in Fortran:

CHARACTER*25 commands(2), array_of_argv(2, 3)
commands(1) = ’ ocean ’
array_of_argv(1, 1) = ’ -gridfile ’
array_of_argv(1, 2) = ’ ocean1.grd’
array_of_argv(1, 3) = ’ ’

commands(2) = ’ atmos ’
array_of_argv(2, 1) = ’ atmos.grd ’
array_of_argv(2, 2) = ’ ’

call MPI_COMM_SPAWN_MULTIPLE(2, commands, array_of_argv, ...)


Self-documentation of the declaration would be clearer if the command argument were declared command(count) instead of command(*).  I suspect that the (*) declaration of the command dummy argument was done that way out of habit.  

Cheers,
Bill



> On Feb 9, 2018, at 12:26 AM, Gilles Gouaillardet <gilles.gouaillardet at gmail.com> wrote:
> 
> Bill,
> 
>>>> That being said, the standard does not state that, and it is unclear whether 'array_of_commands' should be
>>>> 
>>>> NULL-terminated (so to speak) or not.
>>>> 
>> 
>> Fortran characters are NOT null terminated.
> 
> 
> I was referring the array and not the characters, so let me clarify this :
> 
> 
> In example 10.2, the array of commands is
> 
> CHARACTER*25 commands(2),
> commands(1) = ' ocean '
> commands(2) = ' atmos '
> 
> By reading the standard literally, it was unclear to me whether this
> should have been
> 
> CHARACTER*25 commands(3),
> commands(1) = ' ocean '
> commands(2) = ' atmos '
> commands(3) = ' '
> 
> 
> FWIW, Open MPI currently expects the latter form (see
> https://github.com/open-mpi/ompi/issues/4788)
> I initially thought it was a simple bug, but on second thought, I am
> still on the fence whether this should be
> regarded as  a simple bug or a correct/literal interpretation of the standard.
> 
> 
> Cheers,
> 
> Gilles
> 
> On Fri, Feb 9, 2018 at 7:07 AM, Bill Long <longb at cray.com> wrote:
>> 
>>> On Feb 8, 2018, at 3:44 PM, Jeff Squyres (jsquyres) <jsquyres at cisco.com> wrote:
>>> 
>>>> 
>>>> And the Fortran binding is
>>>> 
>>>> MPI_COMM_SPAWN_MULTIPLE(COUNT, ARRAY_OF_COMMANDS, ...)
>>>> INTEGER  COUNT
>>>> CHARACTER*(*) ARRAY_OF_COMMANDS(*)
>>>> 
>> 
>> Note that the character*(*) syntax is archaic (as of 25+ years ago).  The normal way of writing this is character(*).
>> 
>>>> 
>>>> Intuitively, it seems obvious that 'array_of_commands' is an array of 'count' commands.
>> 
>> That is what I would assume.  The user would be responsible for declaring the array elements large enough to hold the longest command.  (All the elements of the array have the same length).
>> 
>>>> 
>>>> That being said, the standard does not state that, and it is unclear whether 'array_of_commands' should be
>>>> 
>>>> NULL-terminated (so to speak) or not.
>>>> 
>> 
>> Fortran characters are NOT null terminated.
>> 
>>>> 
>>>> Back to the Fortran binding, the following prototype, which is somehow consistent with 'array_of_argv',
>>>> 
>>>> could (help to) clear the confusion. The same comments also apply to the Fortran 2008 binding.
>>>> 
>>>> 
>>>> CHARACTER*(*) ARRAY_OF_COMMANDS(COUNT)
>> 
>> This is also fine, and clearer in terms of the expected minimum size of ARRAY_OF_COMMANDS.
>> 
>> Cheers,
>> Bill
>> 
>> 
>>>> 
>>>> 
>> 
>> Bill Long                                                                       longb at cray.com
>> Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
>> Bioinformatics Software Development                      fax:  651-605-9143
>> Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425
>> 
>> 
> _______________________________________________
> mpiwg-fortran mailing list
> mpiwg-fortran at lists.mpi-forum.org
> https://lists.mpi-forum.org/mailman/listinfo/mpiwg-fortran

Bill Long                                                                       longb at cray.com
Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
Bioinformatics Software Development                      fax:  651-605-9143
Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425




More information about the mpiwg-fortran mailing list