PLUTO
al_sz_init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Allocate and initialize a distributed array descriptor
5 
6  \author A. Malagoli (University of Chicago)
7  \date Jul 28, 1999
8 */
9 /* ///////////////////////////////////////////////////////////////////// */
10 #include "al_hidden.h" /*I "al_hidden.h" I*/
11 
12 /*
13  The SZ structure stack is defined and maintained
14  in al_szptr_.c
15  Here we include an external reference to it in
16  order to be able to make internal references to it.
17 */
18 extern SZ *sz_stack[AL_MAX_ARRAYS];
19 extern int stack_ptr[AL_MAX_ARRAYS];
20 
21 /* ********************************************************************* */
22 int AL_Sz_init(MPI_Comm comm, int *sz_ptr)
23 /*!
24  * Allocate and initialize a distributed array descriptor
25  *
26  * \param [in] comm MPI communicator the array is associated with
27  * \param [out] sz_ptr Integer pointer to the array descriptor
28  *
29  * \return AL_SUCCESS if the array descriptor is correct initialized,
30  * AL_FAILURE otherwise.
31  *************************************************************************/
32 {
33  int myrank, nproc;
34  register int i;
35 
36  /*
37  If this process does not belong to the communicator,
38  or if the communicator is MPI_COMM_NULL, return a
39  AL_UNDEFINED pointer
40  */
41  if( comm == MPI_COMM_NULL ) {
42  *sz_ptr = AL_UNDEFINED;
43  return AL_FAILURE;
44  }
45 
46  /*
47  Allocate the SZ structure
48  */
49  *sz_ptr = AL_Allocate_sz_();
50 
51  MPI_Comm_rank(comm, &myrank);
52  MPI_Comm_size(comm, &nproc);
53 
54  /*
55  Set the initial entries
56  */
57  sz_stack[*sz_ptr]->compiled = AL_FALSE; /* The array is not compiled yet */
58  sz_stack[*sz_ptr]->comm = comm;
59  sz_stack[*sz_ptr]->rank = myrank;
60  sz_stack[*sz_ptr]->size = nproc;
61 
62  /*
63  Set some defaults
64  */
65  sz_stack[*sz_ptr]->type = MPI_DOUBLE;
66  for(i=0;i<AL_MAX_DIM;i++){
67  sz_stack[*sz_ptr]->isparallel[i] = AL_TRUE;
68  sz_stack[*sz_ptr]->isperiodic[i] = AL_TRUE;
69  sz_stack[*sz_ptr]->isstaggered[i] = AL_FALSE;
70  sz_stack[*sz_ptr]->larrdim_gp[i]=1;
71  sz_stack[*sz_ptr]->larrdim[i]=1;
72  sz_stack[*sz_ptr]->arrdim[i]=1;
73  sz_stack[*sz_ptr]->beg[i]=0;
74  sz_stack[*sz_ptr]->end[i]=0;
75  sz_stack[*sz_ptr]->lbeg[i]=0;
76  sz_stack[*sz_ptr]->lend[i]=0;
77  sz_stack[*sz_ptr]->bg[i]=0;
78  sz_stack[*sz_ptr]->eg[i]=0;
79  sz_stack[*sz_ptr]->offset[i]=1;
80  sz_stack[*sz_ptr]->stride[i]=1;
81  }
82 
83  sz_stack[*sz_ptr]->begs = NULL;
84  sz_stack[*sz_ptr]->ends = NULL;
85 
86  return (int) AL_SUCCESS;
87 }
88 
int isperiodic[AL_MAX_DIM]
Definition: al_hidden.h:80
#define AL_MAX_DIM
Definition: al_codes.h:18
int end[AL_MAX_DIM]
Definition: al_hidden.h:60
int isparallel[AL_MAX_DIM]
Definition: al_hidden.h:78
int AL_Allocate_sz_()
Definition: al_szptr_.c:58
int offset[AL_MAX_DIM]
Definition: al_hidden.h:76
int AL_Sz_init(MPI_Comm comm, int *sz_ptr)
Definition: al_sz_init.c:22
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_TRUE
Definition: al_codes.h:28
int * begs
Definition: al_hidden.h:63
int arrdim[AL_MAX_DIM]
Definition: al_hidden.h:53
int larrdim_gp[AL_MAX_DIM]
Definition: al_hidden.h:56
int larrdim[AL_MAX_DIM]
Definition: al_hidden.h:54
int rank
Definition: al_hidden.h:44
int * ends
Definition: al_hidden.h:63
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
int stride[AL_MAX_DIM]
Definition: al_hidden.h:77
int bg[AL_MAX_DIM]
Definition: al_hidden.h:72
int beg[AL_MAX_DIM]
Definition: al_hidden.h:58
int isstaggered[AL_MAX_DIM]
Definition: al_hidden.h:82
int eg[AL_MAX_DIM]
Definition: al_hidden.h:74
#define AL_FAILURE
Definition: al_codes.h:33
int size
Definition: al_hidden.h:45
int i
Definition: analysis.c:2
MPI_Comm comm
Definition: al_hidden.h:47
MPI_Datatype type
Definition: al_hidden.h:40
#define AL_FALSE
Definition: al_codes.h:29
Definition: al_hidden.h:38
Internal include file for the ArrayLib.
#define AL_UNDEFINED
Definition: al_codes.h:127
int compiled
Definition: al_hidden.h:39
int lbeg[AL_MAX_DIM]
Definition: al_hidden.h:68
#define AL_MAX_ARRAYS
Definition: al_codes.h:21
int lend[AL_MAX_DIM]
Definition: al_hidden.h:70