program main implicit none include 'mpif.h' integer a(0:1) integer position, i, j, a(0:1), rank, numtasks; character buff(0:1000); integer stat(MPI_STATUS_SIZE) call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr) if (rank == 0) then !/* SENDER CODE */ position = 0; i=1;j=2; CALL MPI_Pack(i, 1, MPI_INTEGER, buff, 1000, position, MPI_COMM_WORLD, ierr); CALL MPI_Pack(j, 1, MPI_INTEGER, buff, 1000, position, MPI_COMM_WORLD, ierr); CALL MPI_Send( buff, position, MPI_PACKED, 1, 0, MPI_COMM_WORLD, ierr); else !/* RECEIVER CODE */ CALL MPI_Recv( a, 2, MPI_INTEGER, 0, 0, MPI_COMM_WORLD, ierr); position = 0; CALL MPI_Unpack(a, 2, position, i, 1, MPI_INTEGER, MPI_COMM_WORLD, ierr); CALL MPI_Unpack(a, 2, position, j, 1, MPI_INTEGER, MPI_COMM_WORLD, ierr); Write(*,*) 'i , j = ' , i,j END IF call MPI_FINALIZE(ierr) end program main