Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Mixing the FORTRAN and C APIs.
From: Tim Hutt (tdhutt_at_[hidden])
Date: 2011-05-06 10:58:44


Hi,

I'm trying to use PARPACK in a C++ app I have written. This is an
FORTRAN MPI routine used to calculate SVDs. The simplest way I found
to do this is to use f2c to convert it to C, and then call the
resulting functions from my C++ code.

However PARPACK requires that I write some user-defined operations to
be parallel using MPI. So far I have just been calling the FORTRAN
versions of the MPI functions from C, because I wasn't sure whether
you can mix the APIs. I.e. I've been doing this:

-----8<-----
extern "C"
{
        int mpi_init__(integer *);
        int mpi_comm_rank__(integer *, integer *, integer *);
        int mpi_comm_size__(integer *, integer *, integer *);
        int mpi_finalize__(integer *);
        int mpi_allgatherv__(doublereal *, integer *, integer *, doublereal
*, integer *, integer *, integer *, integer *);

        // OpenMPI version.
        const integer MPI_DOUBLE_PRECISION = 17;
}

bool MPI__Init()
{
        integer ierr = 0;
        mpi_init__(&ierr);
        return ierr == 0;
}
----8<----

It works so far, but is getting quite tedious and seems like the wrong
way to do it. Also I don't know if it's related but when I use
allgatherv it gives me a segfault:

[panic:20659] *** Process received signal ***
[panic:20659] Signal: Segmentation fault (11)
[panic:20659] Signal code: Address not mapped (1)
[panic:20659] Failing at address: 0x7f4effffffe8
[panic:20659] [ 0] /lib/libc.so.6(+0x33af0) [0x7f4f8fd62af0]
[panic:20659] [ 1] /usr/lib/libstdc++.so.6(_ZNSolsEi+0x3) [0x7f4f905ec0c3]
[panic:20659] [ 2] ./TDLSM() [0x510322]
[panic:20659] [ 3] ./TDLSM() [0x50ec8d]
[panic:20659] [ 4] ./TDLSM() [0x404ee7]
[panic:20659] [ 5] /lib/libc.so.6(__libc_start_main+0xfd) [0x7f4f8fd4dc4d]
[panic:20659] [ 6] ./TDLSM() [0x404c19]
[panic:20659] *** End of error message ***

So my question is: Can I intermix the C and FORTRAN APIs within one
program? Oh and also I think the cluster I will eventually run this on
(cx1.hpc.ic.ac.uk, if anyone is from Imperial) doesn't use OpenMP, so
what about other MPI implementations?

Many thanks,

Tim