[MPI3 Fortran] MPI_SIZEOF question
Bill Long
longb at cray.com
Mon May 23 09:47:26 CDT 2011
The difficulty in writing things like this in Fortran is why the
standard provides intrinsics. In this case, see STORAGE_SIZE, which
returns the size of an array element of the type of the argument in
bits. Dividing by 8 and multiplying by the array size (if the argument
is not a scalar) should be simple enough for the user.
On 5/23/11 8:30 AM, Jeff Squyres wrote:
> I'm re-working Open MPI's Fortran implementation with Craig.
>
> The MPI_SIZEOF function is supposed to return the size of any Fortran intrinsic data type. MPI-2.2 16.2.5 p494:31-44 says:
>
> -----
> The following functions allow a user to obtain a size-specific MPI datatype for any intrinsic Fortran type.
>
> MPI_SIZEOF(x, size)
> IN x a Fortran variable of numeric intrinsic type (choice)
> OUT size size of machine representation of that type (integer)
>
This one is very close to STORAGE_SIZE. Just divide by 8.
> MPI_SIZEOF(X, SIZE, IERROR)
> <type> X
> INTEGER SIZE, IERROR
>
This one would require also multiplying by the size of an array
argument. I assume the IERROR is there only to provide a distinction
for the generic interface. It is hard to imagine an actual run-time
error with a routine like this.
Ultimately, I'd be inclined to just scrap the routine as redundant.
Cheers,
Bill
> This function returns the size in bytes of the machine representation of the given variable. It is a generic Fortran routine and has a Fortran binding only.
> -----
>
> Is there any way of implementing that other than an interface with an overloaded subroutine for every single intrinsic type (including dimension)?
>
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
More information about the mpiwg-fortran
mailing list