# JLD2 load of MersenneTwister does not work

**URL:** <https://discourse.julialang.org/t/jld2-load-of-mersennetwister-does-not-work/14939>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 14, 2018, 8:19am UTC](https://discourse.julialang.org/t/jld2-load-of-mersennetwister-does-not-work/14939 "2018-09-14T08:19:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Post date:** [September 14, 2018, 8:19am UTC](https://discourse.julialang.org/t/jld2-load-of-mersennetwister-does-not-work/14939/1 "2018-09-14T08:19:08Z")

</div>

Hello, I have the following problem:

I try to save a random number generator to a jld2 file and load it later.

Here is an example:

```julia
using Random
using FileIO
using JLD2

rng = Random.MersenneTwister(1)

jldopen("test_rng.jld2", true, true, true, IOStream) do file
	file["rng"] = rng
end

rng_load = load("test_rng.jld2", "rng")

@show typeof(rng)
@show typeof(rng_load)

```

The output is:

```julia
┌ Warning: type DSFMT.DSFMT.DSFMT_state does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/xpVxm/src/data.jl:1153
┌ Warning: saved type MersenneTwister has field state::getfield(JLD2.ReconstructedTypes, Symbol("##DSFMT.DSFMT.DSFMT_state#378")), but workspace type has field state::Random.DSFMT.DSFMT_state, and no applicable convert method exists; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/xpVxm/src/data.jl:420
typeof(rng) = MersenneTwister
typeof(rng_load) = getfield(JLD2.ReconstructedTypes, Symbol("##MersenneTwister#379"))

```

So obviosly this does not work. I would like to know why and ho to correct this.

Remark: I use this `jldopen` version for saving because the real code runs on a cluster and there where issues with the saving with `@save` macro.

Here I have a link to an issue I have opend for JLD2: [Load MersenneTwister fails · Issue #112 · JuliaIO/JLD2.jl · GitHub](https://github.com/simonster/JLD2.jl/issues/112)
