source: CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch/lib/mct/mpi-serial/group.c @ 6331

Last change on this file since 6331 was 6331, checked in by aclsce, 17 months ago

Moved oasis-mct_5.0 in oasis3-mct/branches directory.

File size: 4.6 KB
Line 
1
2#include "mpiP.h"
3
4
5/*********/
6
7
8FC_FUNC( mpi_group_incl, MPI_GROUP_INCL )
9     (int *group, int *n, int *ranks, int *newgroup, int *ierror)
10{
11  *ierror= MPI_Group_incl(*group, *n, ranks, newgroup);
12}
13
14
15int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup)
16{
17
18  if (group==MPI_GROUP_NULL)
19    {
20      fprintf(stderr,"MPI_Group_incl: null group passed in\n");
21      abort();
22    }
23
24  if (group==MPI_GROUP_EMPTY || n==0)
25    *newgroup=MPI_GROUP_EMPTY;
26  else
27    if (n==1 && ranks[0]==0)
28      *newgroup=MPI_GROUP_ONE;
29    else
30      {
31        fprintf(stderr,"MPI_Group_incl: more than 1 proc in group\n");
32        abort();
33      }
34
35  return(MPI_SUCCESS);
36}
37
38
39/*********/
40
41
42/* MPI_Group_range_incl
43 * Include a strided range of ranks in a group.  For one processor, if
44 * "0" is included in any of these ranges, it can only be the first rank.
45 * Thus, if rank 0 is specified, include it, otherwise use GROUP_NULL
46 */
47
48
49FC_FUNC( mpi_group_range_incl, MPI_GROUP_RANGE_INCL )
50     (int *group, int *n, int ranges[][3], int *newgroup, int *ierror)
51{
52  *ierror= MPI_Group_range_incl(*group, *n, ranges, newgroup);
53}
54
55
56int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
57                         MPI_Group *newgroup)
58{
59
60  if (group==MPI_GROUP_NULL)
61    {
62      fprintf(stderr,"MPI_Group_range_incl: null group passed in\n");
63      abort();
64    }
65
66  if (group==MPI_GROUP_EMPTY || n==0)
67    *newgroup=MPI_GROUP_EMPTY;
68  else
69    if (n==1 && ranges[0][0]==0 && ranges[0][1]==0)
70      *newgroup=MPI_GROUP_ONE;
71    else
72      {
73        fprintf(stderr,"MPI_Group_range_incl: more than 1 proc in group\n");
74        abort();
75      }
76
77  return(MPI_SUCCESS);
78}
79
80
81
82
83/*********/
84
85
86
87FC_FUNC( mpi_group_union, MPI_GROUP_UNION )
88     (int *group1, int *group2, int *newgroup, int *ierror)
89{
90  *ierror= MPI_Group_union(*group1,*group2,newgroup);
91}
92
93
94
95int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
96{
97
98  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
99    {
100      fprintf(stderr,"MPI_Group_union: null group passed in\n");
101      abort();
102    }
103
104  if (group1==MPI_GROUP_ONE || group2==MPI_GROUP_ONE)
105    *newgroup=MPI_GROUP_ONE;
106  else
107    *newgroup=MPI_GROUP_EMPTY;
108
109
110  return(MPI_SUCCESS);
111}
112
113/*********/
114
115
116
117FC_FUNC( mpi_group_intersection, MPI_GROUP_INTERSECTION )
118     (int *group1, int *group2, int *newgroup, int *ierror)
119{
120  *ierror= MPI_Group_intersection(*group1,*group2,newgroup);
121}
122
123
124
125int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
126                           MPI_Group *newgroup)
127{
128
129  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
130    {
131      fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
132      abort();
133    }
134
135  if (group1==MPI_GROUP_ONE && group2==MPI_GROUP_ONE)
136    *newgroup=MPI_GROUP_ONE;
137  else
138    *newgroup=MPI_GROUP_EMPTY;
139
140
141  return(MPI_SUCCESS);
142}
143
144
145/*********/
146
147
148
149FC_FUNC( mpi_group_difference, MPI_GROUP_DIFFERENCE )
150     (int *group1, int *group2, int *newgroup, int *ierror)
151{
152  *ierror= MPI_Group_difference(*group1,*group2,newgroup);
153}
154
155
156
157int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
158                         MPI_Group *newgroup)
159{
160
161  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
162    {
163      fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
164      abort();
165    }
166
167  if (group1==MPI_GROUP_EMPTY || group2==MPI_GROUP_ONE)
168    *newgroup=MPI_GROUP_EMPTY;
169  else
170    *newgroup=MPI_GROUP_ONE;
171
172  return(MPI_SUCCESS);
173}
174
175
176
177/*********/
178
179
180FC_FUNC( mpi_group_free, MPI_GROUP_FREE )(int *group, int *ierror)
181{
182  *ierror= MPI_Group_free(group);
183}
184
185
186int MPI_Group_free(MPI_Group *group)
187{
188  *group= MPI_GROUP_NULL;
189
190  return(MPI_SUCCESS);
191}
192
193
194/*********/
195
196
197
198FC_FUNC( mpi_group_translate_ranks, MPI_GROUP_TRANSLATE_RANKS )
199     ( int *group1, int *n, int *ranks1,
200       int *group2, int *ranks2, int *ierror)
201{
202  *ierror= MPI_Group_translate_ranks(*group1,*n,ranks1,*group2,ranks2);
203}
204
205
206
207int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
208                              MPI_Group group2, int *ranks2)
209{
210  int i;
211
212  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
213    {
214      fprintf(stderr,"MPI_Group_translate_ranks: null group passed in\n");
215      abort();
216    }
217
218  if (n==0)
219    return(MPI_SUCCESS);
220
221  if (group1==MPI_GROUP_EMPTY)
222    {
223      fprintf(stderr,"MPI_Group_translate_ranks: empty input group\n");
224      abort();
225    }
226
227  for (i=0; i<n; i++)
228    {
229      if (ranks1[i]!=0)
230        {
231          fprintf(stderr,"MPI_Group_translate_ranks: bad input rank: %d\n",
232                  ranks1[i]);
233          abort();
234        }
235
236      if (group2!=MPI_GROUP_EMPTY)
237        ranks2[i]=ranks1[i];
238      else
239        ranks2[i]=MPI_UNDEFINED;
240    }
241
242
243  return(MPI_SUCCESS);
244
245}
246
247
248/*********/
249
250
251MPI_Group MPI_Group_f2c(MPI_Fint group)
252{
253  return(group);
254}
255
256
257/*********/
258
259
260MPI_Fint MPI_Group_c2f(MPI_Group group)
261{
262  return(group);
263}
264
Note: See TracBrowser for help on using the repository browser.