#ifndef _MPI_INCLUDE
#include <mpi.h>
#endif

typedef struct BExchange {
	int				overlap[2], send[2], recv[2], btype[2]; 
	int				sendproc[2], recvproc[2], sbind[2], rbind[2];
	MPI_Comm			comm;
   MPI_Request		sreq[2], rreq[2]; 
   MPI_Aint			fsize;
} BExchange;

typedef struct Transposition {
	MPI_Datatype *stype, *rtype;
	int *sbeg, *rbeg;
	MPI_Comm comm;
	int nproc, iproc;
	MPI_Request *sreq, *rreq;
	MPI_Aint fsize;
} Transposition;

int P_BExchange_init ( int, int*, int*, int, int*, MPI_Datatype, 
	MPI_Comm, int, BExchange* );
int P_BExchange_start ( void*, BExchange* );
int P_BExchange_end ( BExchange* );
int P_BExchange_free ( BExchange* );
int P_BExchange ( void*, int, int*, int*, int, int*, MPI_Datatype,
	MPI_Comm, int );

int P_Transpose_init ( int , int, int*, int, int*, int*, int*, int*, 
	MPI_Datatype, MPI_Comm, int, Transposition* );
int P_Transpose_start ( void*, void*, Transposition* );
int P_Transpose_end ( Transposition* );
int P_Transpose_free ( Transposition* );
int P_Transpose ( int, void*, int, int*, void*, int, int*, int*, int*, 
	int*, MPI_Datatype, MPI_Comm, int );