I was using the below code to create .jld2
file containing an instance Sim
of structure Simulation
include("./SimulationStructure.jl");
function appFunction()
Sim = Simulation();
io = open("$(@__DIR__)/generatedElements.jld2", "w")
close(io)
save("$(@__DIR__)/generatedElements.jld2", "Sim", Sim)
end
appFunction();
in which SimulationStructure.jl
:
using base
export Simulation
Base.@kwdef mutable struct Simulation
dt::Float64 = 1e-6
tmax::Float64 = 32*1e-3
end
Then, I was reading the created .jld2
by the below code called readFile.jl
. and It was working without any warning, in which typeof Sim
is Simulation
include("./SimulationStructure.jl");
Sim = load("$(@__DIR__)/generatedElements.jld2", "Sim");
julia> typeof(Sim)
Simulation
Now, I have built executable for appFunction()
as below and it works fine to generate the .jld2
file.
module readApp
Base.@ccallable function julia_main()::Cint
try
appFunction()
catch
Base.invokelatest(Base.display_error, Base.catch_stack())
return 1
end
return 0
end
Base.@kwdef mutable struct Simulation
dt::Float64 = 1e-6
tmax::Float64 = 32*1e-3
end
function appFunction()
Sim = Simulation();
io = open("$(@__DIR__)/generatedElements.jld2", "w")
close(io)
save("$(@__DIR__)/generatedElements.jld2", "Sim", Sim)
end
end
However, calling readFile.jl
to read the generated .jld2
gives this warning and typeof Sim
is Simulation
┌ Warning: type readApp.Simulation does not exist in workspace; reconstructing
└ @ JLD2 C:\Users\amroa\.julia\packages\JLD2\k9Gt0\src\data\reconstructing_datatypes.jl:461
julia> typeof(Sim)
JLD2.ReconstructedTypes.var"##readApp.Simulation#292"
How can I get ride of the warning and fix the typeof(Sim) to be of Simulation
?