[MPI3 Fortran] MPI Data types

N.M. Maclaren nmm1 at cam.ac.uk
Thu May 7 11:54:34 CDT 2009


On May 7 2009, Jeff Squyres wrote:
>
>I don't understand the implications of what you are saying.  Be gentle  
>with me; I'm *NOT* a Fortran expert (or anywhere close).

Sorry.

C's array model is confused, but the issue is its semantic aspect.  A C
array is simply a pointer to the first element of a contiguous sequence
of an unspecified number of elements.  Nothing more.  A void * pointer
is the first byte of an unspecified length of storage of unspecified
type.  It is assumed that it is of appropriate alignment and size for how
it is used, but that information is not associated with an array argument.

A Fortran array is strongly typed (the first difference), and it comes in
many forms.  Most of them are contiguous, but the most important Fortran 90
one (plain assumed size) is not.  All but assumed shape (a Fortran 77
feature) have a strongly associated size.  It is the user's responsibility
to never pass a smaller array to a largerr argument.

Pretty well all combinations are allowed in argument passing, and the
compiler is expected to use copy-in/copy-out when needed.  In particular,
it is needed (in general) when passing an assumed-shape array to an assumed
size argument (which is the form that matches C's model).  That can be
locked out, but that means that callers cannot use assumed shape arrays,
which (as I said) are the main Fortran 90 mechanism.

>> I thought that we were discussing features to enable MPI-3 to  
>> support things
>> like Fortran array arguments that have no equivalent in C (principally
>> assumed shape).
>
>I don't understand.  What does it matter if there is no equivalent  
>data type in C?

Not data type - semantic model.

>MPI is about message passing -- as long as we can get a memory layout  
>description of the data to send / receive, then it doesn't matter what  
>language the data will be accessed from.

Yes, but ....

The data layout is part of the MPI datatype, so there is a problem when
passing a Fortran 90 assumed shape REAL array (for example).  If the MPI
datatype is REAL, the MPI send / receive needs to handle discontiguous
data (which it doesn't).  If the MPI datatype is an MPI derived type, there
is no direct equivalence between the Fortran and C interfaces.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679






More information about the mpiwg-fortran mailing list