Skip to content

mpi4py ctypes wrapper for Fortran 2008 #276

Answered by dalcinl
apoorv-2-8 asked this question in Q&A
Discussion options

You must be logged in to vote

Next time, please do not post screenshots. Just paste the test and use proper markdown formatting. Otherwise, you make things harder to try and play around for those trying to help you.

The code you are using would be appropriate for C toYou should learn elsewehre make it work in any platform with any MPI implementation. But it is not correct for Fortran 77 or Fortran 90/08.

First, you should uncomment bind(C) for maximum portability.

Next, you need to do things the following way in Python :

MPI_Fint = ctypes.c_int
MPI_Fint_p = ctypes.POINTER(MPI_Fint)
lib.sayhello.restype = None
lib.sayhello.argtypes = [MPI_Fint_p]  # by default, Fortran pass arguments by address

comm = MPI.COMM_WORLD
f…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@apoorv-2-8
Comment options

Answer selected by dalcinl
Comment options

You must be logged in to vote
2 replies
@apoorv-2-8
Comment options

@dalcinl
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants