Skip to content

Commit eae5e9e

Browse files
committed
Merge pull request #106 from JuliaParallel/eschnett/comm
Correct error in MPI_Comm_dup, and add test case
2 parents cec3373 + a097829 commit eae5e9e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/mpi-base.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ function Finalized()
132132
end
133133

134134
function Comm_dup(comm::Comm)
135-
newcomm = MPI.Comm(0)
135+
newcomm = Array(Cint, 1)
136136
ccall((MPI_COMM_DUP,libmpi), Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
137-
&comm.val, &newcomm.val, &0)
138-
newcomm
137+
&comm.val, newcomm, &0)
138+
MPI.Comm(newcomm[1])
139139
end
140140

141141
function Comm_free(comm::Comm)

test/test_comm.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Base.Test
2+
using MPI
3+
4+
MPI.Init()
5+
6+
comm = MPI.COMM_WORLD
7+
MPI.Barrier(comm)
8+
comm2 = MPI.Comm_dup(comm)
9+
MPI.Barrier(comm2)
10+
comm3 = MPI.Comm_dup(comm2)
11+
MPI.Barrier(comm3)
12+
MPI.Comm_free(comm2)
13+
MPI.Barrier(comm3)
14+
# Don't free comm2
15+
16+
MPI.Finalize()

0 commit comments

Comments
 (0)