<commit_before>module Elemental

using MPI
import Base: A_mul_B!, copy, copy!, similar, size

include("../deps/deps.jl")

include("error.jl")

function Init()
    err = ccall((:ElInitialize, libEl), Cint,
        (Ref{Cint}, Ref{Ptr{Void}}), Ref(zero(Cint)), Ref(C_NULL))
    err == 0 || error("Error Initializing Elemental: $(ErrorString(err))")
    return nothing
end

function Initialized()
    active = Ref(zero(Cint))
    err = ccall((:ElInitialized, libEl), Cuint, (Ref{Cint},), active)
    err == 0 || throw(ElError(err))
    return active[] == 1
end

function Finalize()
    err = ccall((:ElFinalize, libEl), Cint, ())
    err == 0 || error("Error Finalizing Elemental: $(ErrorString(err))")
    return nothing
end

function __init__()
    MPI.Init()
    Init()
    atexit() do
        Initialized() && Finalize()
    end
end

include("types.jl")
include("grid.jl")
include("sparsematrix.jl")
include("distmatrix.jl")
include("distsparsematrix.jl")
include("distmultivec.jl")
include("matrices.jl")<commit_msg>properly initialize Elemental, let Elemental do MPI initialization<commit_after>module Elemental

using MPI
import Base: A_mul_B!, copy, copy!, similar, size

include("../deps/deps.jl")

include("error.jl")

function Init()
    argc = [zero(Cint)]
    argv = [Ptr{Cchar}(0)]
    err = ccall((:ElInitialize, libEl), Cint,
                (Ptr{Cint}, Ptr{Ptr{Cchar}}), argc, argv)
    err == 0 || error("Error Initializing Elemental: $(ErrorString(err))")
    return nothing
end

function Initialized()
    active = Ref(zero(Cint))
    err = ccall((:ElInitialized, libEl), Cuint, (Ref{Cint},), active)
    err == 0 || throw(ElError(err))
    return active[] == 1
end

function Finalize()
    err = ccall((:ElFinalize, libEl), Cint, ())
    err == 0 || error("Error Finalizing Elemental: $(ErrorString(err))")
    return nothing
end

function __init__()
    Init()
    atexit() do
        Initialized() && Finalize()
    end
end

include("types.jl")
include("grid.jl")
include("sparsematrix.jl")
include("distmatrix.jl")
include("distsparsematrix.jl")
include("distmultivec.jl")
include("matrices.jl")
{'fraction_non_alphanumeric': 0.16918714555765596, 'fraction_numerical': 0.004253308128544423, 'mean_word_length': 4.319095477386934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5348633', 'n_tokens_mistral': 745, 'n_tokens_neox': 717, 'n_words': 171}