Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

From: Wang, Peng (pewang_at_[hidden])
Date: 2006-09-01 09:26:52


Hello, I am wondering in openmpi how is the passing of MPI communcator
from Fortran to C is handled? Assuming I have a Fortran 90 subroutine
calling a C function passing MPI_COMM_WORLD in, in the C function, do I
need to first do MPI_Comm_f2c
to convert to MPI handle, then use that handle afterward? Or is there
any better way to do this? Here is some test code:

Fortran 90:

        program test1

        include 'mpif.h'

        integer myrank,ierr

        call MPI_Init(ierr)

        call parallel_info(myrank,MPI_COMM_WORLD)
        write(*,*) 'hello, I am process #',myrank

        call MPI_Finalize(ierr)

        end program test1

C:

#include <mpi.h>

void parallel_info_(int * rank, int* comm)
{
    MPI_Comm ccomm;

    ccomm=MPI_Comm_f2c(*comm);
    MPI_Comm_rank(ccomm, rank);
}

void parallel_info(int * rank, int * comm)
{
    MPI_Comm ccomm;

    ccomm=MPI_Comm_f2c(*comm);

    MPI_Comm_rank(ccomm, rank);
}

Thanks,
Peng