Fortran Why Is MPI_COMM_RANK Not Working Correctly on Mac OSX?

  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Fortran Mac
Click For Summary
The discussion centers around running MPI Fortran code on a Mac, where the user experiences an issue with parallelization. Despite successfully compiling and executing a simple "hello world" program, the output indicates that only node 0 is active, printing the message multiple times instead of showing distinct ranks for each process. The user notes that the same code works correctly on Linux systems. Further investigation reveals that four parallel instances of the code are indeed running, suggesting a problem with how MPI_COMM_RANK is returning the rank value on Mac. The user seeks tips or suggestions to resolve this issue, questioning whether this is a common problem on Mac systems.
natski
Messages
262
Reaction score
2
Hi all,

I have been running mpi fortran code on Linux based systems without any trouble for some time but making the same code run on a Mac is causing me some headaches. I installed mpi using the guide at: http://www.macresearch.org/compiling-mpi-f90-support-snow-leopard

I am trying to run some simple "hello world" code:

! Fortran example
program hello
include 'mpif.h'
integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)

call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
print*, 'node', rank, ': Hello world'
call MPI_FINALIZE(ierror)
end

Compiling with mpif90 -o mpihello mpihello.f90 and then executing with mpirun -np 4 mpihello I get...

node 0 : Hello world
node 0 : Hello world
node 0 : Hello world
node 0 : Hello world

So essentially I am calling node 0 four times rather than actually parallelizing anything. Has anyone else encountered this problem? The same code runs fine on Linux FYI. Any tips/suggestions would be extremely appreciated!

Natski
 
Technology news on Phys.org
By looping the inner code and re-running I notice in Activity Monitor that four parallel versions of the code are in fact running. So this seems simply something wrong with the rank being returned by MPI_COMM_RANK - is this a normal issue for Macs?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 54 ·
2
Replies
54
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K