#include "mpi.h"

// For debugging
#ifdef DEBUG
#include "mon_mpi.h"
#endif

#include <stdio.h>

#define DATA_TAG 12

int main(int narg, char *argv[]){
	int		rank, size;
	MPI_Status	status;

	int d = 1;
	
	MPI_Init(&narg, &argv);
	MPI_Comm_size(MPI_COMM_WORLD, &size);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);

	if( rank ){
	    MPI_Recv(&d, 1, MPI_INT, rank-1, DATA_TAG, MPI_COMM_WORLD, &status);
	}
	if( rank != size-1){
	    MPI_Send(&d, 1, MPI_INT, rank+1, DATA_TAG, MPI_COMM_WORLD);
	}
	MPI_Finalize();
}// main
