1 /*
2 COPYRIGHT
3 
4 The following is a notice of limited availability of the code, and disclaimer
5 which must be included in the prologue of the code and in all source listings
6 of the code.
7 
8 (C) COPYRIGHT 2008 University of Chicago
9 
10 Permission is hereby granted to use, reproduce, prepare derivative works, and
11 to redistribute to others. This software was authored by:
12 
13 D. Levine
14 Mathematics and Computer Science Division
15 Argonne National Laboratory Group
16 
17 with programming assistance of participants in Argonne National
18 Laboratory's SERS program.
19 
20 GOVERNMENT LICENSE
21 
22 Portions of this material resulted from work developed under a
23 U.S. Government Contract and are subject to the following license: the
24 Government is granted for itself and others acting on its behalf a paid-up,
25 nonexclusive, irrevocable worldwide license in this computer software to
26 reproduce, prepare derivative works, and perform publicly and display
27 publicly.
28 
29 DISCLAIMER
30 
31 This computer code material was prepared, in part, as an account of work
32 sponsored by an agency of the United States Government. Neither the United
33 States, nor the University of Chicago, nor any of their employees, makes any
34 warranty express or implied, or assumes any legal liability or responsibility
35 for the accuracy, completeness, or usefulness of any information, apparatus,
36 product, or process disclosed, or represents that its use would not infringe
37 privately owned rights.
38 */
39 
40 /******************************************************************************
41 *     FILE: mpi_stub.c:  MPI stubs needed for PGAPack operation without
42 *                        linking with a real MPI.
43 *
44 *     Authors: Brian P. Walenz
45 ******************************************************************************/
46 
47 #include "pgapack.h"
48 
49 /*
50  *
51  * In the object files created by gcc the names of functions are the same as
52  * in the corresponding source files. fort77 and g77 append an underscore to
53  * each name when creating the object files. To make it possible to call
54  * the functions with the same name in C and fortran, the fortran versions
55  * in pgapack have an additional underscore.
56  *
57  * This works perfectly well when the function name does not contain one or
58  * more underscores. In this case fort77 and g77 append two underscores.
59  *
60  * The following block of defines was added to take care of that.
61  *
62  * Andreas Franzen <anfra@debian.org>, 24 Sep 1998
63  *
64  */
65 
66 #define mpi_address_      mpi_address__
67 #define mpi_bcast_        mpi_bcast__
68 #define mpi_comm_dup_     mpi_comm_dup__
69 #define mpi_comm_free_    mpi_comm_free__
70 #define mpi_comm_rank_    mpi_comm_rank__
71 #define mpi_comm_size_    mpi_comm_size__
72 #define mpi_finalize_     mpi_finalize__
73 #define mpi_init_         mpi_init__
74 #define mpi_initialized_  mpi_initialized__
75 #define mpi_probe_        mpi_probe__
76 #define mpi_send_         mpi_send__
77 #define mpi_recv_         mpi_recv__
78 #define mpi_sendrecv_     mpi_sendrecv__
79 #define mpi_type_commit_  mpi_type_commit__
80 #define mpi_type_free_    mpi_type_free__
81 #define mpi_type_struct_  mpi_type_struct__
82 
83 /*
84 #if defined(FORTRANCAP)
85 #define mpi_address_      MPI_ADDRESS
86 #define mpi_bcast_        MPI_BCAST
87 #define mpi_comm_dup_     MPI_COMM_DUP
88 #define mpi_comm_free_    MPI_COMM_FREE
89 #define mpi_comm_rank_    MPI_COMM_RANK
90 #define mpi_comm_size_    MPI_COMM_SIZE
91 #define mpi_finalize_     MPI_FINALIZE
92 #define mpi_init_         MPI_INIT
93 #define mpi_initialized_  MPI_INITIALIZED
94 #define mpi_probe_        MPI_PROBE
95 #define mpi_send_         MPI_SEND
96 #define mpi_recv_         MPI_RECV
97 #define mpi_sendrecv_     MPI_SENDRECV
98 #define mpi_type_commit_  MPI_TYPE_COMMIT
99 #define mpi_type_free_    MPI_TYPE_FREE
100 #define mpi_type_struct_  MPI_TYPE_STRUCT
101 #elif !defined(FORTRANUNDERSCORE)
102 #define mpi_address_      mpi_address
103 #define mpi_bcast_        mpi_bcast
104 #define mpi_comm_dup_     mpi_comm_dup
105 #define mpi_comm_free_    mpi_comm_free
106 #define mpi_comm_rank_    mpi_comm_rank
107 #define mpi_comm_size_    mpi_comm_size
108 #define mpi_finalize_     mpi_finalize
109 #define mpi_init_         mpi_init
110 #define mpi_initialized_  mpi_initialized
111 #define mpi_probe_        mpi_probe
112 #define mpi_send_         mpi_send
113 #define mpi_recv_         mpi_recv
114 #define mpi_sendrecv_     mpi_sendrecv
115 #define mpi_type_commit_  mpi_type_commit
116 #define mpi_type_free_    mpi_type_free
117 #define mpi_type_struct_  mpi_type_struct
118 #endif
119 */
120 
121 
122 /*  Places the address of "location" into "address"
123  *  In FORTRAN, does not return anything.
124  */
MPI_Address(void * location,MPI_Aint * address)125 int MPI_Address(void *location, MPI_Aint *address) {
126     *address = (MPI_Aint)NULL;
127     return(0);
128 }
129 
130 
131 /*  Broadcast "buf" to all processes.
132  *  FORTRAN adds integer ierror to the end of the parameters.
133  */
MPI_Bcast(void * buf,int count,MPI_Datatype datatype,int root,MPI_Comm comm)134 int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) {
135     return(0);
136 }
137 
138 
139 /*  Duplicates communicator "comm" into "newcomm"
140  *  FORTRAN has a third parameter, integer ie, and does not return anything.
141  */
MPI_Comm_dup(MPI_Comm comm,MPI_Comm * newcomm)142 int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm) {
143     return(0);
144 }
145 
146 
147 /*  Frees a communicator.   */
MPI_Comm_free(MPI_Comm * comm)148 int MPI_Comm_free(MPI_Comm *comm) {
149     return(0);
150 }
151 
152 
153 /*  Returns the rank of the current process in rank.  We return
154  *  0 -- we are the master.
155  */
MPI_Comm_rank(MPI_Comm comm,int * rank)156 int MPI_Comm_rank(MPI_Comm comm, int *rank) {
157     *rank = 0;
158     return(0);
159 }
160 
161 
162 /*  Returns the number of processors that are in communicator comm
163  *  in size.  Always 1.
164  */
MPI_Comm_size(MPI_Comm comm,int * size)165 int MPI_Comm_size(MPI_Comm comm, int *size) {
166     *size = 1;
167     return(0);
168 }
169 
170 /*  Finalizes MPI.  */
MPI_Finalize(void)171 int MPI_Finalize(void) {
172     return(0);
173 }
174 
175 
176 /*  Initializes MPI.
177  *  Ideally, we should parse the command-line and remove MPI arguments.
178  */
MPI_Init(int * argc,char *** argv)179 int MPI_Init(int *argc, char ***argv) {
180     return(0);
181 }
182 
183 
184 /*  Returns 1 in flag if MPI is already running.  It is.  */
MPI_Initialized(int * flag)185 int MPI_Initialized(int *flag) {
186     *flag = 1;
187     return(0);
188 }
189 
190 
191 /*  Waits for messages to us with tag "tag".  Sets status->MPI_SOURCE to the
192  *  source of the message, status->MPI_TAG to the tag, and status->MPI_ERROR
193  *  to 0.
194  */
MPI_Probe(int source,int tag,MPI_Comm comm,MPI_Status * status)195 int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status) {
196     status->MPI_SOURCE = source;
197     status->MPI_TAG    = tag;
198     status->MPI_ERROR  = 0;
199     return(0);
200 }
201 
202 
203 /*  Send a message to a process.  */
MPI_Send(void * buf,int count,MPI_Datatype datatype,int dest,int tag,MPI_Comm comm)204 int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
205     return(0);
206 }
207 
208 
209 /*  Receive a message from a source. */
MPI_Recv(void * buf,int count,MPI_Datatype datatype,int source,int tag,MPI_Comm comm,MPI_Status * status)210 int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) {
211     status->MPI_SOURCE = source;
212     status->MPI_TAG    = tag;
213     status->MPI_ERROR  = 0;
214     return(0);
215 }
216 
217 
MPI_Sendrecv(void * sendbuf,int sendcount,MPI_Datatype sendtype,int dest,int sendtag,void * recvbuf,int recvcount,MPI_Datatype recvtype,int source,int recvtag,MPI_Comm comm,MPI_Status * status)218 int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
219                  int dest, int sendtag, void *recvbuf, int recvcount,
220                   MPI_Datatype recvtype, int source, int recvtag,
221                   MPI_Comm comm, MPI_Status *status) {
222     status->MPI_SOURCE = source;
223     status->MPI_TAG    = recvtag;
224     status->MPI_ERROR  = 0;
225     return(0);
226 }
227 
228 
MPI_Type_commit(MPI_Datatype * datatype)229 int MPI_Type_commit(MPI_Datatype *datatype) {
230     return(0);
231 }
232 
233 
MPI_Type_free(MPI_Datatype * datatype)234 int MPI_Type_free(MPI_Datatype *datatype) {
235     return(0);
236 }
237 
238 
MPI_Type_struct(int count,int * array_of_blocklengths,MPI_Aint * array_of_displacements,MPI_Datatype * array_of_types,MPI_Datatype * newtype)239 int MPI_Type_struct(int count, int *array_of_blocklengths,
240                     MPI_Aint *array_of_displacements,
241                     MPI_Datatype *array_of_types, MPI_Datatype *newtype) {
242     return(0);
243 }
244 
245 
246 /*  FORTRAN versions of some of the above functions.
247  *  Most of these operate the same as above, we just need to make sure that
248  *  they are linked in properly, see f2c.c for details.
249  */
mpi_address_(void ** location,MPI_Aint * address)250 void mpi_address_(void **location, MPI_Aint *address) {
251     *address = (MPI_Aint)NULL;
252 }
253 
mpi_bcast_(void ** n,int * com,MPI_Datatype * dt,int * r,MPI_Comm * c,int * ie)254 void mpi_bcast_(void **n, int *com, MPI_Datatype *dt, int *r, MPI_Comm *c, int *ie) {
255     *ie = 0;
256 }
257 
mpi_comm_dup_(MPI_Comm * comm,MPI_Comm ** newcomm,int * ie)258 void mpi_comm_dup_(MPI_Comm *comm, MPI_Comm **newcomm, int *ie) {
259     *ie = 0;
260 }
261 
mpi_comm_free_(MPI_Comm ** comm,int * ie)262 void mpi_comm_free_(MPI_Comm **comm, int *ie) {
263     *ie = 0;
264 }
265 
mpi_comm_rank_(MPI_Comm * comm,int * rank,int * ie)266 void mpi_comm_rank_(MPI_Comm *comm, int *rank, int *ie) {
267     *rank = 0;
268     *ie = 0;
269 }
270 
mpi_comm_size_(MPI_Comm * comm,int * size,int * ie)271 void mpi_comm_size_(MPI_Comm *comm, int *size, int *ie) {
272     *size = 1;
273     *ie = 0;
274 }
275 
mpi_finalize_(int * ie)276 void mpi_finalize_(int *ie) {
277     *ie = 0;
278 }
279 
mpi_init_(int * ie)280 void mpi_init_(int *ie) {
281     *ie = 0;
282 }
283 
mpi_initialized_(int * flag,int * ie)284 void mpi_initialized_(int *flag, int *ie) {
285     *flag = 1;
286     *ie = 0;
287 }
288 
mpi_probe_(int * source,int * tag,MPI_Comm * comm,MPI_Status * status,int * ie)289 void mpi_probe_(int *source, int *tag, MPI_Comm *comm, MPI_Status *status,
290                int *ie) {
291     status->MPI_SOURCE = *source;
292     status->MPI_TAG    = *tag;
293     status->MPI_ERROR  = 0;
294     *ie = 0;
295 }
296 
mpi_send_(void * buf,int * count,MPI_Datatype * datatype,int * dest,int * tag,MPI_Comm * comm,int * ie)297 void mpi_send_(void *buf, int *count, MPI_Datatype *datatype, int *dest,
298               int *tag, MPI_Comm *comm, int *ie) {
299     *ie = 0;
300 }
301 
302 
mpi_recv_(void * buf,int * count,MPI_Datatype * datatype,int * source,int * tag,MPI_Comm * comm,MPI_Status * status,int * ie)303 void mpi_recv_(void *buf, int *count, MPI_Datatype *datatype, int *source,
304               int *tag, MPI_Comm *comm, MPI_Status *status, int *ie) {
305     status->MPI_SOURCE = *source;
306     status->MPI_TAG    = *tag;
307     status->MPI_ERROR  = 0;
308     *ie = 0;
309 }
310 
311 
mpi_sendrecv_(void * sendbuf,int * sendcount,MPI_Datatype * sendtype,int * dest,int * sendtag,void * recvbuf,int * recvcount,MPI_Datatype * recvtype,int * source,int * recvtag,MPI_Comm * comm,MPI_Status * status,int * ie)312 void mpi_sendrecv_(void *sendbuf, int *sendcount, MPI_Datatype *sendtype,
313                   int *dest, int *sendtag, void *recvbuf, int *recvcount,
314                   MPI_Datatype *recvtype, int *source, int *recvtag,
315                   MPI_Comm *comm, MPI_Status *status, int *ie) {
316     status->MPI_SOURCE = *source;
317     status->MPI_TAG    = *recvtag;
318     status->MPI_ERROR  = 0;
319     *ie = 0;
320 }
321 
mpi_type_commit_(MPI_Datatype ** datatype,int * ie)322 void mpi_type_commit_(MPI_Datatype **datatype, int *ie) {
323     *ie = 0;
324 }
325 
mpi_type_free_(MPI_Datatype ** datatype,int * ie)326 void mpi_type_free_(MPI_Datatype **datatype, int *ie) {
327     *ie = 0;
328 }
329 
330 
mpi_type_struct_(int * count,int ** array_of_blocklengths,MPI_Aint ** array_of_displacements,MPI_Datatype ** array_of_types,MPI_Datatype ** newtype,int * ie)331 void mpi_type_struct_(int *count, int **array_of_blocklengths,
332                     MPI_Aint **array_of_displacements,
333                     MPI_Datatype **array_of_types, MPI_Datatype **newtype, int *ie) {
334     *ie = 0;
335 }
336