include "mpiSim.f90" program main include "useSim.f90" ! Objective: ! An array is declared as q(*) in the subroutine. ! Check whether the type check and buffer check work fine ! in MPI-CHECK. integer, parameter :: n=10 real, allocatable:: A(:), C(:), B(:) ! include "mpif.h" integer p,rank,status(mpi_status_size) call mpi_init(ierror) call mpi_comm_size(mpi_comm_world, p, ierror) call mpi_comm_rank(mpi_comm_world, rank,ierror) write(*,*) "rank=",rank," p=",p allocate(A(n), B(n*p), C(n)) ! Initialize A and send A to all other processors ! from processor 0 do i=1,n A(i) =float(i) enddo if(rank==0) then call Mpi_send(A,n,MPI_REAL, p-1,1,MPI_COMM_WORLD,ierror) endif if(rank==p-1) then call myrecv(C, n) endif call mpi_finalize(ierror) end subroutine myrecv(myarray, n) include "useSim.f90" ! include "mpif.h" real myarray(n) integer n, status(1) call mpi_recv(myarray,n,MPI_REAL,MPI_ANY_SOURCE,1, & MPI_COMM_WORLD,status,ierror) write(*,*) "Check Test Worked; myarray = ", myarray(1) end subroutine myrecv