[MPI3 Fortran] MPI_SIZEOF question
Rolf Rabenseifner
rabenseifner at hlrs.de
Mon May 23 12:44:07 CDT 2011
A) If we are doing BIND(C), I defined for MPI-3.0:
INTERFACE
SUBROUTINE MPI_Sizeof(x, size, ierror) BIND(C)
IMPLICIT NONE
TYPE(*) :: x
INTEGER, INTENT(OUT) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
END SUBROUTINE
END INTERFACE
This seems to be ***bad*** because TYPE(*) is not enough to
get the dope vector
TR 29113, 5.2.2, CFI_cdesc_t,
especially its structure element
size_t elem_len; If the object corresponds to a Fortran
CHARACTER object, the value equals the length of
the CHARACTER object times the sizeof() of a scalar
of the character type; otherwise, the value equals
the sizeof() of an element of the object.
We should do
TYPE(*), DIMENSION(..) :: x
which extends the current definition (in a backward compatible way).
Then size = elem_len of the dope vector.
Correct?
B) If an implementation choose Fortran binding:
B1) Does (without assumed-rank)
SUBROUTINE MPI_Sizeof(x, size, ierror)
IMPLICIT NONE
TYPE(*) :: x
INTEGER, INTENT(OUT) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
size = SIZEOF(x)
END SUBROUTINE
work?
B2) Does (with assumed-rank)
SUBROUTINE MPI_Sizeof(x, size, ierror)
IMPLICIT NONE
TYPE(*), DIMENSION(..) :: x
INTEGER, INTENT(OUT) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
size = SIZEOF(x)
END SUBROUTINE
work, or how can it be programmed?
Best regards
Rolf
----- Original Message -----
> From: "Bill Long" <longb at cray.com>
> To: mpi3-fortran at lists.mpi-forum.org
> Sent: Monday, May 23, 2011 4:47:26 PM
> Subject: Re: [MPI3 Fortran] MPI_SIZEOF question
>
> 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
>
>
> _______________________________________________
> mpi3-fortran mailing list
> mpi3-fortran at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
--
Dr. Rolf Rabenseifner . . . . . . . . . .. email rabenseifner at hlrs.de
High Performance Computing Center (HLRS) . phone ++49(0)711/685-65530
University of Stuttgart . . . . . . . . .. fax ++49(0)711 / 685-65832
Head of Dpmt Parallel Computing . . . www.hlrs.de/people/rabenseifner
Nobelstr. 19, D-70550 Stuttgart, Germany . (Office: Allmandring 30)
More information about the mpiwg-fortran
mailing list