LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Bernard Knaepen (bknaepen_at_[hidden])
Date: 2005-02-25 09:44:15


Hello,
I was having runtime problems with a third-party code and tracked down
my problems to the following issue.
Let's say simplef.f90 is the main program:

*************************** simplef.f90
program main
implicit none
include 'mpif.h'
integer ierr
integer mynod, mycomm

call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, mynod, ierr)

mycomm = MPI_COMM_WORLD
print*, 'Value of the comm in F: ', mycomm

call CROUTINE(mycomm)

call MPI_FINALIZE(ierr)

end
***************************

This small program call the c routine CROUTINE that resides in a
separate .c file simplec.c:
*************************** simplec.c
#include "mpi.h"

void CROUTINE(MPI_Comm *comm_ptr);

void CROUTINE(MPI_Comm *comm_ptr) {
int mynode;
        
MPI_Comm_rank(*comm_ptr, &mynode );
printf("%i\n",mynode);
        
}
***************************
I compile those using:
mpicc -c simplec.c -o simplec.o
mpif77 simplec.o simplef.f90 -o simple

When I run the program simple I get the output:
 Value of the comm in F: 0
Rank (0, MPI_COMM_WORLD): Call stack within LAM:
Rank (0, MPI_COMM_WORLD): - MPI_Comm_rank()
Rank (0, MPI_COMM_WORLD): - main()

After playing around, I discovered that the problem occurs because in
the Fortran part of the
code MPI_COMM_WORLD is equal to 0 and this value is passed on to
MPI_Comm_rank(*comm_ptr, &num_procs ) in the c code. In the c world,
MPI_COMM_WORLD is equal
to 604192 according to printf("%i\n", MPI_COMM_WORLD. In the c code, a call to
MPI_Comm_rank(MPI_COMM_WORLD, &mynode ) gives the desired results.

Is this mismatch of MPI_COMM_WORLD between the Fortran and C world an
intentional feature?
To doublecheck, I tried the above examples using mpich and they don't
produce a runtime error.
In that case MPI_COMM_WORLD is equal to 91 in both the Fortran and C
parts of the codes.

For information, I am using OSX 10.3 and lam 7.1.2b13. My laminfo,
config.log files are available as attachments in a previous email from
earlier this week concerning a problem with romio on OSX.

Thank for any insight into this issue,
Bernard Knaepen.