Skip to content

Commit

Permalink
Let ccall interface handle argument conversion (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored Nov 4, 2023
1 parent bf962ef commit 4ea8190
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/LAMMPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,19 @@ mutable struct LMP
@atomic handle::Ptr{Cvoid}

function LMP(args::Vector{String}=String[], comm::Union{Nothing, MPI.Comm}=nothing)
if isempty(args)
argsv = C_NULL
else
if !isempty(args)
args = copy(args)
pushfirst!(args, "lammps")
argsv = map(pointer, args)
end

GC.@preserve args begin
if comm !== nothing
if !MPI.Initialized()
error("MPI has not been initialized. Make sure to first call `MPI.Init()`")
end
handle = API.lammps_open(length(args), argsv, comm, C_NULL)
handle = API.lammps_open(length(args), args, comm, C_NULL)
else
handle = API.lammps_open_no_mpi(length(args), argsv, C_NULL)
handle = API.lammps_open_no_mpi(length(args), args, C_NULL)
end
end

Expand Down

0 comments on commit 4ea8190

Please sign in to comment.