C C The root node sends out a message process 1. Process 1 send back to Process 0. C program main include 'mpif.h' parameter (BUFSIZE = 64) integer my_rank, n_processes, tag integer ierr integer count, size integer status(MPI_STATUS_SIZE) double precision buf(BUFSIZE) size = BUFSIZE tag = 2001 call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, my_rank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, n_processes, ierr) if (my_rank .eq. 0) then C /* send to the next node */ print *, 'Hello world! I am ', my_rank, ' of ', n_processes, 1 ', sending to Proc ', my_rank+1 call MPI_SEND(buf, size, MPI_DOUBLE_PRECISION, my_rank+1, 1 tag, MPI_COMM_WORLD, ierr) C /* recieve from the last node */ call MPI_RECV(buf, size, MPI_DOUBLE_PRECISION, n_processes-1, 1 tag, MPI_COMM_WORLD, status, ierr) call MPI_GET_COUNT(status, MPI_DOUBLE_PRECISION, count, ierr) print *, 'Hello world! I am ', my_rank, ' of ', n_processes, 1 ', recv ', count,' entries from proc 0' else C /* recieve from the previous node */ call MPI_RECV(buf, size, MPI_DOUBLE_PRECISION, my_rank-1, tag, 1 MPI_COMM_WORLD, status, ierr) call MPI_GET_COUNT(status, MPI_DOUBLE_PRECISION, count, ierr) print *, 'Hello world! I am ', my_rank, ' of ', n_processes, 1 ', recv ', count,' entries from Proc 0' C /* send to the next node */ print *, 'Hello world! I am ', my_rank, ' of ', n_processes, ' sending to Proc 0' call MPI_SEND(buf, size, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD, ierr) endif call MPI_FINALIZE(ierr) end