group.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #include "mpiP.h"
  2. /*********/
  3. FC_FUNC( mpi_group_incl, MPI_GROUP_INCL )
  4. (int *group, int *n, int *ranks, int *newgroup, int *ierror)
  5. {
  6. *ierror= MPI_Group_incl(*group, *n, ranks, newgroup);
  7. }
  8. int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup)
  9. {
  10. if (group==MPI_GROUP_NULL)
  11. {
  12. fprintf(stderr,"MPI_Group_incl: null group passed in\n");
  13. abort();
  14. }
  15. if (group==MPI_GROUP_EMPTY || n==0)
  16. *newgroup=MPI_GROUP_EMPTY;
  17. else
  18. if (n==1 && ranks[0]==0)
  19. *newgroup=MPI_GROUP_ONE;
  20. else
  21. {
  22. fprintf(stderr,"MPI_Group_incl: more than 1 proc in group\n");
  23. abort();
  24. }
  25. return(MPI_SUCCESS);
  26. }
  27. /*********/
  28. FC_FUNC( mpi_group_range_incl, MPI_GROUP_RANGE_INCL )
  29. (int *group, int *n, int ranges[][3], int *newgroup, int *ierror)
  30. {
  31. *ierror= MPI_Group_range_incl(*group, *n, ranges, newgroup);
  32. }
  33. int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
  34. MPI_Group *newgroup)
  35. {
  36. if (group==MPI_GROUP_NULL)
  37. {
  38. fprintf(stderr,"MPI_Group_range_incl: null group passed in\n");
  39. abort();
  40. }
  41. if (group==MPI_GROUP_EMPTY || n==0)
  42. *newgroup=MPI_GROUP_EMPTY;
  43. else
  44. if (n==1 && ranges[0][0]==0 && ranges[0][1]==0)
  45. *newgroup=MPI_GROUP_ONE;
  46. else
  47. {
  48. fprintf(stderr,"MPI_Group_range_incl: more than 1 proc in group\n");
  49. abort();
  50. }
  51. return(MPI_SUCCESS);
  52. }
  53. /*********/
  54. FC_FUNC( mpi_group_union, MPI_GROUP_UNION )
  55. (int *group1, int *group2, int *newgroup, int *ierror)
  56. {
  57. *ierror= MPI_Group_union(*group1,*group2,newgroup);
  58. }
  59. int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
  60. {
  61. if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
  62. {
  63. fprintf(stderr,"MPI_Group_union: null group passed in\n");
  64. abort();
  65. }
  66. if (group1==MPI_GROUP_ONE || group2==MPI_GROUP_ONE)
  67. *newgroup=MPI_GROUP_ONE;
  68. else
  69. *newgroup=MPI_GROUP_EMPTY;
  70. return(MPI_SUCCESS);
  71. }
  72. /*********/
  73. FC_FUNC( mpi_group_intersection, MPI_GROUP_INTERSECTION )
  74. (int *group1, int *group2, int *newgroup, int *ierror)
  75. {
  76. *ierror= MPI_Group_intersection(*group1,*group2,newgroup);
  77. }
  78. int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
  79. MPI_Group *newgroup)
  80. {
  81. if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
  82. {
  83. fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
  84. abort();
  85. }
  86. if (group1==MPI_GROUP_ONE && group2==MPI_GROUP_ONE)
  87. *newgroup=MPI_GROUP_ONE;
  88. else
  89. *newgroup=MPI_GROUP_EMPTY;
  90. return(MPI_SUCCESS);
  91. }
  92. /*********/
  93. FC_FUNC( mpi_group_difference, MPI_GROUP_DIFFERENCE )
  94. (int *group1, int *group2, int *newgroup, int *ierror)
  95. {
  96. *ierror= MPI_Group_difference(*group1,*group2,newgroup);
  97. }
  98. int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
  99. MPI_Group *newgroup)
  100. {
  101. if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
  102. {
  103. fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
  104. abort();
  105. }
  106. if (group1==MPI_GROUP_EMPTY || group2==MPI_GROUP_ONE)
  107. *newgroup=MPI_GROUP_EMPTY;
  108. else
  109. *newgroup=MPI_GROUP_ONE;
  110. return(MPI_SUCCESS);
  111. }
  112. /*********/
  113. FC_FUNC( mpi_group_free, MPI_GROUP_FREE )(int *group, int *ierror)
  114. {
  115. *ierror= MPI_Group_free(group);
  116. }
  117. int MPI_Group_free(MPI_Group *group)
  118. {
  119. *group= MPI_GROUP_NULL;
  120. return(MPI_SUCCESS);
  121. }
  122. /*********/
  123. FC_FUNC( mpi_group_translate_ranks, MPI_GROUP_TRANSLATE_RANKS )
  124. ( int *group1, int *n, int *ranks1,
  125. int *group2, int *ranks2, int *ierror)
  126. {
  127. *ierror= MPI_Group_translate_ranks(*group1,*n,ranks1,*group2,ranks2);
  128. }
  129. int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
  130. MPI_Group group2, int *ranks2)
  131. {
  132. int i;
  133. if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
  134. {
  135. fprintf(stderr,"MPI_Group_translate_ranks: null group passed in\n");
  136. abort();
  137. }
  138. if (n==0)
  139. return(MPI_SUCCESS);
  140. if (group1==MPI_GROUP_EMPTY)
  141. {
  142. fprintf(stderr,"MPI_Group_translate_ranks: empty input group\n");
  143. abort();
  144. }
  145. for (i=0; i<n; i++)
  146. {
  147. if (ranks1[i]!=0)
  148. {
  149. fprintf(stderr,"MPI_Group_translate_ranks: bad input rank: %d\n",
  150. ranks1[i]);
  151. abort();
  152. }
  153. if (group2!=MPI_GROUP_EMPTY)
  154. ranks2[i]=ranks1[i];
  155. else
  156. ranks2[i]=MPI_UNDEFINED;
  157. }
  158. return(MPI_SUCCESS);
  159. }
  160. /*********/
  161. MPI_Group MPI_Group_f2c(MPI_Fint group)
  162. {
  163. return(group);
  164. }
  165. /*********/
  166. MPI_Fint MPI_Group_c2f(MPI_Group group)
  167. {
  168. return(group);
  169. }