PLUTO
al_boundary.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Check if the local beginnings or endings of an array
5  correspond to the global beginnings or endings.
6 
7  Check if the local beginnings or endings of an array
8  correspond to the global beginnings or endings.
9 
10  \author A. Malagoli (University of Chicago)
11 
12  \date Jul 17, 1999
13 */
14 
15 /* ///////////////////////////////////////////////////////////////////// */
16 #include "al_hidden.h" /*I "al_hidden.h" I*/
17 
18 /*
19  The SZ structure stack is defined and maintained
20  in al_szptr_.c
21  Here we include an external reference to it in
22  order to be able to make internal references to it.
23 */
24 extern SZ *sz_stack[AL_MAX_ARRAYS];
25 extern int stack_ptr[AL_MAX_ARRAYS];
26 
27 /* ********************************************************************* */
28 int AL_Is_boundary(int sz_ptr, int *is_gbeg, int *is_gend)
29 /*!
30  * This routine is useful when implementing the physical
31  * boundary conditions on a problem. It returns two arrays
32  * that are set to AL_TRUE or AL_FALSE depending on wether
33  * or not the local beginning (ending) address for the array
34  * in each direction is actually a global one.
35  *
36  * \param [in] sz_ptr pointer to a distributed array descriptor (integer)
37  * \param [out] is_gbeg int array set to AL_TRUE or AL_FALSE
38  for global beginning
39  * \param [out] is_gend int array set to AL_TRUE or AL_FALSE
40  for global ending
41  *********************************************************************** */
42 {
43  register int i;
44  int myrank, nproc,ndims;
45  MPI_Comm comm;
46  SZ *s;
47 
48  /* DIAGNOSTICS
49  Check that sz_ptr points to an allocated SZ
50  */
51  if( stack_ptr[sz_ptr] == AL_STACK_FREE){
52  printf("AL_Is_boundary: wrong SZ pointer\n");
53  }
54 
55  s = sz_stack[sz_ptr];
56 
57  myrank = s->rank;
58  nproc = s->size;
59  comm = s->comm;
60  ndims = s->ndim;
61 
62  for(i=0;i<ndims;i++){
63  if( s->beg[i] == s->bg[i] ){
64  is_gbeg[i] = AL_TRUE;
65  } else {
66  is_gbeg[i] = AL_FALSE;
67  }
68  if( s->end[i] == s->arrdim[i]+s->bg[i]-1 ){
69  is_gend[i] = AL_TRUE;
70  } else {
71  is_gend[i] = AL_FALSE;
72  }
73  }
74 
75  /* DIAGNOSTICS */
76 #ifdef DEBUG
77  printf("AL_Is_boundary: completed\n");
78 #endif
79 
80  return (int) AL_SUCCESS;
81 }
int AL_Is_boundary(int sz_ptr, int *is_gbeg, int *is_gend)
Definition: al_boundary.c:28
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
int end[AL_MAX_DIM]
Definition: al_hidden.h:60
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_TRUE
Definition: al_codes.h:28
#define AL_STACK_FREE
Definition: al_codes.h:24
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
int arrdim[AL_MAX_DIM]
Definition: al_hidden.h:53
int rank
Definition: al_hidden.h:44
int bg[AL_MAX_DIM]
Definition: al_hidden.h:72
int beg[AL_MAX_DIM]
Definition: al_hidden.h:58
#define s
int size
Definition: al_hidden.h:45
int i
Definition: analysis.c:2
MPI_Comm comm
Definition: al_hidden.h:47
#define AL_FALSE
Definition: al_codes.h:29
Definition: al_hidden.h:38
Internal include file for the ArrayLib.
#define AL_MAX_ARRAYS
Definition: al_codes.h:21
int ndim
Definition: al_hidden.h:43