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

Last change on this file since 4775 was 4775, checked in by aclsce, 5 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: 2.4 KB
Line 
1#include "mpiP.h"
2
3
4/*
5 * COMPLETION
6 */
7
8
9
10FC_FUNC( mpi_test , MPI_TEST)(int *request, int *flag, int *status,
11                                int *ierror)
12{
13  *ierror=MPI_Test( (void *)request ,flag,(MPI_Status *)status);
14}
15
16
17
18int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status)
19{
20  Req *req;
21
22  if (*request==MPI_REQUEST_NULL)
23    {
24      status->MPI_TAG= MPI_ANY_TAG;
25      status->MPI_SOURCE= MPI_ANY_SOURCE;
26      *flag=1;
27      return(MPI_SUCCESS);
28    }
29
30
31  req=mpi_handle_to_ptr(*request);
32
33  *flag=req->complete;
34
35  if (*flag)
36    {
37      status->MPI_SOURCE= req->source;
38      status->MPI_TAG= req->tag;
39
40      mpi_free_handle(*request);
41      *request=MPI_REQUEST_NULL;
42    }
43
44  return(MPI_SUCCESS);
45}
46
47
48
49FC_FUNC( mpi_wait , MPI_WAIT )(int *request, int *status, int *ierror)
50{
51  *ierror=MPI_Wait( (void *)request, (MPI_Status *)status );
52}
53
54
55
56int MPI_Wait(MPI_Request *request, MPI_Status *status)
57{
58  int flag;
59
60  MPI_Test(request,&flag,status);
61
62  if (!flag)
63    {
64      fprintf(stderr,"MPI_Wait: request not complete, deadlock\n");
65      abort();
66    }
67
68  return(MPI_SUCCESS);
69}
70
71
72/*********/
73
74
75FC_FUNC( mpi_waitany , MPI_WAITANY )(int *count, int *requests,
76                                       int *index, int *status, int *ierror)
77{
78
79  *ierror=MPI_Waitany(*count, (void *)requests,index,(MPI_Status *)status);
80}
81
82
83
84int MPI_Waitany(int count, MPI_Request *array_of_requests,
85                int *index, MPI_Status *status)
86{
87  int i;
88  int flag;
89
90  for (i=0; i<count; i++)
91    {
92      MPI_Test(&array_of_requests[i],&flag,status);
93     
94      if (flag)
95        return(MPI_SUCCESS);
96    }
97
98  /* none are completed */
99
100  fprintf(stderr,"MPI_Waitany: no requests complete, deadlock\n");
101  abort();
102}
103
104
105/*********/
106
107
108FC_FUNC( mpi_waitall , MPI_WAITALL )(int *count, int *array_of_requests,
109                                       int *array_of_statuses, int *ierror)
110{
111  *ierror=MPI_Waitall(*count, (void *)array_of_requests,
112                      (MPI_Status *)array_of_statuses);
113
114}
115
116
117
118int MPI_Waitall(int count, MPI_Request *array_of_requests,
119                MPI_Status *array_of_statuses)
120{
121  int i;
122  int flag;
123
124  for (i=0; i<count; i++)
125    {
126      MPI_Test(&array_of_requests[i],&flag,&array_of_statuses[i]);
127
128      if (!flag)
129        {
130          fprintf(stderr,"MPI_Waitall: request not complete, deadlock\n");
131          abort();
132        }
133    }
134
135  return(MPI_SUCCESS);
136}
137
138
139
140/*********/
141
142
143MPI_Request MPI_Request_f2c(MPI_Fint request)
144{
145  return(request);
146}
147
148
149/*********/
150
151
152
153MPI_Fint MPI_Request_c2f(MPI_Request request)
154{
155  return(request);
156}
Note: See TracBrowser for help on using the repository browser.