@@ -120,40 +120,40 @@ function Abort(comm::Comm, errcode::Integer)
120120end
121121
122122function Initialized ()
123- flag = Array ( Cint, 1 )
123+ flag = Ref { Cint} ( )
124124 ccall (MPI_INITIALIZED, Void, (Ptr{Cint}, Ptr{Cint}), flag, & 0 )
125- flag[1 ] != 0
125+ flag[] != 0
126126end
127127
128128function Finalized ()
129- flag = Array ( Cint, 1 )
129+ flag = Ref { Cint} ( )
130130 ccall (MPI_FINALIZED, Void, (Ptr{Cint}, Ptr{Cint}), flag, & 0 )
131- flag[1 ] != 0
131+ flag[] != 0
132132end
133133
134134function Comm_dup (comm:: Comm )
135- newcomm = Array ( Cint, 1 )
135+ newcomm = Ref { Cint} ( )
136136 ccall (MPI_COMM_DUP, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
137137 & comm. val, newcomm, & 0 )
138- MPI. Comm (newcomm[1 ])
138+ MPI. Comm (newcomm[])
139139end
140140
141141function Comm_free (comm:: Comm )
142142 ccall (MPI_COMM_FREE, Void, (Ptr{Cint}, Ptr{Cint}), & comm. val, & 0 )
143143end
144144
145145function Comm_rank (comm:: Comm )
146- rank = Array ( Cint, 1 )
146+ rank = Ref { Cint} ( )
147147 ccall (MPI_COMM_RANK, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
148148 & comm. val, rank, & 0 )
149- Int (rank[1 ])
149+ Int (rank[])
150150end
151151
152152function Comm_size (comm:: Comm )
153- size = Array ( Cint, 1 )
153+ size = Ref { Cint} ( )
154154 ccall (MPI_COMM_SIZE, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
155155 & comm. val, size, & 0 )
156- Int (size[1 ])
156+ Int (size[])
157157end
158158
159159# Point-to-point communication
@@ -167,22 +167,22 @@ function Probe(src::Integer, tag::Integer, comm::Comm)
167167end
168168
169169function Iprobe (src:: Integer , tag:: Integer , comm:: Comm )
170- flag = Array ( Cint, 1 )
170+ flag = Ref { Cint} ( )
171171 stat = Status ()
172172 ccall (MPI_IPROBE, Void,
173173 (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
174174 & src, & tag, & comm. val, flag, stat. val, & 0 )
175- if flag[1 ] == 0
176- return ( false , nothing )
175+ if flag[] == 0
176+ return false , nothing
177177 end
178- ( true , stat)
178+ true , stat
179179end
180180
181181function Get_count {T<:MPIDatatype} (stat:: Status , :: Type{T} )
182- count = Array ( Cint, 1 )
182+ count = Ref { Cint} ( )
183183 ccall (MPI_GET_COUNT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
184184 stat. val, & mpitype (T), count, & 0 )
185- Int (count[1 ])
185+ Int (count[])
186186end
187187
188188function Send {T<:MPIDatatype} (buf:: Union{Ptr{T},Array{T}} , count:: Integer ,
@@ -210,12 +210,12 @@ end
210210
211211function Isend {T<:MPIDatatype} (buf:: Union{Ptr{T},Array{T}} , count:: Integer ,
212212 dest:: Integer , tag:: Integer , comm:: Comm )
213- rval = Array ( Cint, 1 )
213+ rval = Ref { Cint} ( )
214214 ccall (MPI_ISEND, Void,
215215 (Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
216216 Ptr{Cint}, Ptr{Cint}),
217217 buf, & count, & mpitype (T), & dest, & tag, & comm. val, rval, & 0 )
218- Request (rval[1 ], buf)
218+ Request (rval[], buf)
219219end
220220
221221function Isend {T<:MPIDatatype} (buf:: Array{T} , dest:: Integer , tag:: Integer ,
@@ -249,9 +249,9 @@ function Recv!{T<:MPIDatatype}(buf::Array{T}, src::Integer, tag::Integer,
249249end
250250
251251function Recv {T<:MPIDatatype} (:: Type{T} , src:: Integer , tag:: Integer , comm:: Comm )
252- buf = Array (T, 1 )
252+ buf = Ref{T}
253253 stat = Recv! (buf, src, tag, comm)
254- (buf[1 ], stat)
254+ (buf[], stat)
255255end
256256
257257function recv (src:: Integer , tag:: Integer , comm:: Comm )
@@ -264,12 +264,12 @@ end
264264
265265function Irecv! {T<:MPIDatatype} (buf:: Union{Ptr{T},Array{T}} , count:: Integer ,
266266 src:: Integer , tag:: Integer , comm:: Comm )
267- rval = Array ( Cint, 1 )
267+ val = Ref { Cint} ( )
268268 ccall (MPI_IRECV, Void,
269269 (Ptr{T}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint},
270270 Ptr{Cint}, Ptr{Cint}),
271- buf, & count, & mpitype (T), & src, & tag, & comm. val, rval , & 0 )
272- Request (rval[ 1 ], buf)
271+ buf, & count, & mpitype (T), & src, & tag, & comm. val, val , & 0 )
272+ Request (val[ ], buf)
273273end
274274
275275function Irecv! {T<:MPIDatatype} (buf:: Array{T} , src:: Integer , tag:: Integer ,
@@ -297,11 +297,11 @@ function Wait!(req::Request)
297297end
298298
299299function Test! (req:: Request )
300- flag = Array ( Cint, 1 )
300+ flag = Ref { Cint} ( )
301301 stat = Status ()
302302 ccall (MPI_TEST, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
303303 & req. val, flag, stat. val, & 0 )
304- if flag[1 ] == 0
304+ if flag[] == 0
305305 return (false , nothing )
306306 end
307307 req. buffer = nothing
@@ -349,12 +349,12 @@ end
349349function Waitany! (reqs:: Array{Request,1} )
350350 count = length (reqs)
351351 reqvals = [reqs[i]. val for i in 1 : count]
352- ind = Array ( Cint, 1 )
352+ ind = Ref { Cint} ( )
353353 stat = Status ()
354354 ccall (MPI_WAITANY, Void,
355355 (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
356356 & count, reqvals, index, statvals, & 0 )
357- index = ind[1 ]
357+ index = ind[]
358358 reqs[index]. val = reqvals[index]
359359 reqa[index]. buffer = nothing
360360 (index, stat)
@@ -363,16 +363,16 @@ end
363363function Testany! (reqs:: Array{Request,1} )
364364 count = length (reqs)
365365 reqvals = [reqs[i]. val for i in 1 : count]
366- ind = Array ( Cint, 1 )
367- flag = Array ( Cint, 1 )
366+ ind = Ref { Cint} ( )
367+ flag = Ref { Cint} ( )
368368 stat = Status ()
369369 ccall (MPI_TESTANY, Void,
370370 (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
371371 & count, reqvals, ind, flag, stat. val, & 0 )
372- if flag[1 ] == 0
372+ if flag[] == 0
373373 return (false , 0 , nothing )
374374 end
375- index = ind[1 ]
375+ index = ind[]
376376 reqs[index]. val = reqvals[index]
377377 reqs[index]. buffer = nothing
378378 (true , index, stat)
@@ -381,13 +381,13 @@ end
381381function Waitsome! (reqs:: Array{Request,1} )
382382 count = length (reqs)
383383 reqvals = [reqs[i]. val for i in 1 : count]
384- outcnt = Array ( Cint, 1 )
384+ outcnt = Ref { Cint} ( )
385385 inds = Array (Cint, count)
386386 statvals = Array (Cint, MPI_STATUS_SIZE, count)
387387 ccall (MPI_WAITSOME, Void,
388388 (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
389389 & count, reqvals, outcnt, inds, statvals, & 0 )
390- outcount = outcnt[1 ]
390+ outcount = outcnt[]
391391 # This can happen if there were no valid requests
392392 if outcount == MPI_UNDEFINED
393393 outcount = 0
@@ -408,13 +408,13 @@ end
408408function Testsome! (reqs:: Array{Request,1} )
409409 count = length (reqs)
410410 reqvals = [reqs[i]. val for i in 1 : count]
411- outcnt = Array ( Cint, 1 )
411+ outcnt = Ref { Cint} ( )
412412 inds = Array (Cint, count)
413413 statvals = Array (Cint, MPI_STATUS_SIZE, count)
414414 ccall (MPI_TESTSOME, Void,
415415 (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
416416 & count, reqvals, outcnt, inds, statvals, & 0 )
417- outcount = outcnt[1 ]
417+ outcount = outcnt[]
418418 # This can happen if there were no valid requests
419419 if outcount == MPI_UNDEFINED
420420 outcount = 0
0 commit comments