@@ -95,8 +95,51 @@ const REQUEST_NULL = Request(MPI_REQUEST_NULL, nothing)
9595
9696mutable struct Info
9797 val:: Cint
98+ # val::Cint
99+ function Info ()
100+ newinfo = Ref {Cint} ()
101+ ccall (MPI_INFO_CREATE, Void, (Ptr{Cint}, Ptr{Cint}), newinfo, & 0 )
102+ info= new (newinfo[])
103+ finalizer (info, info -> ( ccall (MPI_INFO_FREE, Void,
104+ (Ptr{Cint}, Ptr{Cint}), & info. val, & 0 );
105+ info. val = MPI_INFO_NULL ) )
106+ info
107+ end
108+ end
109+ const INFO_NULL = MPI_INFO_NULL
110+
111+ # the info functions assume that Fortran hidden arguments are placed at the end of the argument list
112+ function Info_set (info:: Info ,key:: AbstractString ,value:: AbstractString )
113+ @assert isascii (key) && isascii (value)
114+ ccall (MPI_INFO_SET, Void,
115+ (Ptr{Cint}, Ptr{UInt8}, Ptr{UInt8}, Ptr{Cint}, Csize_t, Csize_t),
116+ & info. val, key, value, & 0 , sizeof (key), sizeof (value))
117+ end
118+
119+ function Info_get (info:: Info ,key:: AbstractString )
120+ @assert isascii (key)
121+ keyexists= Ref {Bool} ()
122+ len= Ref {Cint} ()
123+ ccall (MPI_INFO_GET_VALUELEN, Void,
124+ (Ptr{Cint}, Ptr{UInt8}, Ptr{Cint}, Ptr{Bool}, Ptr{Cint}, Csize_t),
125+ & info. val, key, len, keyexists, & 0 , sizeof (key))
126+ if keyexists[]
127+ value= " " ^ (len[])
128+ ccall (MPI_INFO_GET, Void,
129+ (Ptr{Cint}, Ptr{UInt8}, Ptr{Cint}, Ptr{UInt8}, Ptr{Bool}, Ptr{Cint}, Csize_t, Csize_t),
130+ & info. val, key, len, value, keyexists, & 0 , sizeof (key), sizeof (value) )
131+ else
132+ value= " "
133+ end
134+ value
98135end
99- const INFO_NULL = Info (MPI_INFO_NULL)
136+
137+ function Info_delete (info:: Info ,key:: AbstractString )
138+ @assert isascii (key)
139+ ccall (MPI_INFO_DELETE, Void,
140+ (Ptr{Cint}, Ptr{UInt8}, Ptr{Cint}, Csize_t), & info. val, key ,& 0 , sizeof (key) )
141+ end
142+ Info_free (info:: Info ) = finalize (info)
100143
101144mutable struct Status
102145 val:: Array{Cint,1}
@@ -176,14 +219,16 @@ end
176219
177220function Comm_split (comm:: Comm ,color:: Integer ,key:: Integer )
178221 newcomm = Ref {Cint} ()
179- ccall (MPI_COMM_SPLIT, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
222+ ccall (MPI_COMM_SPLIT, Void,
223+ (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
180224 & comm. val, & color, & key, newcomm, & 0 )
181225 MPI. Comm (newcomm[])
182226end
183227
184228function Comm_split_type (comm:: Comm ,split_type:: Integer ,key:: Integer ;info:: Info = INFO_NULL)
185229 newcomm = Ref {Cint} ()
186- ccall (MPI_COMM_SPLIT_TYPE, Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
230+ ccall (MPI_COMM_SPLIT_TYPE, Void,
231+ (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
187232 & comm. val, & split_type, & key, & info. val, newcomm, & 0 )
188233 MPI. Comm (newcomm[])
189234end
0 commit comments