PLUTO
al_exchange_dim.c File Reference

Fill the ghost boundaries along selected dimensions. More...

#include "al_hidden.h"
Include dependency graph for al_exchange_dim.c:

Go to the source code of this file.

Functions

int AL_Exchange_dim (char *buf, int *dims, int sz_ptr)
 

Variables

SZsz_stack [AL_MAX_ARRAYS]
 
int stack_ptr [AL_MAX_ARRAYS]
 

Detailed Description

Fill the ghost boundaries along selected dimensions.

Fill the ghost boundaries along selected dimensions

Author
A. Malagoli (University of Chicago)
Date
Jul 17, 1999

Definition in file al_exchange_dim.c.

Function Documentation

int AL_Exchange_dim ( char *  buf,
int *  dims,
int  sz_ptr 
)

Fill the ghost boundaries along selected dimensions

Parameters
[in]bufpointer to buffer
[in]dimsif dims[i]=0, do not perform the exchange in this dimension (array if int)
[in]sz_ptrinteger pointer to the distributed array descriptor

Definition at line 24 of file al_exchange_dim.c.

33 {
34  register int nd;
35  int myrank, nproc;
36  int ndim, gp, nleft, nright, tag1, tag2;
37  int sendb, recvb;
38  MPI_Datatype itype;
39  MPI_Comm comm;
40  MPI_Status status;
41  SZ *s;
42 
43  /* DIAGNOSTICS
44  Check that sz_ptr points to an allocated SZ
45  */
46  if( stack_ptr[sz_ptr] == AL_STACK_FREE){
47  printf("AL_Decompose: wrong SZ pointer\n");
48  }
49 
50  s = sz_stack[sz_ptr];
51 
52  myrank = s->rank;
53  nproc = s->size;
54  comm = s->comm;
55  ndim = s->ndim;
56 
57  for(nd=0;nd<ndim;nd++){
58  gp = s->bg[nd];
59 
60  /* If gp=0, do nothing */
61  if( gp > 0 && dims[nd] != 0 ){
62  nleft = s->left[nd];
63  nright = s->right[nd];
64  itype = s->type_rl[nd];
65  tag1 = s->tag1[nd];
66 
67  sendb = s->sendb1[nd];
68  recvb = s->recvb1[nd];
69 
70  MPI_Sendrecv(&buf[sendb], 1, itype, nleft, tag1,
71  &buf[recvb], 1, itype, nright,tag1,
72  comm, &status);
73 
74  nleft = s->left[nd];
75  nright = s->right[nd];
76  itype = s->type_lr[nd];
77  tag2 = s->tag2[nd];
78 
79 
80  sendb = s->sendb2[nd];
81  recvb = s->recvb2[nd];
82 
83  MPI_Sendrecv(&buf[sendb], 1, itype, nright, tag2,
84  &buf[recvb], 1, itype, nleft,tag2,
85  comm, &status);
86  }
87  }
88 
89  /* DIAGNOSTICS */
90 #ifdef DEBUG
91  if(myrank==0) printf("AL_Exchange: filled ghost regions\n");
92 #endif
93 
94  return (int) AL_SUCCESS;
95 }
int recvb2[AL_MAX_DIM]
Definition: al_hidden.h:95
int tag1[AL_MAX_DIM]
Definition: al_hidden.h:96
#define AL_SUCCESS
Definition: al_codes.h:32
int right[AL_MAX_DIM]
Definition: al_hidden.h:86
#define AL_STACK_FREE
Definition: al_codes.h:24
int recvb1[AL_MAX_DIM]
Definition: al_hidden.h:94
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
int sendb1[AL_MAX_DIM]
Definition: al_hidden.h:92
int rank
Definition: al_hidden.h:44
MPI_Datatype type_rl[AL_MAX_DIM]
Definition: al_hidden.h:106
int bg[AL_MAX_DIM]
Definition: al_hidden.h:72
int left[AL_MAX_DIM]
Definition: al_hidden.h:84
int sendb2[AL_MAX_DIM]
Definition: al_hidden.h:93
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define s
int size
Definition: al_hidden.h:45
int tag2[AL_MAX_DIM]
Definition: al_hidden.h:96
MPI_Comm comm
Definition: al_hidden.h:47
Definition: al_hidden.h:38
MPI_Datatype type_lr[AL_MAX_DIM]
Definition: al_hidden.h:104
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

Variable Documentation

int stack_ptr[AL_MAX_ARRAYS]

Definition at line 26 of file al_szptr_.c.

SZ* sz_stack[AL_MAX_ARRAYS]

Definition at line 18 of file al_szptr_.c.