123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- #include "mpiP.h"
- /*
- * Communicators
- *
- */
- MPI_Comm mpi_comm_new(void)
- {
- MPI_Comm chandle;
- Comm *cptr;
- static int num=0;
- mpi_alloc_handle(&chandle,(void **) &cptr);
- cptr->sendlist=AP_list_new();
- cptr->recvlist=AP_list_new();
- cptr->num=num++;
- return(chandle);
- }
- /*********/
- FC_FUNC( mpi_comm_free , MPI_COMM_FREE )(int *comm, int *ierror)
- {
- *ierror=MPI_Comm_free(comm);
- }
- /*
- * MPI_Comm_free()
- *
- * Note: will NOT free any pending MPI_Request handles
- * that are allocated... correct user code should have
- * already done a Wait or Test to free them.
- *
- */
- int MPI_Comm_free(MPI_Comm *comm)
- {
- pList sendlist, recvlist;
- int size;
- Comm *mycomm;
- mycomm=mpi_handle_to_ptr(*comm); /* (Comm *)(*comm) */
- sendlist=mycomm->sendlist;
- recvlist=mycomm->recvlist;
- size=AP_list_size(sendlist);
- if (size!=0)
- fprintf(stderr,"MPI_Comm_free: warning: %d pending send reqs\n",
- size);
- AP_list_free(sendlist);
- size=AP_list_size(recvlist);
- if (size!=0)
- fprintf(stderr,"MPI_Comm_free: warning: %d pending receive reqs\n",
- size);
- AP_list_free(recvlist);
- mpi_free_handle(*comm); /* free(mycomm); */
- *comm=MPI_COMM_NULL;
- return(MPI_SUCCESS);
- }
- /*********/
- FC_FUNC( mpi_comm_size , MPI_COMM_SIZE )(int *comm, int *size, int *ierror)
- {
- *ierror=MPI_Comm_size(*comm, size);
- }
- int MPI_Comm_size(MPI_Comm comm, int *size)
- {
- *size=1;
- return(MPI_SUCCESS);
- }
- /*********/
- FC_FUNC( mpi_comm_rank , MPI_COMM_RANK )(int *comm, int *rank, int *ierror)
- {
- *ierror=MPI_Comm_rank( *comm, rank);
- }
- int MPI_Comm_rank(MPI_Comm comm, int *rank)
- {
- *rank=0;
- return(MPI_SUCCESS);
- }
- /*********/
- FC_FUNC( mpi_comm_dup , MPI_COMM_DUP )(int *comm, int *newcomm, int *ierror)
- {
- *ierror=MPI_Comm_dup( *comm, newcomm);
- }
- int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
- {
- *newcomm= mpi_comm_new();
- #ifdef INFO
- fflush(stdout);
- fprintf(stderr,"MPI_Comm_dup: new comm handle=%d\n",*newcomm);
- #endif
- return(MPI_SUCCESS);
- }
- /*********/
- int FC_FUNC( mpi_comm_create, MPI_COMM_CREATE)
- (int *comm, int *group, int *newcomm, int *ierror)
- {
- *ierror=MPI_Comm_create(*comm,*group,newcomm);
- }
- int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm)
- {
- if (group==MPI_GROUP_NULL || group==MPI_GROUP_EMPTY)
- *newcomm= MPI_COMM_NULL;
- else
- *newcomm=mpi_comm_new();
- return(MPI_SUCCESS);
- }
- /*********/
- FC_FUNC( mpi_comm_split, MPI_COMM_SPLIT )
- (int *comm, int *color, int *key, int *newcomm, int *ierror)
- {
- *ierror=MPI_Comm_split(*comm,*color,*key,newcomm);
- }
- int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm)
- {
- if (color==MPI_UNDEFINED)
- *newcomm=MPI_COMM_NULL;
- else
- *newcomm= mpi_comm_new();
- return(MPI_SUCCESS);
- }
- /*********/
- FC_FUNC( mpi_comm_group, MPI_COMM_GROUP )
- (int *comm, int *group, int *ierror)
- {
- *ierror= MPI_Comm_group(*comm, group);
- }
- int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)
- {
- if (comm==MPI_COMM_NULL)
- *group= MPI_GROUP_NULL;
- else
- *group= MPI_GROUP_ONE;
- return(MPI_SUCCESS);
- }
- /*********/
- MPI_Comm MPI_Comm_f2c(MPI_Fint comm)
- {
- /* Comm is an integer handle used both by C and Fortran */
- return(comm);
- }
- MPI_Fint MPI_Comm_c2f(MPI_Comm comm)
- {
- return(comm);
- }
|