PLUTO  4.0
 All Data Structures Files Functions Variables Enumerations Macros Pages
al_hidden.h
1 #ifndef __AL_HIDDEN
2 #define __AL_HIDDEN
3 
4 /*
5  al_hidden.h -- Internal include file for the AL library
6 */
7 
8 /*
9  If this is defined, each node has a copy of
10  the indexes from all other nodes. This is mainly
11  useful to deal with non-uniform array distributions
12 */
13 
14 #include <mpi.h>
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 
21 #include "al_defs.h"
22 
23 /* Include AL macros and definitions */
24 #include "al_codes.h"
25 
26 /* Include functions prototypes */
27 #include "al_proto.h"
28 
29 
30 /* Type definition for the SZ structure */
31 typedef struct szz{
32  int compiled; /* AL_TRUE if this is a compiled array */
33  MPI_Datatype type; /* The elementary data type of the array
34  e.g.: MPI_FLOAT, MPI_INT .. */
35  int type_size; /* Size of the elmentary data type */
36  int ndim; /* Number of array dimensions (max: 5) */
37  int rank; /* Rank of this portion of the array */
38  int size; /* Size of the communicator which the
39  array is associated with */
40  MPI_Comm comm; /* The communicator which the array is
41  associated with */
42  MPI_Comm cart_comm; /* The derived cartesian communicator */
43  MPI_Comm oned_comm[AL_MAX_DIM]; /* 1D communicators along directions */
44  /* (Useful for performing global operations along single directions */
45  long int buffsize; /* Size of the local buffer for the array */
46  int arrdim[AL_MAX_DIM]; /* Global dimensions of the array */
47  int larrdim[AL_MAX_DIM]; /* Local dimensions of the array
48  in this dimension WITHOUT ghost points */
49  int larrdim_gp[AL_MAX_DIM]; /* Local size of array in this direction
50  WITH ghost points (compare to larrdim)*/
51  int beg[AL_MAX_DIM]; /* Global address of beginning of array
52  in this dimension (C-convention) */
53  int end[AL_MAX_DIM]; /* Global address of ending of array
54  in this dimension (C-convention) */
55 
56  int *begs, *ends; /* These pointers can be used to
57  gather the information about the
58  distribution of the indexes across
59  all the nodes */
60 
61  int lbeg[AL_MAX_DIM]; /* Local address of beginning of array
62  in this dimension (C-convention) */
63  int lend[AL_MAX_DIM]; /* Local address of ending of array
64  in this dimension (C-convention) */
65  int bg[AL_MAX_DIM]; /* Size of ghost point at beginning of
66  array in this dimension */
67  int eg[AL_MAX_DIM]; /* Size of ghost point at beginning of
68  array in this dimension */
69  int offset[AL_MAX_DIM]; /* Local array offsets for local do loops */
70  int stride[AL_MAX_DIM]; /* We will replace offset with stride EVENTUALLY */
71  int isparallel[AL_MAX_DIM]; /* AL_TRUE if the array is distributed
72  along this dimension [Default: AL_TRUE]*/
73  int isperiodic[AL_MAX_DIM]; /* AL_TRUE if the array is periodic in
74  this dimension [Default: AL_TRUE] */
75  int isstaggered[AL_MAX_DIM]; /* AL_TRUE if the array is staggered in
76  this dimension [Default: AL_FALSE]*/
77  int left[AL_MAX_DIM]; /* Rank of left node in this dimension in the
78  cartesian communicator topology */
79  int right[AL_MAX_DIM]; /* Rank of right node in this dimension in the
80  cartesian communicator topology */
81  int lrank[AL_MAX_DIM]; /* Rank of this node along this dimension of
82  the cartesian nodes topology */
83  int lsize[AL_MAX_DIM]; /* Number of nodes along this dimension of
84  the cartesian nodes topology */
85  int sendb1[AL_MAX_DIM]; /* Send buffer pointer for the SendRecv operation */
86  int sendb2[AL_MAX_DIM];
87  int recvb1[AL_MAX_DIM]; /* Receive buffer pointers for the SendRecv operation */
88  int recvb2[AL_MAX_DIM];
89  int tag1[AL_MAX_DIM], tag2[AL_MAX_DIM]; /* Tags for SendRecv operation */
90  MPI_Datatype strided[AL_MAX_DIM]; /* Strided data type corresponding to
91  the ghost point buffer in this
92  dimension */
93  /* We add two separate strided data types in order to allow for
94  a different exchange of ghost points from Left to Right than
95  from Right to Left. This is needed when we exchange boundary
96  points in strided or overlapping data types */
97  MPI_Datatype type_lr[AL_MAX_DIM]; /* Strided data type for the
98  Left->Right exchange */
99  MPI_Datatype type_rl[AL_MAX_DIM]; /* Strided data type for the
100  Right->Left exchange */
101  int pio_offset; /* The offset for PIO */
102 
103  MPI_Datatype gsubarr; /* Global subarray for MPI-IO */
104  MPI_Datatype lsubarr; /* Local subarray for MPI-IO */
105 
106  MPI_Datatype gsubarr_stag[AL_MAX_DIM]; /* Global staggered subarrays for MPI-IO */
107  MPI_Datatype lsubarr_stag[AL_MAX_DIM]; /* Local staggered subarrays for MPI-IO */
108 
109  MPI_Offset io_offset; /* Offset used to store file pointer */
110  MPI_File ifp; /* Pointer to the file this array is to be
111  written using MPI-IO */
112 } SZ;
113 
114 
115 #endif /* End ifndef __AL_HIDDEN */
116 /*------------------------------------------------------------*/
117 
118 /* In order to make life easier with the Fortran interface,
119  we do not pass the pointers to the SZ structures directly,
120  but we rather allocate statically an array of pointers to
121  SZ structures, and pass an integer index that points to
122  an entry in this array */
123 /* SZ *sz_stack[AL_MAX_ARRAYS]; */
124 
125 
126 /*M
127  SZ - The descriptor structure for distributed arrays.
128 
129 .vb
130 
131  This structure contains all the information necessary
132  to handle information on distributed arrays. The structures
133  are not accessible directly by the user, but are modified
134  and queried by calling routines that are part of the AL
135  library.
136 
137 
138 Here is the type definition for the SZ structure:
139 
140 
141 typedef struct SZ_{
142  int compiled; AL_TRUE if this is a compiled array
143  int type; The elementary data type of the array
144  e.g.: MPI_FLOAT, MPI_INT ..
145  int ndim; Number of array dimensions (max: 5)
146  int rank; Rank of this portion of the array
147  int size; Size of the communicator which the
148  array is associated with
149  MPI_Comm comm; The communicator which the array is
150  associated with.
151  MPI_Comm cart_comm; The derived cartesian communicator
152  MPI_Comm oned_comm[AL_MAX_DIM]; 1D communicators along directions
153  (Useful for performing global operations
154  along single directions)
155  int buffsize;
156  int arrdim[AL_MAX_DIM]; Global dimensions of the array
157  int larrdim[AL_MAX_DIM]; Local dimensions of the array
158  in this dimension WITHOUT ghost points
159  int larrdim_gp[AL_MAX_DIM]; Local size of array in this direction
160  WITH ghost points (compare to larrdim)
161  int beg[AL_MAX_DIM]; Global address of beginning of array
162  in this dimension (C-convention)
163  int end[AL_MAX_DIM]; Global address of ending of array
164  in this dimension (C-convention)
165 
166  int *begs, *ends; These pointers can be used to
167  gather the information about the
168  distribution of the indexes across
169  all the nodes
170 
171  int lbeg[AL_MAX_DIM]; Local address of beginning of array
172  in this dimension (C-convention)
173  int lend[AL_MAX_DIM]; Local address of ending of array
174  in this dimension (C-convention)
175  int bg[AL_MAX_DIM]; Size of ghost point at beginning of
176  array in this dimension
177  int eg[AL_MAX_DIM]; Size of ghost point at beginning of
178  array in this dimension
179  int offset[AL_MAX_DIM]; Local array offsets for local do loops
180  int isparallel[AL_MAX_DIM]; AL_TRUE if the array is distributed
181  along this dimension [Default: AL_TRUE]
182  int isperiodic[AL_MAX_DIM]; AL_TRUE if the array is periodic in
183  this dimension [Default: AL_TRUE]
184  int isstaggered[AL_MAX_DIM];AL_TRUE if the array is staggered in
185  this dimension [Default: AL_FALSE]
186  int left[AL_MAX_DIM]; Rank of left node in this dimension in the
187  cartesian communicator topology
188  int right[AL_MAX_DIM]; Rank of right node in this dimension in the
189  cartesian communicator topology
190  int lrank[AL_MAX_DIM]; Rank of this node along this dimension of
191  the cartesian nodes topology
192  int lsize[AL_MAX_DIM]; Number of nodes along this dimension of
193  the cartesian nodes topology
194  int sendb1[AL_MAX_DIM]; Send buffer pointer for the SendRecv operation
195  int sendb2[AL_MAX_DIM];
196  int recvb1[AL_MAX_DIM]; Receive buffer pointers for the SendRecv operation
197  int recvb2[AL_MAX_DIM];
198  int tag1[AL_MAX_DIM], tag2[AL_MAX_DIM]; Tags for SendRecv operation
199 
200  MPI_Datatype strided[AL_MAX_DIM]; Strided data type corresponding to
201  the ghost point buffer in this
202  dimension
203 
204  MPI_Datatype type_lr[AL_MAX_DIM]; Strided data type for the
205  Left->Right exchange
206  MPI_Datatype type_rl[AL_MAX_DIM]; Strided data type for the
207  Right->Left exchange
208 
209  THESE ARE DEFINED ONLY IF MPI-IO IS COMPILED:
210 
211  MPI_Datatype gsubarr; Global subarray for MPI-IO
212  MPI_Datatype lsubarr; Local subarray for MPI-IO
213  MPI_Offset io_offset; Offset used to store file pointer
214  MPI_File ifp; Pointer to the file this array is to be
215  written using MPI-IO
216 
217 } SZ;
218 .ve
219 M*/
220