PLUTO
al_sz_set.c File Reference

Miscellaneous functions to define the properties of the distributed array by setting various parameters via the isz descriptor. More...

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

Go to the source code of this file.

Functions

int AL_Set_comm (MPI_Comm comm, int isz)
 
int AL_Set_dimensions (int ndim, int isz)
 
int AL_Set_type (AL_Datatype type, int nelem, int isz)
 
int AL_Set_global_dim (int *gdims, int isz)
 
int AL_Set_local_dim (int *ldims, int isz)
 
int AL_Set_parallel_dim (int *pardims, int isz)
 
int AL_Set_periodic_dim (int *periods, int isz)
 
int AL_Set_staggered_dim (int *stagger, int isz)
 
int AL_Set_ghosts (int *ghosts, int isz)
 

Variables

SZsz_stack [AL_MAX_ARRAYS]
 
int stack_ptr [AL_MAX_ARRAYS]
 

Detailed Description

Miscellaneous functions to define the properties of the distributed array by setting various parameters via the isz descriptor.

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

Definition in file al_sz_set.c.

Function Documentation

int AL_Set_comm ( MPI_Comm  comm,
int  isz 
)

Set the communicator for a distributed array

Parameters
[in]commMPI communicator the array is associated with
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the communicator is set correctly, AL_FAILURE otherwise.

Definition at line 24 of file al_sz_set.c.

34 {
35  int myrank, nproc;
36  SZ *s;
37 
38  /*
39  Check that isz points to an allocated SZ
40  */
41  if( stack_ptr[isz] == AL_STACK_FREE ){
42  printf("AL_Set_comm: wrong SZ pointer\n");
43  return (int) AL_FAILURE;
44  }
45 
46  /*
47  Get the SZ structure isz is pointing at
48  */
49  s = sz_stack[isz];
50 
51  MPI_Comm_rank(comm, &myrank);
52  MPI_Comm_size(comm, &nproc);
53 
54  s->comm = comm;
55  s->size = nproc;
56  /*
57  Patch for the case in which this node does not
58  belong to this communicator
59  */
60  if( nproc > 0 ) {
61  s->rank = myrank;
62  } else { s->rank = MPI_UNDEFINED; }
63 
64  return (int) AL_SUCCESS;
65 }
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
int rank
Definition: al_hidden.h:44
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int size
Definition: al_hidden.h:45
MPI_Comm comm
Definition: al_hidden.h:47
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38
int AL_Set_dimensions ( int  ndim,
int  isz 
)

Set the dimensions of a distributed array

Parameters
[in]ndimNumber of dimensions (1 to 5)
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the dimensions are set correctly, AL_FAILURE otherwise.

Definition at line 69 of file al_sz_set.c.

79 {
80  SZ *s;
81 
82  /*
83  Check that isz points to an allocated SZ
84  */
85  if( stack_ptr[isz] == AL_STACK_FREE ){
86  printf("AL_Set_dimensions: wrong SZ pointer\n");
87  return (int) AL_FAILURE;
88  }
89 
90  /*
91  Get the SZ structure isz is pointing at
92  */
93  s = sz_stack[isz];
94 
95  s->ndim = ndim;
96 
97  return (int) AL_SUCCESS;
98 }
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define AL_FAILURE
Definition: al_codes.h:33
#define s
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

int AL_Set_ghosts ( int *  ghosts,
int  isz 
)

Set the ghost points of a distributed array

Parameters
[in]ghostArray of integers with size of ghost points in each dimension
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the ghost points are set correctly, AL_FAILURE otherwise.

Definition at line 333 of file al_sz_set.c.

344 {
345  register int i;
346  int ndim;
347  SZ *s;
348 
349  /*
350  Check that isz points to an allocated SZ
351  */
352  if( stack_ptr[isz] == AL_STACK_FREE ){
353  printf("AL_Set_ghosts: wrong SZ pointer\n");
354  return (int) AL_FAILURE;
355  }
356 
357  /*
358  Get the SZ structure isz is pointing at
359  */
360  s = sz_stack[isz];
361 
362  ndim = s->ndim;
363  for(i=0;i<ndim;i++){
364  s->bg[i] = ghosts[i];
365  s->eg[i] = ghosts[i];
366  }
367 
368  return (int) AL_SUCCESS;
369 }
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
int bg[AL_MAX_DIM]
Definition: al_hidden.h:72
int eg[AL_MAX_DIM]
Definition: al_hidden.h:74
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int i
Definition: analysis.c:2
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

int AL_Set_global_dim ( int *  gdims,
int  isz 
)

Set the global dimensions of a distributed array

Parameters
[in]gdimsArray of integers with global dimensions
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the global dimension are set correctly, AL_FAILURE otherwise.

Definition at line 141 of file al_sz_set.c.

151 {
152  register int i;
153  int ndim;
154 
155  SZ *s;
156 
157  /*
158  Check that isz points to an allocated SZ
159  */
160  if( stack_ptr[isz] == AL_STACK_FREE ){
161  printf("AL_Set_global_dim: wrong SZ pointer\n");
162  return (int) AL_FAILURE;
163  }
164 
165  /*
166  Get the SZ structure isz is pointing at
167  */
168  s = sz_stack[isz];
169 
170  ndim = s->ndim;
171  for(i=0;i<ndim;i++){ s->arrdim[i] = gdims[i] ;}
172 
173  return (int) AL_SUCCESS;
174 }
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int arrdim[AL_MAX_DIM]
Definition: al_hidden.h:53
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int i
Definition: analysis.c:2
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

int AL_Set_local_dim ( int *  ldims,
int  isz 
)

Set the local dimensions of a distributed array

Parameters
[in]ldimsArray of integers with local dimensions
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the local dimension are set correctly, AL_FAILURE otherwise.

Definition at line 177 of file al_sz_set.c.

187 {
188  register int i;
189  int ndim;
190  SZ *s;
191 
192  /*
193  Check that isz points to an allocated SZ
194  */
195  if( stack_ptr[isz] == AL_STACK_FREE ){
196  printf("AL_Set_local_dim: wrong SZ pointer\n");
197  return (int) AL_FAILURE;
198  }
199 
200  /*
201  Get the SZ structure isz is pointing at
202  */
203  s = sz_stack[isz];
204 
205  ndim = s->ndim;
206  for(i=0;i<ndim;i++){
207  s->larrdim[i] = ldims[i];
208  s->lbeg[i] = 0;
209  s->lend[i] = ldims[i]-1;
210  }
211 
212  return (int) AL_SUCCESS;
213 }
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
int larrdim[AL_MAX_DIM]
Definition: al_hidden.h:54
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int i
Definition: analysis.c:2
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38
int lbeg[AL_MAX_DIM]
Definition: al_hidden.h:68
int lend[AL_MAX_DIM]
Definition: al_hidden.h:70
int ndim
Definition: al_hidden.h:43
int AL_Set_parallel_dim ( int *  pardims,
int  isz 
)

Set the parallel dimensions of a distributed array

Parameters
[in]pardimsArray of integers with parallel dimensions [AL_TRUE|AL_FALSE]
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the parallel dimension are set correctly, AL_FAILURE otherwise.

Definition at line 216 of file al_sz_set.c.

226 {
227  register int i;
228  int ndim;
229  SZ *s;
230 
231  /*
232  Check that isz points to an allocated SZ
233  */
234  if( stack_ptr[isz] == AL_STACK_FREE ){
235  printf("AL_Set_parallel_dim: wrong SZ pointer\n");
236  return (int) AL_FAILURE;
237  }
238 
239  /*
240  Get the SZ structure isz is pointing at
241  */
242  s = sz_stack[isz];
243 
244  ndim = s->ndim;
245  for(i=0;i<ndim;i++){
246  s->isparallel[i] = pardims[i];
247  }
248 
249  return (int) AL_SUCCESS;
250 }
int isparallel[AL_MAX_DIM]
Definition: al_hidden.h:78
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int i
Definition: analysis.c:2
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

int AL_Set_periodic_dim ( int *  periods,
int  isz 
)

Set the periodic dimensions of a distributed array

Parameters
[in]periodsArray of integers with periodic dimensions [AL_TRUE|AL_FALSE]
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the periodic dimension are set correctly, AL_FAILURE otherwise.

Definition at line 253 of file al_sz_set.c.

263 {
264  register int i;
265  int ndim;
266  SZ *s;
267 
268  /*
269  Check that isz points to an allocated SZ
270  */
271  if( stack_ptr[isz] == AL_STACK_FREE ){
272  printf("AL_Set_periodic_dim: wrong SZ pointer\n");
273  return (int) AL_FAILURE;
274  }
275 
276  /*
277  Get the SZ structure isz is pointing at
278  */
279  s = sz_stack[isz];
280 
281  ndim = s->ndim;
282  for(i=0;i<ndim;i++){
283  if( periods[i] != AL_TRUE && periods[i] != AL_FALSE ){
284  printf("Warning: periods has illegal values in AL_Set_periodic_dim\n");
285  }
286  s->isperiodic[i] = periods[i];
287  }
288 
289  return (int) AL_SUCCESS;
290 }
int isperiodic[AL_MAX_DIM]
Definition: al_hidden.h:80
#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
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int i
Definition: analysis.c:2
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
#define AL_FALSE
Definition: al_codes.h:29
Definition: al_hidden.h:38
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

int AL_Set_staggered_dim ( int *  stagger,
int  isz 
)

Set the staggered dimensions of a distributed array

Parameters
[in]staggerArray of integers with staggered dimensions [AL_TRUE|AL_FALSE]
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the staggered dimension are set correctly, AL_FAILURE otherwise.

Definition at line 293 of file al_sz_set.c.

303 {
304  register int i;
305  int ndim;
306  SZ *s;
307 
308  /*
309  Check that isz points to an allocated SZ
310  */
311  if( stack_ptr[isz] == AL_STACK_FREE ){
312  printf("AL_Set_staggered_dim: wrong SZ pointer\n");
313  return (int) AL_FAILURE;
314  }
315 
316  /*
317  Get the SZ structure isz is pointing at
318  */
319  s = sz_stack[isz];
320 
321  ndim = s->ndim;
322  for(i=0;i<ndim;i++){
323  if( stagger[i] != AL_TRUE && stagger[i] != AL_FALSE ){
324  printf("Warning: stagger has illegal values in AL_Set_staggered_dim\n");
325  }
326  s->isstaggered[i] = stagger[i];
327  }
328 
329  return (int) AL_SUCCESS;
330 }
#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
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
int isstaggered[AL_MAX_DIM]
Definition: al_hidden.h:82
#define AL_FAILURE
Definition: al_codes.h:33
#define s
int i
Definition: analysis.c:2
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
#define AL_FALSE
Definition: al_codes.h:29
Definition: al_hidden.h:38
int ndim
Definition: al_hidden.h:43

Here is the caller graph for this function:

int AL_Set_type ( AL_Datatype  type,
int  nelem,
int  isz 
)

Set the basic data type of a distributed array. The data types are identical to the MPI datatypes, and they can be defined as AL_<type> or MPI_<type> (e.g. AL_FLOAT or MPI_FLOAT).

Parameters
[in]typeDatatype (AL_Datatype or MPI_Datatype)
[in]nelemNumber of type 'type' elements in array elements
[out]iszInteger pointer to the input array descriptor
Returns
AL_SUCCESS if the type is set correctly, AL_FAILURE otherwise.

Definition at line 101 of file al_sz_set.c.

112 {
113  SZ *s;
114  AL_Datatype ivector;
115 
116  /*
117  Check that isz points to an allocated SZ
118  */
119  if( stack_ptr[isz] == AL_STACK_FREE ){
120  printf("AL_Set_type: wrong SZ pointer\n");
121  return (int) AL_FAILURE;
122  }
123 
124  /*
125  Get the SZ structure isz is pointing at
126  */
127  s = sz_stack[isz];
128 
129  if( nelem <= 1 ){
130  s->type = type;
131  } else {
132  MPI_Type_contiguous( nelem, type, &ivector);
133  MPI_Type_commit(&ivector);
134  s->type = ivector;
135  }
136 
137  return (int) AL_SUCCESS;
138 }
#define AL_Datatype
Definition: al_defs.h:22
#define AL_SUCCESS
Definition: al_codes.h:32
#define AL_STACK_FREE
Definition: al_codes.h:24
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define AL_FAILURE
Definition: al_codes.h:33
#define s
MPI_Datatype type
Definition: al_hidden.h:40
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18
Definition: al_hidden.h:38

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.