1#include "RCCE.h" 2#include <stdlib.h> 3#include <stdio.h> 4#include "directions.h" 5#include "applu_share.h" 6#include "applu_macros.h" 7 8#define g(i,j) g[i+(isiz2+2)*(j)] 9#define h(i,j) h[i+(isiz2+2)*(j)] 10#define COMM_SIZE 1024 11 12extern int rcce_curphase; 13 14void exchange_4(double *g, double *h, 15 int ibeg, int ifin1, int jbeg, int jfin1) { 16 17 int i, j; 18 size_t chunk; 19 double bufin[COMM_SIZE], bufout[COMM_SIZE]; 20 int ny2 = ny + 2; 21 22//c--------------------------------------------------------------------- 23//c communicate in the east and west directions 24//c--------------------------------------------------------------------- 25 26 rcce_curphase = 1; 27 28//c--------------------------------------------------------------------- 29//c receive from east 30//c--------------------------------------------------------------------- 31 if (jfin1 == ny) { 32 RCCE_recv((char*)bufin, 2*nx*sizeof(double), east); 33 34 for (int ib=0, i=1; i<=nx; i++) { 35 g(i,ny+1) = bufin[ib++]; 36 h(i,ny+1) = bufin[ib++]; 37 } 38 39 } 40 41//c--------------------------------------------------------------------- 42//c send west 43//c--------------------------------------------------------------------- 44 if (jbeg == 1) { 45 for (int ib=0,i=1; i<=nx; i++) { 46 bufout[ib++] = g(i,1); 47 bufout[ib++] = h(i,1); 48 } 49 50 RCCE_send((char*)bufout, 2*nx*sizeof(double), west); 51 } 52 53//c--------------------------------------------------------------------- 54//c communicate in the south and north directions 55//c--------------------------------------------------------------------- 56 57 rcce_curphase = 0; 58 59//c--------------------------------------------------------------------- 60//c receive from south 61//c--------------------------------------------------------------------- 62 if (ifin1 == nx) { 63 RCCE_recv((char*)bufin, 2*ny2*sizeof(double), south); 64 65 for (int ib=0,j=0; j<=ny+1; j++) { 66 g(nx+1,j) = bufin[ib++]; 67 h(nx+1,j) = bufin[ib++]; 68 } 69 70 } 71 72//c--------------------------------------------------------------------- 73//c send north 74//c--------------------------------------------------------------------- 75 if (ibeg == 1) { 76 for (int ib=0,j=0; j<=ny+1; j++) { 77 bufout[ib++] = g(1,j); 78 bufout[ib++] = h(1,j); 79 } 80 RCCE_send((char*)bufout, 2*ny2*sizeof(double), north); 81 } 82 83 return; 84} 85 86