Skip to content

Commit

Permalink
fortran module: assumed size arg must match actual array arg of any rank
Browse files Browse the repository at this point in the history
Here's an example code that fails to compile prior to this checkin:
     use mpi
     integer, contiguous, pointer :: requests(:, :)
     integer :: ierr
     allocate(requests(2,2))
     requests(1,1) = 1
     requests(2,1) = 2
     requests(1,2) = 3
     requests(2,2) = 4
     call MPI_Waitall(size(requests),requests,MPI_STATUSES_IGNORE,ierr)
     end

But according to the standard under "A.4 Fortran Bindings with mpif.h or the mpi
Module", waitall is supposed to take
    INTEGER COUNT, ARRAY_OF_REQUESTS(*)
and under fortran that assumed size arg should match the above actual arg.

The fortran module previously had
    integer, dimension(count), intent(inout) :: array_of_requests
and this checkin changes it to
    integer, dimension(*), intent(inout) :: array_of_requests

According to Rafik Zurob the rules for assumed-size arrays are such that we know
the incoming array_of_requests is contiguous so nothing changes in the fundamental
operation of the waitall call.

Signed-off-by: Austen Lauria <[email protected]>

Co-authored-by: Jeff Squyres <[email protected]>
  • Loading branch information
2 people authored and awlauria committed Sep 22, 2021
1 parent 9989374 commit b8e2f23
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
38 changes: 19 additions & 19 deletions ompi/mpi/fortran/use-mpi-tkr/mpi-f90-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,9 +1336,9 @@ interface MPI_Testall
subroutine MPI_Testall(count, array_of_requests, flag, array_of_statuses, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE, count), intent(out) :: array_of_statuses
integer, dimension(MPI_STATUS_SIZE, *), intent(out) :: array_of_statuses
integer, intent(out) :: ierror
end subroutine MPI_Testall

Expand All @@ -1351,7 +1351,7 @@ subroutine MPI_Testany(count, array_of_requests, index, flag, status&
, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: index
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
Expand All @@ -1367,7 +1367,7 @@ subroutine MPI_Testsome(incount, array_of_requests, outcount, array_of_indices,
, ierror)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(MPI_STATUS_SIZE, *), intent(out) :: array_of_statuses
Expand Down Expand Up @@ -1830,7 +1830,7 @@ interface MPI_Waitall
subroutine MPI_Waitall(count, array_of_requests, array_of_statuses, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, dimension(MPI_STATUS_SIZE, *), intent(out) :: array_of_statuses
integer, intent(out) :: ierror
end subroutine MPI_Waitall
Expand All @@ -1843,7 +1843,7 @@ interface MPI_Waitany
subroutine MPI_Waitany(count, array_of_requests, index, status, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: index
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierror
Expand All @@ -1858,7 +1858,7 @@ subroutine MPI_Waitsome(incount, array_of_requests, outcount, array_of_indices,
, ierror)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(MPI_STATUS_SIZE, *), intent(out) :: array_of_statuses
Expand Down Expand Up @@ -2341,10 +2341,10 @@ subroutine MPI_Dist_graph_create(comm_old, n, sources, degrees, destinations, &
weights, info, reorder, comm_dist_graph, ierror)
integer, intent(in) :: comm_old
integer, intent(in) :: n
integer, dimension(n), intent(in) :: sources
integer, dimension(n), intent(in) :: degrees
integer, dimension(n), intent(in) :: destinations
integer, dimension(n), intent(in) :: weights
integer, dimension(*), intent(in) :: sources
integer, dimension(*), intent(in) :: degrees
integer, dimension(*), intent(in) :: destinations
integer, dimension(*), intent(in) :: weights
integer, intent(in) :: info
logical, intent(in) :: reorder
integer, intent(out) :: comm_dist_graph
Expand All @@ -2361,11 +2361,11 @@ subroutine MPI_Dist_graph_create_adjacent(comm_old, indegree, sources, sourcewei
comm_dist_graph, ierror)
integer, intent(in) :: comm_old
integer, intent(in) :: indegree
integer, dimension(indegree), intent(in) :: sources
integer, dimension(indegree), intent(in) :: sourceweights
integer, dimension(*), intent(in) :: sources
integer, dimension(*), intent(in) :: sourceweights
integer, intent(in) :: outdegree
integer, dimension(outdegree), intent(in) :: destinations
integer, dimension(outdegree), intent(in) :: destweights
integer, dimension(*), intent(in) :: destinations
integer, dimension(*), intent(in) :: destweights
integer, intent(in) :: info
logical, intent(in) :: reorder
integer, intent(out) :: comm_dist_graph
Expand Down Expand Up @@ -2394,11 +2394,11 @@ subroutine MPI_Dist_graph_neighbors(comm, maxindegree, sources, sourceweights, &
maxoutdegree, destinations, destweights, ierror)
integer, intent(in) :: comm
integer, intent(in) :: maxindegree
integer, dimension(maxindegree), intent(out) :: sources
integer, dimension(maxindegree), intent(out) :: sourceweights
integer, dimension(*), intent(out) :: sources
integer, dimension(*), intent(out) :: sourceweights
integer, intent(in) :: maxoutdegree
integer, dimension(maxoutdegree), intent(out) :: destinations
integer, dimension(maxoutdegree), intent(out) :: destweights
integer, dimension(*), intent(out) :: destinations
integer, dimension(*), intent(out) :: destweights
integer, intent(out) :: ierror
end subroutine MPI_Dist_graph_neighbors

Expand Down
4 changes: 2 additions & 2 deletions ompi/mpi/fortran/use-mpi-tkr/mpi_testall_f90.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
subroutine MPI_TestallS(count, array_of_requests, flag, array_of_statuses, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE, count), intent(out) :: array_of_statuses
integer, intent(out) :: ierror
Expand All @@ -33,7 +33,7 @@ end subroutine MPI_TestallS
subroutine MPI_TestallI(count, array_of_requests, flag, array_of_statuses, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
logical, intent(out) :: flag
double precision, intent(out) :: array_of_statuses
integer, intent(out) :: ierror
Expand Down
4 changes: 2 additions & 2 deletions ompi/mpi/fortran/use-mpi-tkr/mpi_testsome_f90.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ subroutine MPI_TestsomeS(incount, array_of_requests, outcount, array_of_indices,
, ierror)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(MPI_STATUS_SIZE, incount), intent(out) :: array_of_statuses
Expand All @@ -36,7 +36,7 @@ subroutine MPI_TestsomeI(incount, array_of_requests, outcount, array_of_indices,
, ierror)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
double precision, intent(out) :: array_of_statuses
Expand Down
4 changes: 2 additions & 2 deletions ompi/mpi/fortran/use-mpi-tkr/mpi_waitall_f90.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
subroutine MPI_WaitallS(count, array_of_requests, array_of_statuses, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, dimension(MPI_STATUS_SIZE, count), intent(out) :: array_of_statuses
integer, intent(out) :: ierror
call MPI_Waitall(count, array_of_requests, array_of_statuses, ierror)
Expand All @@ -31,7 +31,7 @@ end subroutine MPI_WaitallS
subroutine MPI_WaitallI(count, array_of_requests, array_of_statuses, ierror)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
double precision, intent(out) :: array_of_statuses
integer, intent(out) :: ierror
call MPI_Waitall(count, array_of_requests, array_of_statuses, ierror)
Expand Down
4 changes: 2 additions & 2 deletions ompi/mpi/fortran/use-mpi-tkr/mpi_waitsome_f90.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ subroutine MPI_WaitsomeS(incount, array_of_requests, outcount, array_of_indices,
, ierror)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(MPI_STATUS_SIZE, incount), intent(out) :: array_of_statuses
Expand All @@ -36,7 +36,7 @@ subroutine MPI_WaitsomeI(incount, array_of_requests, outcount, array_of_indices,
, ierror)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, dimension(*), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
double precision, intent(out) :: array_of_statuses
Expand Down

0 comments on commit b8e2f23

Please sign in to comment.