Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Support for Fortran code in SMPI based on f2c, some perl and some dirty hacks.
[simgrid.git] / src / smpi / smpi_f77.c
1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5   * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "private.h"
8
9 extern int xargc;
10 extern char** xargv;
11
12 void* mpi_byte__             = &MPI_BYTE;
13 void* mpi_character__        = &MPI_CHAR;
14 void* mpi_logical__          = &MPI_INT;
15 void* mpi_integer__          = &MPI_INT;
16 void* mpi_integer1__         = &MPI_INT8_T;
17 void* mpi_integer2__         = &MPI_INT16_T;
18 void* mpi_integer4__         = &MPI_INT32_T;
19 void* mpi_integer8__         = &MPI_INT64_T;
20 void* mpi_real__             = &MPI_FLOAT;
21 void* mpi_real4__            = &MPI_FLOAT;
22 void* mpi_real8__            = &MPI_DOUBLE;
23 void* mpi_double_precision__ = &MPI_DOUBLE;
24 void* mpi_complex__          = &MPI_C_FLOAT_COMPLEX;
25 void* mpi_double_complex__   = &MPI_C_DOUBLE_COMPLEX;
26 void* mpi_2integer__         = &MPI_2INT;
27 void* mpi_logical1__         = &MPI_UINT8_T;
28 void* mpi_logical2__         = &MPI_UINT16_T;
29 void* mpi_logical4__         = &MPI_UINT32_T;
30 void* mpi_logical8__         = &MPI_UINT64_T;
31
32 void* mpi_comm_world__ = &MPI_COMM_WORLD;
33
34 void mpi_init__(int* ierr) {
35    /* smpif2c is responsible for generating a call with the final arguments */
36    *ierr = MPI_Init(NULL, NULL);
37 }
38
39 void mpi_finalize__(int* ierr) {
40    *ierr = MPI_Finalize();
41 }
42
43 void mpi_comm_rank__(MPI_Comm** comm, int* rank, int* ierr) {
44    /* Yes, you really get a MPI_Comm** here */
45    *ierr = MPI_Comm_rank(**comm, rank);
46 }
47
48 void mpi_comm_size__(MPI_Comm** comm, int* size, int* ierr) {
49    /* Yes, you really get a MPI_Comm** here */
50    *ierr = MPI_Comm_size(**comm, size);
51 }
52
53 double mpi_wtime__(void) {
54    return MPI_Wtime();
55 }
56
57 void mpi_send__(void* buf, int* count, MPI_Datatype** datatype, int* dst,
58                 int* tag, MPI_Comm** comm, int* ierr) {
59    *ierr = MPI_Send(buf, *count, **datatype, *dst, *tag, **comm);
60 }
61
62 void mpi_recv__(void* buf, int* count, MPI_Datatype** datatype, int* src,
63                 int* tag, MPI_Comm** comm, MPI_Status* status, int* ierr) {
64    *ierr = MPI_Recv(buf, *count, **datatype, *src, *tag, **comm, status);
65 }