[MPIWG Fortran] [Mpi-comments] MPI_Comm_spawn_multiple: parameter description and Fortran bindings
Gilles Gouaillardet
gilles.gouaillardet at gmail.com
Fri Feb 9 00:26:09 CST 2018
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
>
>
More information about the mpiwg-fortran
mailing list