xref: /petsc/src/sys/mpiuni/mpi.c (revision 89d949e22d93de971d3ed7d7fdc00f23508da20b)
1 /*
2       This provides a few of the MPI-uni functions that cannot be implemented
3     with C macros
4 */
5 #include <mpiuni/mpi.h>
6 #if !defined(__MPIUNI_H)
7 #error "Wrong mpi.h included! require mpi.h from MPIUNI"
8 #endif
9 #if !defined(PETSC_STDCALL)
10 #define PETSC_STDCALL
11 #endif
12 #include <petscsys.h>
13 
14 #define MPI_SUCCESS 0
15 #define MPI_FAILURE 1
16 
17 void *MPIUNI_TMP         = 0;
18 int  MPIUNI_DATASIZE[10] = {sizeof(int),sizeof(float),sizeof(double),2*sizeof(double),sizeof(char),2*sizeof(int),4*sizeof(double),4,8,2*sizeof(double)};
19 /*
20        With MPI Uni there are exactly four distinct communicators:
21     MPI_COMM_SELF, MPI_COMM_WORLD, and a MPI_Comm_dup() of each of these (duplicates of duplicates return the same communictor)
22 
23     MPI_COMM_SELF and MPI_COMM_WORLD are MPI_Comm_free() in MPI_Finalize() but in general with PETSc,
24      the other communicators are freed once the last PETSc object is freed (before MPI_Finalize()).
25 
26 */
27 #define MAX_ATTR 128
28 
29 typedef struct {
30   void *attribute_val;
31   int  active;
32 } MPI_Attr;
33 
34 typedef struct {
35   void                *extra_state;
36   MPI_Delete_function *del;
37 } MPI_Attr_keyval;
38 
39 static MPI_Attr_keyval attr_keyval[MAX_ATTR];
40 static MPI_Attr        attr[4][MAX_ATTR];
41 static int             num_attr = 1,mpi_tag_ub = 100000000;
42 
43 #if defined(__cplusplus)
44 extern "C" {
45 #endif
46 
47 /*
48    To avoid problems with prototypes to the system memcpy() it is duplicated here
49 */
50 int MPIUNI_Memcpy(void *a,const void *b,int n)
51 {
52   int  i;
53   char *aa= (char*)a;
54   char *bb= (char*)b;
55 
56   if (b == MPI_IN_PLACE) return 0;
57   for (i=0; i<n; i++) aa[i] = bb[i];
58   return 0;
59 }
60 
61 /*
62    Used to set the built-in MPI_TAG_UB attribute
63 */
64 static int Keyval_setup(void)
65 {
66   attr[MPI_COMM_WORLD-1][0].active        = 1;
67   attr[MPI_COMM_WORLD-1][0].attribute_val = &mpi_tag_ub;
68   attr[MPI_COMM_SELF-1][0].active         = 1;
69   attr[MPI_COMM_SELF-1][0].attribute_val  = &mpi_tag_ub;
70   return 0;
71 }
72 
73 int MPI_Keyval_create(MPI_Copy_function *copy_fn,MPI_Delete_function *delete_fn,int *keyval,void *extra_state)
74 {
75   if (num_attr >= MAX_ATTR) MPI_Abort(MPI_COMM_WORLD,1);
76 
77   attr_keyval[num_attr].extra_state = extra_state;
78   attr_keyval[num_attr].del         = delete_fn;
79   *keyval                           = num_attr++;
80   return 0;
81 }
82 
83 int MPI_Keyval_free(int *keyval)
84 {
85   attr_keyval[*keyval].extra_state = 0;
86   attr_keyval[*keyval].del         = 0;
87 
88   *keyval = 0;
89   return MPI_SUCCESS;
90 }
91 
92 int MPI_Attr_put(MPI_Comm comm,int keyval,void *attribute_val)
93 {
94   if (comm-1 < 0 || comm-1 > 3) return 1;
95   attr[comm-1][keyval].active        = 1;
96   attr[comm-1][keyval].attribute_val = attribute_val;
97   return MPI_SUCCESS;
98 }
99 
100 int MPI_Attr_delete(MPI_Comm comm,int keyval)
101 {
102   if (comm-1 < 0 || comm-1 > 3) return 1;
103   if (attr[comm-1][keyval].active && attr_keyval[keyval].del) {
104     void *save_attribute_val = attr[comm-1][keyval].attribute_val;
105     attr[comm-1][keyval].active        = 0;
106     attr[comm-1][keyval].attribute_val = 0;
107     (*(attr_keyval[keyval].del))(comm,keyval,save_attribute_val,attr_keyval[keyval].extra_state);
108   }
109   return MPI_SUCCESS;
110 }
111 
112 int MPI_Attr_get(MPI_Comm comm,int keyval,void *attribute_val,int *flag)
113 {
114   if (comm-1 < 0 || comm-1 > 3) return 1;
115   if (!keyval) Keyval_setup();
116   *flag                  = attr[comm-1][keyval].active;
117   *(void**)attribute_val = attr[comm-1][keyval].attribute_val;
118   return MPI_SUCCESS;
119 }
120 
121 static int dups[4] = {1,1,1,1};
122 int MPI_Comm_create(MPI_Comm comm,MPI_Group group,MPI_Comm *newcomm)
123 {
124   if (comm-1 < 0 || comm-1 > 3) return 1;
125   dups[comm-1]++;
126   *newcomm =  comm;
127   return MPI_SUCCESS;
128 }
129 
130 int MPI_Comm_dup(MPI_Comm comm,MPI_Comm *out)
131 {
132   if (comm-1 < 0 || comm-1 > 3) return 1;
133   if (comm == MPI_COMM_WORLD || comm == MPI_COMM_SELF) *out = comm + 2;
134   else {
135     *out = comm;
136     dups[comm-1]++;
137   }
138   return 0;
139 }
140 
141 int MPI_Comm_free(MPI_Comm *comm)
142 {
143   int i;
144 
145   if (*comm-1 < 0 || *comm-1 > 3) return 1;
146   if (dups[*comm-1] == 1) {
147     for (i=0; i<num_attr; i++) {
148       if (attr[*comm-1][i].active && attr_keyval[i].del) (*attr_keyval[i].del)(*comm,i,attr[*comm-1][i].attribute_val,attr_keyval[i].extra_state);
149       attr[*comm-1][i].active        = 0;
150       attr[*comm-1][i].attribute_val = 0;
151     }
152     dups[*comm-1] = 1;
153     *comm = 0;
154   } else if (dups[*comm-1] > 1) dups[*comm-1]--;
155   return MPI_SUCCESS;
156 }
157 
158 int MPI_Comm_size(MPI_Comm comm, int *size)
159 {
160   *size=1;
161   return MPI_SUCCESS;
162 }
163 
164 int MPI_Comm_rank(MPI_Comm comm, int *rank)
165 {
166   *rank=0;
167   return MPI_SUCCESS;
168 }
169 
170 int MPI_Abort(MPI_Comm comm,int errorcode)
171 {
172   abort();
173   return MPI_SUCCESS;
174 }
175 
176 /* --------------------------------------------------------------------------*/
177 
178 static int MPI_was_initialized = 0;
179 static int MPI_was_finalized   = 0;
180 
181 int MPI_Init(int *argc, char ***argv)
182 {
183   if (MPI_was_initialized) return 1;
184   if (MPI_was_finalized) return 1;
185   MPI_was_initialized = 1;
186   return 0;
187 }
188 
189 int MPI_Finalize(void)
190 {
191   MPI_Comm comm;
192   if (MPI_was_finalized) return 1;
193   if (!MPI_was_initialized) return 1;
194   comm = MPI_COMM_WORLD;
195   MPI_Comm_free(&comm);
196   comm = MPI_COMM_SELF;
197   MPI_Comm_free(&comm);
198   MPI_was_finalized = 1;
199   return 0;
200 }
201 
202 int MPI_Initialized(int *flag)
203 {
204   *flag = MPI_was_initialized;
205   return 0;
206 }
207 
208 int MPI_Finalized(int *flag)
209 {
210   *flag = MPI_was_finalized;
211   return 0;
212 }
213 
214 /* -------------------     Fortran versions of several routines ------------------ */
215 
216 #if defined(PETSC_HAVE_FORTRAN_CAPS)
217 #define mpi_init_             MPI_INIT
218 #define mpi_finalize_         MPI_FINALIZE
219 #define mpi_comm_size_        MPI_COMM_SIZE
220 #define mpi_comm_rank_        MPI_COMM_RANK
221 #define mpi_abort_            MPI_ABORT
222 #define mpi_reduce_           MPI_REDUCE
223 #define mpi_allreduce_        MPI_ALLREDUCE
224 #define mpi_barrier_          MPI_BARRIER
225 #define mpi_bcast_            MPI_BCAST
226 #define mpi_gather_           MPI_GATHER
227 #define mpi_allgather_        MPI_ALLGATHER
228 #define mpi_comm_split_       MPI_COMM_SPLIT
229 #define mpi_scan_             MPI_SCAN
230 #define mpi_send_             MPI_SEND
231 #define mpi_recv_             MPI_RECV
232 #define mpi_reduce_scatter_   MPI_REDUCE_SCATTER
233 #define mpi_irecv_            MPI_IRECV
234 #define mpi_isend_            MPI_ISEND
235 #define mpi_sendrecv_         MPI_SENDRECV
236 #define mpi_test_             MPI_TEST
237 #define mpi_waitall_          MPI_WAITALL
238 #define mpi_waitany_          MPI_WAITANY
239 #define mpi_allgatherv_       MPI_ALLGATHERV
240 #define mpi_alltoallv_        MPI_ALLTOALLV
241 #define mpi_comm_create_      MPI_COMM_CREATE
242 #define mpi_address_          MPI_ADDRESS
243 #define mpi_pack_             MPI_PACK
244 #define mpi_unpack_           MPI_UNPACK
245 #define mpi_pack_size_        MPI_PACK_SIZE
246 #define mpi_type_struct_      MPI_TYPE_STRUCT
247 #define mpi_type_commit_      MPI_TYPE_COMMIT
248 #define mpi_wtime_            MPI_WTIME
249 #define mpi_cancel_           MPI_CANCEL
250 #define mpi_comm_dup_         MPI_COMM_DUP
251 #define mpi_comm_free_        MPI_COMM_FREE
252 #define mpi_get_count_        MPI_GET_COUNT
253 #define mpi_get_processor_name_ MPI_GET_PROCESSOR_NAME
254 #define mpi_initialized_      MPI_INITIALIZED
255 #define mpi_iprobe_           MPI_IPROBE
256 #define mpi_probe_            MPI_PROBE
257 #define mpi_request_free_     MPI_REQUEST_FREE
258 #define mpi_ssend_            MPI_SSEND
259 #define mpi_wait_             MPI_WAIT
260 #define mpi_comm_group_       MPI_COMM_GROUP
261 #define mpi_exscan_           MPI_EXSCAN
262 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
263 #define mpi_init_             mpi_init
264 #define mpi_finalize_         mpi_finalize
265 #define mpi_comm_size_        mpi_comm_size
266 #define mpi_comm_rank_        mpi_comm_rank
267 #define mpi_abort_            mpi_abort
268 #define mpi_reduce_           mpi_reduce
269 #define mpi_allreduce_        mpi_allreduce
270 #define mpi_barrier_          mpi_barrier
271 #define mpi_bcast_            mpi_bcast
272 #define mpi_gather_           mpi_gather
273 #define mpi_allgather_        mpi_allgather
274 #define mpi_comm_split_       mpi_comm_split
275 #define mpi_scan_             mpi_scan
276 #define mpi_send_             mpi_send
277 #define mpi_recv_             mpi_recv
278 #define mpi_reduce_scatter_   mpi_reduce_scatter
279 #define mpi_irecv_            mpi_irecv
280 #define mpi_isend_            mpi_isend
281 #define mpi_sendrecv_         mpi_sendrecv
282 #define mpi_test_             mpi_test
283 #define mpi_waitall_          mpi_waitall
284 #define mpi_waitany_          mpi_waitany
285 #define mpi_allgatherv_       mpi_allgatherv
286 #define mpi_alltoallv_        mpi_alltoallv
287 #define mpi_comm_create_      mpi_comm_create
288 #define mpi_address_          mpi_address
289 #define mpi_pack_             mpi_pack
290 #define mpi_unpack_           mpi_unpack
291 #define mpi_pack_size_        mpi_pack_size
292 #define mpi_type_struct_      mpi_type_struct
293 #define mpi_type_commit_      mpi_type_commit
294 #define mpi_wtime_            mpi_wtime
295 #define mpi_cancel_           mpi_cancel
296 #define mpi_comm_dup_         mpi_comm_dup
297 #define mpi_comm_free_        mpi_comm_free
298 #define mpi_get_count_        mpi_get_count
299 #define mpi_get_processor_name_ mpi_get_processor_name
300 #define mpi_initialized_      mpi_initialized
301 #define mpi_iprobe_           mpi_iprobe
302 #define mpi_probe_            mpi_probe
303 #define mpi_request_free_     mpi_request_free
304 #define mpi_ssend_            mpi_ssend
305 #define mpi_wait_             mpi_wait
306 #define mpi_comm_group_       mpi_comm_group
307 #define mpi_exscan_           mpi_exscan
308 #endif
309 
310 #if defined(PETSC_HAVE_FORTRAN_UNDERSCORE_UNDERSCORE)
311 #define mpi_init_             mpi_init__
312 #define mpi_finalize_         mpi_finalize__
313 #define mpi_comm_size_        mpi_comm_size__
314 #define mpi_comm_rank_        mpi_comm_rank__
315 #define mpi_abort_            mpi_abort__
316 #define mpi_reduce_           mpi_reduce__
317 #define mpi_allreduce_        mpi_allreduce__
318 #define mpi_barrier_          mpi_barrier__
319 #define mpi_bcast_            mpi_bcast__
320 #define mpi_gather_           mpi_gather__
321 #define mpi_allgather_        mpi_allgather__
322 #define mpi_comm_split_       mpi_comm_split__
323 #define mpi_scan_             mpi_scan__
324 #define mpi_send_             mpi_send__
325 #define mpi_recv_             mpi_recv__
326 #define mpi_reduce_scatter_   mpi_reduce_scatter__
327 #define mpi_irecv_            mpi_irecv__
328 #define mpi_isend_            mpi_isend__
329 #define mpi_sendrecv_         mpi_sendrecv__
330 #define mpi_test_             mpi_test__
331 #define mpi_waitall_          mpi_waitall__
332 #define mpi_waitany_          mpi_waitany__
333 #define mpi_allgatherv_       mpi_allgatherv__
334 #define mpi_alltoallv_        mpi_alltoallv__
335 #define mpi_comm_create_      mpi_comm_create__
336 #define mpi_address_          mpi_address__
337 #define mpi_pack_             mpi_pack__
338 #define mpi_unpack_           mpi_unpack__
339 #define mpi_pack_size_        mpi_pack_size__
340 #define mpi_type_struct_      mpi_type_struct__
341 #define mpi_type_commit_      mpi_type_commit__
342 #define mpi_wtime_            mpi_wtime__
343 #define mpi_cancel_           mpi_cancel__
344 #define mpi_comm_dup_         mpi_comm_dup__
345 #define mpi_comm_free_        mpi_comm_free__
346 #define mpi_get_count_        mpi_get_count__
347 #define mpi_get_processor_name_ mpi_get_processor_name__
348 #define mpi_initialized_      mpi_initialized__
349 #define mpi_iprobe_           mpi_iprobe__
350 #define mpi_probe_            mpi_probe__
351 #define mpi_request_free_     mpi_request_free__
352 #define mpi_ssend_            mpi_ssend__
353 #define mpi_wait_             mpi_wait__
354 #define mpi_comm_group_       mpi_comm_group__
355 #define mpi_exscan_           mpi_exscan__
356 #endif
357 
358 
359 /* Do not build fortran interface if MPI namespace colision is to be avoided */
360 #if !defined(MPIUNI_AVOID_MPI_NAMESPACE)
361 
362 PETSC_EXTERN void PETSC_STDCALL   mpi_init_(int *ierr)
363 {
364   *ierr = MPI_Init((int*)0, (char***)0);
365 }
366 
367 PETSC_EXTERN void PETSC_STDCALL   mpi_finalize_(int *ierr)
368 {
369   *ierr = MPI_Finalize();
370 }
371 
372 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_size_(MPI_Comm *comm,int *size,int *ierr)
373 {
374   *size = 1;
375   *ierr = 0;
376 }
377 
378 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_rank_(MPI_Comm *comm,int *rank,int *ierr)
379 {
380   *rank=0;
381   *ierr=MPI_SUCCESS;
382 }
383 
384 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_split_(MPI_Comm *comm,int *color,int *key, MPI_Comm *newcomm, int *ierr)
385 {
386   *newcomm = *comm;
387   *ierr    =MPI_SUCCESS;
388 }
389 
390 PETSC_EXTERN void PETSC_STDCALL  mpi_abort_(MPI_Comm *comm,int *errorcode,int *ierr)
391 {
392   abort();
393   *ierr = MPI_SUCCESS;
394 }
395 
396 PETSC_EXTERN void PETSC_STDCALL  mpi_reduce_(void *sendbuf,void *recvbuf,int *count,int *datatype,int *op,int *root,int *comm,int *ierr)
397 {
398   MPI_Reduce(sendbuf,recvbuf,*count,*datatype,*op,*root,*comm);
399   *ierr = MPI_SUCCESS;
400 }
401 
402 PETSC_EXTERN void PETSC_STDCALL  mpi_allreduce_(void *sendbuf,void *recvbuf,int *count,int *datatype,int *op,int *comm,int *ierr)
403 {
404   MPI_Allreduce(sendbuf,recvbuf,*count,*datatype,*op,*comm);
405   *ierr = MPI_SUCCESS;
406 }
407 
408 PETSC_EXTERN void PETSC_STDCALL  mpi_barrier_(MPI_Comm *comm,int *ierr)
409 {
410   *ierr = MPI_SUCCESS;
411 }
412 
413 PETSC_EXTERN void PETSC_STDCALL  mpi_bcast_(void *buf,int *count,int *datatype,int *root,int *comm,int *ierr)
414 {
415   *ierr = MPI_SUCCESS;
416 }
417 
418 
419 PETSC_EXTERN void PETSC_STDCALL  mpi_gather_(void *sendbuf,int *scount,int *sdatatype, void *recvbuf, int *rcount, int *rdatatype, int *root,int *comm,int *ierr)
420 {
421   MPI_Gather(sendbuf,*scount,*sdatatype,recvbuf,rcount,rdatatype,*root,*comm);
422   *ierr = MPI_SUCCESS;
423 }
424 
425 PETSC_EXTERN void PETSC_STDCALL  mpi_allgather_(void *sendbuf,int *scount,int *sdatatype, void *recvbuf, int *rcount, int *rdatatype,int *comm,int *ierr)
426 {
427   MPI_Allgather(sendbuf,*scount,*sdatatype,recvbuf,rcount,rdatatype,*comm);
428 }
429 
430 PETSC_EXTERN void PETSC_STDCALL  mpi_scan_(void *sendbuf,void *recvbuf,int *count,int *datatype,int *op,int *comm,int *ierr)
431 {
432   MPIUNI_Memcpy(recvbuf,sendbuf,(*count)*MPIUNI_DATASIZE[*datatype]);
433   *ierr = MPI_SUCCESS;
434 }
435 
436 PETSC_EXTERN void PETSC_STDCALL  mpi_send_(void *buf,int *count,int *datatype,int *dest,int *tag,int *comm,int *ierr)
437 {
438   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
439 }
440 
441 PETSC_EXTERN void PETSC_STDCALL  mpi_recv_(void *buf,int *count,int *datatype,int *source,int *tag,int *comm,int status,int *ierr)
442 {
443   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
444 }
445 
446 PETSC_EXTERN void PETSC_STDCALL  mpi_reduce_scatter_(void *sendbuf,void *recvbuf,int *recvcounts,int *datatype,int *op,int *comm,int *ierr)
447 {
448   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
449 }
450 
451 PETSC_EXTERN void PETSC_STDCALL  mpi_irecv_(void *buf,int *count, int *datatype, int *source, int *tag, int *comm, int *request, int *ierr)
452 {
453   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
454 }
455 
456 PETSC_EXTERN void PETSC_STDCALL  mpi_isend_(void *buf,int *count,int *datatype,int *dest,int *tag,int *comm,int *request, int *ierr)
457 {
458   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
459 }
460 
461 PETSC_EXTERN void PETSC_STDCALL  mpi_sendrecv_(void *sendbuf,int *sendcount,int *sendtype,int *dest,int *sendtag,void *recvbuf,int *recvcount,int *recvtype,int *source,int *recvtag,int *comm,int *status,int *ierr)
462 {
463   MPIUNI_Memcpy(recvbuf,sendbuf,(*sendcount)*MPIUNI_DATASIZE[*sendtype]);
464   *ierr = MPI_SUCCESS;
465 }
466 
467 PETSC_EXTERN void PETSC_STDCALL  mpi_test_(int *request,int *flag,int *status,int *ierr)
468 {
469   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
470 }
471 
472 PETSC_EXTERN void PETSC_STDCALL  mpi_waitall_(int *count,int *array_of_requests,int *array_of_statuses,int *ierr)
473 {
474   *ierr = MPI_SUCCESS;
475 }
476 
477 PETSC_EXTERN void PETSC_STDCALL  mpi_waitany_(int *count,int *array_of_requests,int * index, int *status,int *ierr)
478 {
479   *ierr = MPI_SUCCESS;
480 }
481 
482 PETSC_EXTERN void PETSC_STDCALL  mpi_allgatherv_(void *sendbuf,int *sendcount,int *sendtype,void *recvbuf,int *recvcounts,int *displs,int *recvtype,int *comm,int *ierr)
483 {
484   MPI_Allgatherv(sendbuf,*sendcount,*sendtype,recvbuf,recvcounts,displs,*recvtype,*comm);
485   *ierr = MPI_SUCCESS;
486 }
487 
488 PETSC_EXTERN void PETSC_STDCALL  mpi_alltoallv_(void *sendbuf,int *sendcounts,int *sdispls,int *sendtype,void *recvbuf,int *recvcounts,int *rdispls,int *recvtype,int *comm,int *ierr)
489 {
490   MPI_Alltoallv(sendbuf,sendcounts,sdispls,*sendtype,recvbuf,recvcounts,rdispls,*recvtype,*comm);
491   *ierr = MPI_SUCCESS;
492 }
493 
494 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_create_(int *comm,int *group,int *newcomm,int *ierr)
495 {
496   *newcomm =  *comm;
497   *ierr    = MPI_SUCCESS;
498 }
499 
500 PETSC_EXTERN void PETSC_STDCALL  mpi_address_(void *location,MPIUNI_INTPTR *address,int *ierr)
501 {
502   *address =  (MPIUNI_INTPTR) location;
503   *ierr    = MPI_SUCCESS;
504 }
505 
506 PETSC_EXTERN void PETSC_STDCALL  mpi_pack_(void *inbuf,int *incount,int *datatype,void *outbuf,int *outsize,int *position,int *comm,int *ierr)
507 {
508   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
509 }
510 
511 PETSC_EXTERN void PETSC_STDCALL  mpi_unpack_(void *inbuf,int *insize,int *position,void *outbuf,int *outcount,int *datatype,int *comm,int *ierr)
512 {
513   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
514 }
515 
516 PETSC_EXTERN void PETSC_STDCALL  mpi_pack_size_(int *incount,int *datatype,int *comm,int *size,int *ierr)
517 {
518   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
519 }
520 
521 PETSC_EXTERN void PETSC_STDCALL  mpi_type_struct_(int *count,int *array_of_blocklengths,int * array_of_displaments,int *array_of_types,int *newtype,int *ierr)
522 {
523   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
524 }
525 
526 PETSC_EXTERN void PETSC_STDCALL  mpi_type_commit_(int *datatype,int *ierr)
527 {
528   *ierr = MPI_SUCCESS;
529 }
530 
531 double PETSC_STDCALL mpi_wtime_(void)
532 {
533   return 0.0;
534 }
535 
536 PETSC_EXTERN void PETSC_STDCALL  mpi_cancel_(int *request,int *ierr)
537 {
538   *ierr = MPI_SUCCESS;
539 }
540 
541 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_dup_(int *comm,int *out,int *ierr)
542 {
543   *out  = *comm;
544   *ierr = MPI_SUCCESS;
545 }
546 
547 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_free_(int *comm,int *ierr)
548 {
549   *ierr = MPI_SUCCESS;
550 }
551 
552 PETSC_EXTERN void PETSC_STDCALL  mpi_get_count_(int *status,int *datatype,int *count,int *ierr)
553 {
554   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
555 }
556 
557 /* duplicate from fortranimpl.h */
558 #if defined(PETSC_HAVE_FORTRAN_MIXED_STR_ARG)
559 #define PETSC_MIXED_LEN(len) ,int len
560 #define PETSC_END_LEN(len)
561 #else
562 #define PETSC_MIXED_LEN(len)
563 #define PETSC_END_LEN(len)   ,int len
564 #endif
565 
566 PETSC_EXTERN void PETSC_STDCALL  mpi_get_processor_name_(char *name PETSC_MIXED_LEN(len),int *result_len,int *ierr PETSC_END_LEN(len))
567 {
568   MPIUNI_Memcpy(name,"localhost",9*sizeof(char));
569   *result_len = 9;
570   *ierr       = MPI_SUCCESS;
571 }
572 
573 PETSC_EXTERN void PETSC_STDCALL  mpi_initialized_(int *flag,int *ierr)
574 {
575   *flag = MPI_was_initialized;
576   *ierr = MPI_SUCCESS;
577 }
578 
579 PETSC_EXTERN void PETSC_STDCALL  mpi_iprobe_(int *source,int *tag,int *comm,int *glag,int *status,int *ierr)
580 {
581   *ierr = MPI_SUCCESS;
582 }
583 
584 PETSC_EXTERN void PETSC_STDCALL  mpi_probe_(int *source,int *tag,int *comm,int *flag,int *status,int *ierr)
585 {
586   *ierr = MPI_SUCCESS;
587 }
588 
589 PETSC_EXTERN void PETSC_STDCALL  mpi_request_free_(int *request,int *ierr)
590 {
591   *ierr = MPI_SUCCESS;
592 }
593 
594 PETSC_EXTERN void PETSC_STDCALL  mpi_ssend_(void *buf,int *count,int *datatype,int *dest,int *tag,int *comm,int *ierr)
595 {
596   *ierr = MPI_Abort(MPI_COMM_WORLD,0);
597 }
598 
599 PETSC_EXTERN void PETSC_STDCALL  mpi_wait_(int *request,int *status,int *ierr)
600 {
601   *ierr = MPI_SUCCESS;
602 }
603 
604 PETSC_EXTERN void PETSC_STDCALL  mpi_comm_group_(int *comm,int *group,int *ierr)
605 {
606   *ierr = MPI_SUCCESS;
607 }
608 
609 PETSC_EXTERN void PETSC_STDCALL  mpi_exscan_(void *sendbuf,void *recvbuf,int *count,int *datatype,int *op,int *comm,int *ierr)
610 {
611   *ierr = MPI_SUCCESS;
612 }
613 
614 #endif /* MPIUNI_AVOID_MPI_NAMESPACE */
615 
616 #if defined(__cplusplus)
617 }
618 #endif
619