program gather include "mpif.h" integer rank, size, ierr, MAXPROCS parameter(MAXPROCS=20) character*30 message character*30 allmessages(MAXPROCS) integer root parameter(root = 0) call MPI_Init(ierr ) ! You should call MPI_Comm_size( MPI_COMM_WORLD, size, ierr ) ! always check call MPI_Comm_rank( MPI_COMM_WORLD, rank, ierr ) ! the ierr value!! if (size .gt. MAXPROCS) then print *, "Too many processes!" call MPI_Finalize() endif write(message, '("The message from proc ",i2.2)') rank call MPI_Gather(message, 30, MPI_CHARACTER, . allmessages, 30, MPI_CHARACTER, root, . MPI_COMM_WORLD, ierr) if (rank .eq. root) then do i = 0,size-1 print *, "Proc ",i, ": ", allmessages(i+1) enddo endif call MPI_Finalize(ierr) stop end