# Which version of Julia can run the following codes

**URL:** <https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [July 15, 2021, 2:32pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695 "2021-07-15T14:32:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjk](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tjk](https://discourse.julialang.org/u/tjk)\
**Post date:** [July 15, 2021, 2:32pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/1 "2021-07-15T14:32:01Z")

</div>

Hello, I am new to Julia and for research reasons I have to run a simple code for my friends. The code need Devito and JUDI:[Installation · slimgroup/JUDI.jl Wiki · GitHub](https://github.com/slimgroup/JUDI.jl/wiki/Installation)  
Here is the source code (Julia was installed on Ubuntu 16.04.7 LTS):

```julia
#using ClusterManagers; addprocs_slurm(1)
#using Distributed; addprocs(64)
using JUDI.TimeModeling, HDF5

n, d, o, m = read(h5open("./Brain_3D_true_model.h5", "r"), "n", "d", "o", "m")

# @everywhere using PyPlot
# figure(); imshow(sqrt.(1 ./ m[:, 200, :]))

# Set up model structure
model = Model((n[1], n[2], n[3]), (d[1], d[2], d[3]), (o[1], o[2], o[3]), m)

tn = 0.2f0#200f0 # micro s
dt = 0.1f0
f0 = .25 # MHz

# set up source
nsrc, src_loc = read(h5open("./Sources_location_512.h5"), "nsrc", "src_loc")
nsrc = Integer(nsrc[1])
xsrc = convertToCell(src_loc[1:2, 1] .* d[1])
ysrc = convertToCell(src_loc[1:2, 2] .* d[2])
zsrc = convertToCell(src_loc[1:2, 3] .* d[3])
nsrc = 2

# set up receivers
xrec = Float32.(xsrc)
yrec = Float32.(ysrc)
zrec = Float32.(zsrc)

src_geometry = Geometry(xsrc, ysrc, zsrc; dt = dt, t = tn)
rec_geometry = Geometry(xrec, yrec, zrec; dt = dt, t = tn, nsrc = nsrc)

# Set up source
wavelet = ricker_wavelet(tn, dt, f0)

# Info for modeling operators
ntComp = get_computational_nt(src_geometry, rec_geometry, model)
info = Info(prod(model.n), nsrc, ntComp)

# Set up modeling options
opt = Options(save_data_to_disk = true, file_path = "./records", file_name = "brain_3D_shot")

# Set up operators
Pr = judiProjection(info, rec_geometry)
Ps = judiProjection(info, src_geometry)
A_inv = judiModeling(info, model; options=opt)
q = judiVector(src_geometry, wavelet)

# Generate data and save as individual SEG-Y files to disk
d_obs = Pr * A_inv * adjoint(Ps) * q

```

I have tried to install Devito4.3, Julia v0.6.4, v0.7.0, v1.4.2, v1.5.0, v1.5.4, v1.6.1 and installed JUDI subsequently, but it seems none of the Julia version above can run the code.  
The error output is:  
ERROR: LoadError: MethodError: no method matching Float32(::Vector{Float64})  
Closest candidates are:  
(::Type{T})(!Matched::AbstractChar) where T\<:Union{AbstractChar, Number} at char.jl:50  
(::Type{T})(!Matched::Base.TwicePrecision) where T\<:Number at twiceprecision.jl:243  
(::Type{T})(!Matched::Complex) where T\<:Real at complex.jl:37  
…  
Stacktrace:  
[1] \_broadcast\_getindex\_evalf  
@ ./broadcast.jl:648 [inlined]  
[2] \_broadcast\_getindex  
@ ./broadcast.jl:621 [inlined]  
[3] getindex  
@ ./broadcast.jl:575 [inlined]  
[4] copy  
@ ./broadcast.jl:922 [inlined]  
[5] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{Float32}, Tuple{Vector{Vector{Float64}}}})  
@ Base.Broadcast ./broadcast.jl:883  
[6] top-level scope  
@ /media/hp/46E0111EE0111631/jktong/brain\_3D/Brain\_3D\_forward\_new.jl:26  
if I change line 26-line 29 into  
xrec = xsrc  
yrec = ysrc  
zrec = zsrc  
it will prompt: MethodError: no method matching Geometry  
PS: my python version is Python 3.8.9.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [July 15, 2021, 2:54pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/2 "2021-07-15T14:54:32Z")

</div>

Please use three backtics (```) to proceed and follow your code when pasted into the thread.  
It will format the code correctly, making it much easier to help.

I suspect that the solution is to replace `Float32(::Vector{Float64})` with `Float32.(::Vector{Float64})`,  
which would make sense if for instance `xsrc` was a vector of vectors.

---

<div class="post-metadata">

**Author:** ![tjk](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tjk](https://discourse.julialang.org/u/tjk)\
**Post date:** [July 15, 2021, 3:38pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/3 "2021-07-15T15:38:31Z")

</div>

Thanks for your help! As can be seen from line 26 of the code，we have already used Float32. to convert the variables:

```julia
xrec = Float32.(xsrc)
yrec = Float32.(ysrc)
zrec = Float32.(zsrc)

```

But the it did not solve the problem

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 15, 2021, 3:43pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/4 "2021-07-15T15:43:27Z")

</div>

but you should be getting different errors now right? can you post the error again?

---

<div class="post-metadata">

**Author:** ![tjk](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tjk](https://discourse.julialang.org/u/tjk)\
**Post date:** [July 15, 2021, 3:57pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/5 "2021-07-15T15:57:47Z")

</div>

No，the error messages are the same…  
We used Float32. in the beginning，I did not add ``` before the code at first so the code didn’t format correctly.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [July 15, 2021, 4:05pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/6 "2021-07-15T16:05:59Z")

</div>

Can you give an output of `typeof(xsrc)`?

---

<div class="post-metadata">

**Author:** ![jjoravet](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jjoravet](https://discourse.julialang.org/u/jjoravet)\
**Post date:** [June 4, 2022, 1:39pm UTC](https://discourse.julialang.org/t/which-version-of-julia-can-run-the-following-codes/64695/7 "2022-06-04T13:39:59Z")

</div>

Hi,

You might try visiting the GitHub slimgroup repository (**[https://github.com/slimgroup/JUDI.jl](https://github.com/slimgroup/JUDI.jl)**) and read the “Running with Docker”  
information. It’s possible to pull the stated docker image and initiate a jupyter notebook to execute your code. For example: **docker run -p 8888:8888 mloubout/judi:1.7-latest** should execute and list a URL for an interactive jupyter notebook session. You could paste your code in a cell for testing and debugging.

You could also try executing additional demo scripts from the slimgroup and others for learning and reference.

Without access to the Brain model and source geometry files, it would otherwise be difficult to debug or advise.

Good luck - hope it helps.
