MPI_Init(); global nx ny nz nzb ZeRo mpitag comm = MPI_Comm_Load("NEWORLD"); nprocs = MPI_Comm_size(comm); me = MPI_Comm_rank(comm); src = me; src_up = me+1; src_dn = me-1; dst = me; dst_up = me+1; dst_dn = me-1; nx = 128; %# grid points ny = 128; nz = 128; nzb = nz/nprocs; ZeRo = zeros(nx,ny,nzb+2); mpitag = sort(primes(1000),'descend'); for i = 1:1e7 if me == 0 if i == 1 fw_mem = fopen('Memory_Usage.out','a'); end if mod(i,10)==0 system('free -m | grep "buffers/cache" | cut -c 36-40 >> Memory_Usage.out'); end utot = randn(nx,ny,nz); for i = 1:nprocs-1 u = utot(:,:,nzb*i+1:nzb*(i+1)); MPI_Send(u,i,i*mpitag(27),comm); end u = ZeRo; u(:,:,2:nzb+1) = utot(:,:,1:nzb); else u = ZeRo; [u(:,:,2:nzb+1)] = MPI_Recv(0,me*mpitag(27),comm); end end fclose all; MPI_Finalize; disp('SUCCESS');