What should I add in initilizeFile.jl
to make readingFile.jl
gives the type of Sim
as Simulation
not JLD2.ReconstructedTypes.var"##Main.readApp.Simulation#292"(2.0, 4.0)
with warning?
initilizeFile.jl
is:
module readApp
using JLD2
Base.@kwdef mutable struct Simulation
dt::Float64 = 1e-6
tmax::Float64 = 32*1e-3
end
function appFunction()
Sim = Simulation(2,4);
save("$(@__DIR__)/filename.jld2", "Sim", Sim)
end
appFunction();
end
readingFile.jl
using JLD2
Base.@kwdef mutable struct Simulation
dt::Float64 = 1e-6
tmax::Float64 = 32*1e-3
end
Sim = load("$(@__DIR__)/filename.jld2", "Sim");
#Now I have warning
┌ Warning: type Main.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"##Main.readApp.Simulation#292"(2.0, 4.0)
# I need to remove the warning and to make typeof(Sim) gives Simulation as below
julia> typeof(Sim)
Simulation