-2

My system is Ubuntu Bash shell on Windows.

I use gfortran GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609 and gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5). and OpenMPI to compile a file.

The flag is:

mpifort -ffree-form -g -fbacktrace -UREPSOILM -UNLDAS2 -c test-mpi.f90

PROGRAM test

USE MPI

IMPLICIT NONE
REAL, DIMENSION(2)  :: xcug2m
INTEGER             :: NODID,  NUMPROCS, IERROR, COMM, DISPLS
REAL, DIMENSION(1)  :: cug2m
INTEGER             :: NPROCS=2, root
INTEGER             :: SENDCOUNTS=1
INTEGER             :: i

CALL MPI_INIT(IERROR)
CALL MPI_COMM_RANK(COMM, NODID,    IERROR)
CALL MPI_COMM_SIZE(COMM, NUMPROCS, IERROR)

xcug2m = (/1,2/)

do i = 1,2
CALL MPI_SCATTERV(xcug2m(i), SENDCOUNTS, DISPLS, MPI_REAL,  &
                  cug2m,    SENDCOUNTS, MPI_REAL, root, COMM, IERROR)
end do



END PROGRAM test

The error is:

CALL MPI_SCATTERV(xc(:,i,j  ), SCOUNT, DISPLS, MPI_REAL, c(:,i  ),

       SCOUNT, MPI_REAL, 0, MPI_COMM_WORLD, IER)
                                               1                                                                                   

Error: There is no specific subroutine for the generic ‘mpi_scatterv’ at (1).

I have read MPI_scatterv 's manual but found nothing. The syntax is OK. I used to compile in server with ifort and OpenMPI. There is no error and runs good.

Could you help me to solve this problem? I searched for several days.

Qing Sun
  • 21
  • 1
  • 5
  • 1
    Welcome. Use tag [tag:fortran] for Fortran questions and tag [tag:mpi] for MPI questions. Tags are very important so that the rigjt experts see your question!. We have to see your code. Please read [mcve], [ask] and take the welcome [tour]. – Vladimir F Героям слава Nov 07 '17 at 22:59
  • 3
    See also https://stackoverflow.com/questions/8044568/how-to-debug-fortran-90-compile-error-there-is-no-specific-subroutine-for-the-g we have to see your code. Not just the `call scatterv()` but a complete compilable example, where we see all types of all variables and which we can compile and test the error. The datatypes of all variables are really necessary. – Vladimir F Героям слава Nov 07 '17 at 23:03
  • 1
    Almost certainly the syntax is not ok. The error means one or more of the arguments don't match any valid call to the MPI_SCATTERV. – Ross Nov 07 '17 at 23:08
  • 1
    this suggests a typo. the second argument should be `SCOUNTS` instead of `SCOUNT`. Fortran likely complains because a scalar is used when an array is expected. – Gilles Gouaillardet Nov 07 '17 at 23:10
  • And also suggests Implicit None is not in scope, which, if the case, means I have little sympathy – Ian Bush Nov 08 '17 at 08:07
  • 1
    At least something, but now the error message does not correspond to the code. – Vladimir F Героям слава Nov 09 '17 at 16:15
  • Thanks so much for all your reply. Have a good day! – Qing Sun Nov 09 '17 at 20:03

1 Answers1

0

As already indicated by Gilles Gouaillardet in the comments, there are several arguments, which should be arrays, but you pass scalars there.

You claimed you checked the OpenMPI manual. When I open it I see

MPI_SCATTERV(SENDBUF, SENDCOUNTS, DISPLS, SENDTYPE, RECVBUF,
                 RECVCOUNT, RECVTYPE, ROOT, COMM, IERROR)
            <type>    SENDBUF(*), RECVBUF(*)
            INTEGER   SENDCOUNTS(*), DISPLS(*), SENDTYPE
            INTEGER   RECVCOUNT, RECVTYPE, ROOT, COMM, IERROR

As you can see SENDCOUNTS and DISPLS are arrays. They indicate

sendcounts
                 Integer array (of length group size) specifying the number of elements to send to each processor.

       displs    Integer array (of length group size). Entry i specifies the displacement (relative to sendbuf) from which to take the outgoing data to process i.

They must be arrays, otherwise the program is incorrect.

The program crashes on my computer. I will not search why, it is not worth it. It may be because the value of root is undefined. The above-mentioned errors must be fixed.

  • Thanks so much! Now I use mpich, then compile succeed. There maybe some compiler use different type of argument. – Qing Sun Nov 09 '17 at 20:03
  • 1
    I repeat again: Your code is **wrong**. Even if it compiles, it is wrong. A lot of wrong code does compile. – Vladimir F Героям слава Nov 09 '17 at 21:36
  • also, you cannot `MPI_Scatterv()` in a do loop like this. the send buffer should have 2 elements, and there will be a buffer overflow when the send buffer is `xcug2m(i)`. As pointed by @Vladimir F, your code is still wrong (at least 4 errors), and it is surprising mpich is using a loose compiler (option ?) that is fooling you. – Gilles Gouaillardet Nov 10 '17 at 02:27