I'm encountering a compile-time warning when passing arrays to MPI calls by referencing their first value. Consider the following example code, which is the leanest I could get:
module mymod
implicit none
contains
subroutine test_sequence(input,output,icomw,N)
use MPI
integer, intent(in), contiguous :: input(:)
integer, intent(in) :: icomw, N
integer, intent(out) :: output(:)
integer :: ier
write(*,*) 'in sub: ', is_contiguous(input), is_contiguous(output)
call MPI_REDUCE(input(1),output(1),N,MPI_INTEGER,MPI_MAX,0,icomw,ier)
! -- This is the line referenced in the error
end subroutine test_sequence
end module mymod
program main
use MPI
use mymod
implicit none
integer :: icomw, id, nproc, ier, N, i
integer, allocatable :: input(:), output(:)
real :: harvest
call MPI_INIT(ier)
icomw = MPI_COMM_WORLD
N = 10
allocate(input(N), output(N))
input = 1
write(*,*) 'in main: ', is_contiguous(input), is_contiguous(output)
call test_sequence(input,output,icomw,N)
call MPI_FINALIZE(ier)
end program main
Notice that I'm passing MPI_REDUCE only the first element of input and output but using a count of N, which is (in this case) the complete size of the array. It's worth noting that referencing array sections like this probably isn't best practice but I'm doing it anyway.
I get the following compiler warning and runtime output:
km-gs3% mpifort test_sequence.f90
PGF90-W-0312-Array input should be declared SEQUENCE (test_sequence.f90: 14)
PGF90-W-0312-Array output should be declared SEQUENCE (test_sequence.f90: 14)
0 inform, 2 warnings, 0 severes, 0 fatal for test_sequence
km-gs3% mpirun -np 2 ./a.out
in main: T T
in sub: F F
in main: T T
in sub: F F
I get the warning with PGI 14.3/OpenMPI 1.8.0 or PGI 15.5/OpenMPI 1.8.6. I do not get the warning with PGI 12.9/OpenMPI 1.6.2, PGI 14.3/OpenMPI 1.6.5, or Intel 14.0/OpenMPI 1.8.0.
It's my understanding that sequence is a keyword affecting derived data types only, and input and output here are plain integers. Also, these are 1D arrays - don't they have to be contiguous anyway?
My question is: what's going on here? Can (and should) I declare integers as sequence?
Edit 1 Following the advice of francescalus, I've attempted to define the the dummy array as contiguous. I've added contiguous to the input argument and inquired about the contiguity (is that a word?) of input and output using is_contiguous in main and sub. Rather than re-post the entire code, I've edited the original code shown above. Unfortunately, I still get the same compiler warning. Furthermore, the contiguous attribute doesn't seem to be doing anything because is_contiguous reports false in the subroutine for both input and output.
Am I using the contiguous attribute correctly? It seems reasonable to require input and output to be contiguous, but not sequence. Perhaps I should report this to PGI directly, especially now that I've encountered the problem on a reasonably new version of pgfortran.
I've now got some closure on this issue and wanted to share. This answer will hopefully provide some clarity for future readers. Thanks francescalus and Vladimir F for your help; I also received help on the Portland Group Forums.
There are two separate bugs in
pgfortranat play here. The first is a bug in theis_contiguousintrinsic. The second is an erroneous use of a legacy warning. Both issues have been reported and will (hopefully) be fixed in a new compiler release.Issue with
is_contiguousis_contiguousisn't performing as expected. The bug has been reported with tagTPR#21939. Consider the following example code:which gives the following output:
Both
inputandoutputare contiguous, and I'm even assigningia1thecontiguousattribute. Yetis_contiguousreports them to be not contiguous inmysub.Warning to Declare as
sequenceThis is the original issue that led to this question - a compile-time warning to declare an array as
sequence. This issue has been reported with tagTPR#21947. Consider the following example code:As mentioned in the question, I'm passing the entire
inputandoutputarray toMPI_REDUCEby referencing the first element in each array and assigning a size ofN. This is not good practice, but I was doing it anyway. I get the following compile-time warning:which is incorrect because arrays (like
input) may not be defined assequence.