PROGRAM MPIPRG INCLUDE 'mpif.h' PARAMETER ( N = 1024*1024 ) INTEGER MYRANK, NPROCS, IERR, SRC, DEST, TAG, REQUEST(2) INTEGER STATUS(MPI_STATUS_SIZE,2) DOUBLE PRECISION A(N), B(N), SUM * CALL MPI_INIT(IERR) CALL MPI_COMM_RANK( MPI_COMM_WORLD, MYRANK, IERR) CALL MPI_COMM_SIZE( MPI_COMM_WORLD, NPROCS, IERR) * DO I = 1, N A(I) = DBLE(MYRANK) ENDDO * SRC = MYRANK-1 IF ( SRC .LT. 0 ) SRC = NPROCS - 1 DEST = MYRANK + 1 IF ( DEST .GE. NPROCS ) DEST = 0 * TAG = 111 CALL MPI_ISEND( A, N, MPI_DOUBLE_PRECISION, DEST, TAG, + MPI_COMM_WORLD, REQUEST(1), IERR ) CALL MPI_IRECV( B, N, MPI_DOUBLE_PRECISION, SRC, TAG, + MPI_COMM_WORLD, REQUEST(2), IERR ) * ! CALL MPI_WAITALL( 2, REQUEST, STATUS, IERR ) CALL MPI_WAIT( REQUEST(2), STATUS(1,2), IERR ) * SUM = 0.D0 DO I = 1, N SUM = SUM + B(I) ENDDO * PRINT 1000, MYRANK, SUM/N 1000 FORMAT(' Process ', I3, ': value = ', 1PG12.5) * CALL MPI_WAIT( REQUEST(1), STATUS(1,1), IERR ) * CALL MPI_FINALIZE(IERR) STOP END