[MPI3 Fortran] Serious problem/bug in MPI libraries with the alignment of MPI_DOUBLE_PRECISION

N.M. Maclaren nmm1 at cam.ac.uk
Wed Sep 28 12:50:45 CDT 2011


On Sep 28 2011, Rolf Rabenseifner wrote:

>> A very good question. Instead of referring to SEQUENCE, it should say
>> that MPI_DOUBLE_PRECISION would use the numeric storage sequence rules
>> (16.4.3.1 in Fortran 2003) for alignment.
>
>please can you explain, what "16.4.3.1 in Fortran 2003" tells
>about alignments. 
>In SEQUENCE derived types and COMMON blocks,
>when I understand this correctly, then DOUBLE PRECISION
>must have also one numerical storage unit as alignment,
>i.e., with REAL=4 bytes, DOUBLE PRECISION alignment must be
>also 4 byte, i.e., exactly what the Intel compiler is doing
>in a SEQUENCE derived type or COMMON block.

That is my understanding, too, and I am pretty sure that I am correct.

>The implication is that the compiler issues nice "warnings" about
>misaligned data.

Yes.

>Do I understand correctly, that the other compilers with 
>REAL-size=4 byte and DOUBLE PRECISION size and alignment = 8 byte,
>do it wrong, i.e.not according to Fortran 2003 or 2008?

Not quite.  If they align DOUBLE PRECISION at 8 bytes in SEQUENCE
derived types or COMMON blocks, then my understanding is that they
are incorrect.  But they may do so anywhere else, such as in all
other derived types, and it is permitted for DOUBLE PRECISION and
REAL(KIND=C_DOUBLE) to be identical except for different alignments
(indeed, that is very likely).

My understanding is that, if DOUBLE PRECISION and REAL(KIND=C_DOUBLE)
have different alignments, then KIND(0.0D0) must not equal C_DOUBLE.

Even if they align at 8 bytes in other contexts, EQUIVALENCE can
be used to generate 4-byte aligned DOUBLE PRECISION from an 8-byte
aligned object, which is required to work.  But EQUIVALENCE is
horrible and strongly disapproved of.

Are there any compilers that break those rules?

Regards,
Nick Maclaren.




More information about the mpiwg-fortran mailing list