Re: [MPI3 Fortran] (j3.2006) (SC22WG5.3823) Please tell me I'm wrong
Jim, Thanks for your response. The question was not really how to get around the problem but to ask why the problem exists in the first place. MPI users have been using generic MPI interfaces for years (using F77 style implicit interfaces) so they won't be happy if they have to change their codes in this way. I think I have figured out the reasoning. I can argument associate a 2D array with a 1D dummy specified as real :: dimension(*) :: dummy_array However, generic resolution can't be used to resolve a procedure calling with a 2D actual to a 1D dummy. Is this reasoning correct? Thanks, Craig
Craig
If your message is a contiguous assumed-shape, then you can solve the problem without Fortran committee's help by using a conversion function as follows
function convertToRank1 (x, n) result (res) real, target, intent(inout) :: x(n) integer, intent(in) :: n
real, pointer :: res(:)
res => x end function
The your subroutine can be rewritten as follows
subroutine test_recv (message) real, target :: message(:,:) !<-- assume it is contiguous
real, pointer :: remappedArray(:)
remappedArray => convertToRank1(message, size(message))
call MP_Recv (remappedArray, 2, MPI_INTEGER, 1, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE)
end subroutine
That only solves the problem if the assumed-shape is contiguous. In F03 we have bounds-remapping for pointers that converts (maps) rank one target to multi-dimension arrays. I think that can be used if your test_recv() always expects a rank-one array assumed-shape dummy. You can map that array into a rank-n array using data pointer assignment to match the interface of MPI_Recv_wrapper, then you don't have the problems with generic resolution issues.
Cheers,
Jim Xia
RL Fortran Compiler Test IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7 Phone (905) 413-3444 Tie-line 313-3444 email: [email protected] D2/YF7/8200 /MKM
From: Craig Rasmussen <[email protected]> To: MPI-3 Fortran working group <[email protected]> Cc: WG5 <[email protected]> Date: 12/17/2008 10:45 AM Subject: (j3.2006) (SC22WG5.3823) Please tell me I'm wrong
Without help from the Fortran standard, I don't think there is anyway to avoid a combinatorial explosion of interfaces (made worse by the F2008 with 15 dimensions). Consider the simple example code snippet:
---------
subroutine test_recv(message) real :: message(:,:)
call MPI_Recv(message, 2, MPI_INTEGER, 1, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE)
end subroutine
---------
For interface declaration:
subroutine MPI_Recv_wrapper(buf, count, datatype, source, tag, comm, status, err) real, dimension(*), intent(out) :: buf
or:
subroutine MPI_Recv_wrapper(buf, count, datatype, source, tag, comm, status, err) real, dimension(1,1,1,1,1,1,*), intent(out) :: buf
This give the following error with the Intel compiler:
fortcom: Error: test_recv_call.f90, line 15: There is no matching specific subroutine for this generic subroutine call. [MPI_RECV] call MPI_Recv(message, 2, MPI_INTEGER, dest, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE) --------^
On the other hand, if we use the interface:
subroutine MPI_Recv_wrapper(buf, count, datatype, source, tag, comm, status, err) type(C_PTR) :: buf
There is still a problem as assumed shape arrays are not interoperable.
From gfortran:
call MPI_Recv(C_LOC(message), 2, MPI_INTEGER, dest, 1, MPI_COMM_WORLD, requ 1 Error: Assumed-shape array 'message' at (1) cannot be an argument to the procedure 'c_loc because it is not C interoperable
So there doesn't seem to be anyway to currently do multi-dimensional interfaces for assumed-shape actuals without a combinatorial explosion of interfaces. This also seems to be the case for assumed-size actuals as well.
Comments?
Cheers, Craig
_______________________________________________ J3 mailing list [email protected] http://j3-fortran.org/mailman/listinfo/j3
_______________________________________________ J3 mailing list [email protected] http://j3-fortran.org/mailman/listinfo/j3
participants (1)
-
Craig E. Rasmussen