# Reconstructing warning when dealing with Module?

**URL:** https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363
**Category:** General Usage
**Tags:** question
**Created:** [March 23, 2022, 11:55pm UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363 "2022-03-23T23:55:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)
#### Post date: [March 23, 2022, 11:55pm UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363/1 "2022-03-23T23:55:25Z")

</div>

I am using `createSim.jl` to save an instance `Sim` of structure `Simulation` in `.jld2` file, and `readSim.jl` to read this instance. However, I am having `reconstructing`. How to solve it please?  
`createSim.jl` is:

```julia
using JLD2
Base.@kwdef mutable struct Simulation
  dt::Float64 = 1e-6 
  tmax::Float64 = 32*1e-3
end
Sim = Simulation(2,4);
save("$(@ __DIR__ )/generatedElements.jld2", "Sim", Sim)

```

`readSim.jl`

```julia
module test
using JLD2
Base.@kwdef mutable struct Simulation
  dt::Float64 = 1e-6 
  tmax::Float64 = 32*1e-3
end

function readJLD()
  Sim = load("$(@ __DIR__ )/generatedElements.jld2", "Sim")
  return Sim
end
Sim = readJLD()
end
┌ Warning: type Main.Simulation does not exist in workspace; reconstructing
└ @ JLD2 C:\Users\amroa\.julia\packages\JLD2\k9Gt0\src\data\reconstructing_datatypes.jl:461
julia> test.Sim
JLD2.ReconstructedTypes.var"##Main.Simulation#292"(2.0, 4.0)

```

---

<div class="post-metadata">

### Author: ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)
#### Post date: [March 24, 2022, 7:52am UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363/2 "2022-03-24T07:52:43Z")

</div>

this is a guess but

as the error message says

> `type Main.Simulation does not exist in workspace`

```julia
module test

export Simulation

```

might fix it

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [March 24, 2022, 9:11am UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363/3 "2022-03-24T09:11:21Z")

</div>

Ok, you opened a new thread with the same issue you already asked here [How to save a structure instance (inside module) in JLD2, to load it later correctly?](https://discourse.julialang.org/t/how-to-save-a-structure-instance-inside-module-in-jld2-to-load-it-later-correctly/78339)

With that you are just wasting my (and others) time to trying to help you. If you don’t get immediate answers just consider that people who already answered your question may have a different time zone and just went to bed for some time or have other things to do.  
Please consider this for the future.

---

<div class="post-metadata">

### Author: ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)
#### Post date: [March 24, 2022, 12:51pm UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363/4 "2022-03-24T12:51:49Z")

</div>

Dear @oheil I am sorry for this. You get me wrong or maybe I was naive in my thoughts.

In the previous one, it saving from module into `.jld2` and here is the opposite. I tried by myself many times based on your help previously, but failed and I was a shy to be blamed that I am not able to solve similar issue reversely.  
I am sorry again if this is improper and I can delete it here if this can solve the issue. Moreover, thanks for your note which can guide me and make posting in the community more professional. I will not do this again.

---

<div class="post-metadata">

### Author: ![JonasIsensee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonasisensee/32/4704_2.png) [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)
#### Post date: [March 24, 2022, 1:02pm UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363/6 "2022-03-24T13:02:51Z")

</div>

When changing the location of a struct definition, it is easiest to  
tell JLD2 explicitly where to find it.  
Here: Load saved type “Main.Simulation” as the new `Simulation` struct.

```julia
julia> Sim = load("$(@ __DIR__ )/generatedElements.jld2"; typemap=Dict("Main.Simulation" => Simulation))

```

---

<div class="post-metadata">

### Author: ![JonasIsensee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonasisensee/32/4704_2.png) [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)
#### Post date: [March 24, 2022, 1:45pm UTC](https://discourse.julialang.org/t/reconstructing-warning-when-dealing-with-module/78363/8 "2022-03-24T13:45:11Z")

</div>

Please take a look at the documentation of JLD2  
and in particular at [Advanced Usage · Julia Data Format](https://juliaio.github.io/JLD2.jl/dev/advanced/#Explicit-Type-Remapping)

`load` returns a `Dict` of all objects stored in the file.

```julia
data = load("$(@ __DIR__ )/generatedElements.jld2"; typemap=Dict("Main.Simulation" => Simulation))
Sim = data["Sim"]

```
