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

Last change on this file since 4775 was 4775, checked in by aclsce, 4 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

File size: 4.4 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
42FC_FUNC( mpi_group_range_incl, MPI_GROUP_RANGE_INCL )
43     (int *group, int *n, int ranges[][3], int *newgroup, int *ierror)
44{
45  *ierror= MPI_Group_range_incl(*group, *n, ranges, newgroup);
46}
47 
48
49int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
50                         MPI_Group *newgroup)
51{
52
53  if (group==MPI_GROUP_NULL)
54    {
55      fprintf(stderr,"MPI_Group_range_incl: null group passed in\n");
56      abort();
57    }
58
59  if (group==MPI_GROUP_EMPTY || n==0)
60    *newgroup=MPI_GROUP_EMPTY;
61  else
62    if (n==1 && ranges[0][0]==0 && ranges[0][1]==0)
63      *newgroup=MPI_GROUP_ONE;
64    else
65      {
66        fprintf(stderr,"MPI_Group_range_incl: more than 1 proc in group\n");
67        abort();
68      }
69
70  return(MPI_SUCCESS);
71}
72
73
74
75
76/*********/
77
78
79
80FC_FUNC( mpi_group_union, MPI_GROUP_UNION )
81     (int *group1, int *group2, int *newgroup, int *ierror)
82{
83  *ierror= MPI_Group_union(*group1,*group2,newgroup);
84}
85
86
87
88int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
89{
90
91  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
92    {
93      fprintf(stderr,"MPI_Group_union: null group passed in\n");
94      abort();
95    }
96 
97  if (group1==MPI_GROUP_ONE || group2==MPI_GROUP_ONE)
98    *newgroup=MPI_GROUP_ONE;
99  else
100    *newgroup=MPI_GROUP_EMPTY;
101
102
103  return(MPI_SUCCESS);
104}
105
106/*********/
107
108
109
110FC_FUNC( mpi_group_intersection, MPI_GROUP_INTERSECTION )
111     (int *group1, int *group2, int *newgroup, int *ierror)
112{
113  *ierror= MPI_Group_intersection(*group1,*group2,newgroup);
114}
115
116
117
118int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
119                           MPI_Group *newgroup)
120{
121
122  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
123    {
124      fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
125      abort();
126    }
127 
128  if (group1==MPI_GROUP_ONE && group2==MPI_GROUP_ONE)
129    *newgroup=MPI_GROUP_ONE;
130  else
131    *newgroup=MPI_GROUP_EMPTY;
132
133
134  return(MPI_SUCCESS);
135}
136
137
138/*********/
139
140
141
142FC_FUNC( mpi_group_difference, MPI_GROUP_DIFFERENCE )
143     (int *group1, int *group2, int *newgroup, int *ierror)
144{
145  *ierror= MPI_Group_difference(*group1,*group2,newgroup);
146}
147
148
149
150int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
151                         MPI_Group *newgroup)
152{
153
154  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
155    {
156      fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
157      abort();
158    }
159 
160  if (group1==MPI_GROUP_EMPTY || group2==MPI_GROUP_ONE)
161    *newgroup=MPI_GROUP_EMPTY;
162  else
163    *newgroup=MPI_GROUP_ONE;
164
165  return(MPI_SUCCESS);
166}
167
168
169
170/*********/
171
172
173FC_FUNC( mpi_group_free, MPI_GROUP_FREE )(int *group, int *ierror)
174{
175  *ierror= MPI_Group_free(group);
176}
177
178
179int MPI_Group_free(MPI_Group *group)
180{
181  *group= MPI_GROUP_NULL;
182
183  return(MPI_SUCCESS);
184}
185
186
187/*********/
188
189
190
191FC_FUNC( mpi_group_translate_ranks, MPI_GROUP_TRANSLATE_RANKS )
192     ( int *group1, int *n, int *ranks1,
193       int *group2, int *ranks2, int *ierror)
194{
195  *ierror= MPI_Group_translate_ranks(*group1,*n,ranks1,*group2,ranks2);
196}
197
198
199
200int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
201                              MPI_Group group2, int *ranks2)
202{
203  int i;
204
205  if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
206    {
207      fprintf(stderr,"MPI_Group_translate_ranks: null group passed in\n");
208      abort();
209    }
210
211  if (n==0)
212    return(MPI_SUCCESS);
213
214  if (group1==MPI_GROUP_EMPTY)
215    {
216      fprintf(stderr,"MPI_Group_translate_ranks: empty input group\n");
217      abort();
218    }   
219
220  for (i=0; i<n; i++)
221    {
222      if (ranks1[i]!=0)
223        {
224          fprintf(stderr,"MPI_Group_translate_ranks: bad input rank: %d\n",
225                  ranks1[i]);
226          abort();
227        }
228
229      if (group2!=MPI_GROUP_EMPTY)
230        ranks2[i]=ranks1[i];
231      else
232        ranks2[i]=MPI_UNDEFINED;
233    }
234     
235
236  return(MPI_SUCCESS);
237
238}
239
240
241/*********/
242
243
244MPI_Group MPI_Group_f2c(MPI_Fint group)
245{
246  return(group);
247}
248
249
250/*********/
251
252
253MPI_Fint MPI_Group_c2f(MPI_Group group)
254{
255  return(group);
256}
257
Note: See TracBrowser for help on using the repository browser.