Skip to content

add fixed-size Fortran MPI_LOGICAL types #699

@jeffhammond

Description

@jeffhammond

Problem

MPI_LOGICAL is standardized, but the Fortran standard provides for multiple widths of logical and at least one implementation supports this already.

The following is a portable program, if these types are defined. Today, one must either rely on the equivalent of Fortran logical and integer, which is often true but not guaranteed, or copy logical data to a temporary array of the default logical kind.

program main
    use mpi
    implicit none
    integer :: ierr
    logical(1) :: a(2)
    logical(2) :: b(2)
    logical(4) :: c(2)
    logical(8) :: d(2)
    a = [ .true. , .false. ]
    b = [ .true. , .false. ]
    c = [ .true. , .false. ]
    d = [ .true. , .false. ]
    call mpi_init(ierr)
    call mpi_allreduce(a(1),a(2),1,MPI_LOGICAL1,MPI_LOR,MPI_COMM_WORLD,ierr)
    call mpi_allreduce(b(1),b(2),1,MPI_LOGICAL2,MPI_LOR,MPI_COMM_WORLD,ierr)
    call mpi_allreduce(c(1),c(2),1,MPI_LOGICAL4,MPI_LOR,MPI_COMM_WORLD,ierr)
    call mpi_allreduce(d(1),d(2),1,MPI_LOGICAL8,MPI_LOR,MPI_COMM_WORLD,ierr)
    print*,a,b,c,d
    call mpi_finalize(ierr)
end program main

Proposal

Add fixed-size MPI_LOGICAL datatypes to the table "Optional datatypes (Fortran)" and other places, as appropriate.

Changes to the Text

Trivial

Impact on Implementations

OMPI implements these already. Other implementations would need to do the trivial work to implement them. I suspect that the hard work is in the build system detection of Fortran compiler support, not the implementation code itself.

Impact on Users

This makes it possible to write straightforward, portable programs using Fortran logical kinds.

References and Pull Requests

Metadata

Metadata

Assignees

Labels

chap-datatypesDatatypes Chapter Committeempi-nextFor inclusion in the MPI 5.1 or 6.0 standardscheduled readingReading is scheduled for the next meeting

Type

No type

Projects

Status

Merged

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions