Skip to content

Commit

Permalink
add definition of MPI_IN_PLACE (still need use)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Loy committed Apr 21, 2015
1 parent 9a4b2a1 commit d5f9d41
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
15 changes: 7 additions & 8 deletions mpi-serial/fort.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,18 @@ subroutine mpi_init(ierror)


!
! mpi_get_fort_status
! mpi_get_fort_pointers
!
! In Fortran, MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE
! are in a COMMON block and not accessible by C code.
! This routine calls back a C routine to store the
! addresses.
! In Fortran, various values e.g. MPI_STATUS_IGNORE, MPI_STATUSES_IGNORE,
! and MPI_IN_PLACE are in a COMMON block and not accessible by C code.
! This routine calls back a C routine to store the addresses.
!

subroutine mpi_get_fort_status
subroutine mpi_get_fort_pointers
implicit none
include "mpif.h"

call mpi_save_fort_status(MPI_STATUS_IGNORE,MPI_STATUSES_IGNORE)
call mpi_save_fort_pointers(MPI_STATUS_IGNORE,MPI_STATUSES_IGNORE,MPI_IN_PLACE)

end subroutine mpi_get_fort_status
end subroutine mpi_get_fort_pointers

20 changes: 16 additions & 4 deletions mpi-serial/mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

static int initialized=0;

int *f_MPI_STATUS_IGNORE;
int *f_MPI_STATUSES_IGNORE;

/* Store fortran pointer values here */

static int *f_MPI_STATUS_IGNORE;
static int *f_MPI_STATUSES_IGNORE;
static int *f_MPI_IN_PLACE;


/****************************************************************************/
Expand Down Expand Up @@ -171,7 +175,7 @@ int MPI_Init(int *argc, char **argv[])

// call this to have the fortran routine call back and save
// values for f_MPI_STATUS_IGNORE and f_MPI_STATUSES_IGNORE
FC_FUNC(mpi_get_fort_status,MPI_GET_FORT_STATUS)(); // the () are important
FC_FUNC(mpi_get_fort_pointers,MPI_GET_FORT_POINTERS)(); // the () are important

initialized=1;
return(MPI_SUCCESS);
Expand Down Expand Up @@ -291,10 +295,11 @@ int MPI_Initialized(int *flag)
/**********/


void FC_FUNC( mpi_save_fort_status, MPI_SAVE_FORT_STATUS ) (int *status, int *statuses)
void FC_FUNC( mpi_save_fort_pointers, MPI_SAVE_FORT_POINTERS ) (int *status, int *statuses, int *in_place)
{
f_MPI_STATUS_IGNORE=status;
f_MPI_STATUSES_IGNORE=statuses;
f_MPI_IN_PLACE=in_place;
}


Expand All @@ -317,3 +322,10 @@ MPI_Status *mpi_c_statuses(int *statuses)
}


void *mpi_c_in_place(void *buffer)
{
if (buffer==(void *)f_MPI_IN_PLACE)
return(MPI_IN_PLACE);

return(buffer);
}
1 change: 1 addition & 0 deletions mpi-serial/mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typedef int MPI_Group;

typedef unsigned long int MPI_Aint;
#define MPI_BOTTOM (0)
#define MPI_IN_PLACE (void *)(-1)
typedef int MPI_Datatype;


Expand Down
3 changes: 2 additions & 1 deletion mpi-serial/mpiP.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ extern void mpi_alloc_handle(int *handle, void **data);
extern void *mpi_handle_to_ptr(int handle);
extern void mpi_free_handle(int handle);

extern void FC_FUNC(mpi_get_fort_status,MPI_GET_FORT_STATUS)(void);
extern void FC_FUNC(mpi_get_fort_pointers,MPI_GET_FORT_POINTERS)(void);

extern MPI_Status *mpi_c_status(int *status);
extern MPI_Status *mpi_c_statuses(int *statuses);
extern void *mpi_c_in_place(void *buffer);


#endif /* _MPIP_H */
9 changes: 8 additions & 1 deletion mpi-serial/mpif.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@

INTEGER MPI_STATUS_IGNORE(MPI_STATUS_SIZE)
INTEGER MPI_STATUSES_IGNORE(MPI_STATUS_SIZE,1)

COMMON /MPISERIAL/ MPI_STATUS_IGNORE
COMMON /MPISERIAL/ MPI_STATUSES_IGNORE

!
! MPI_IN_PLACE
!

INTEGER MPI_IN_PLACE
COMMON /MPISERIAL/ MPI_IN_PLACE

SAVE /MPISERIAL/ ! Technically needed in case goes out of scope


!
Expand Down

0 comments on commit d5f9d41

Please sign in to comment.