# Sundials.jl --\> LoadError: TypeError: in cfunction, expected Union{}, got Int32

**URL:** <https://discourse.julialang.org/t/sundials-jl-loaderror-typeerror-in-cfunction-expected-union-got-int32/25059>\
**Category:** General Usage\
**Created:** [June 7, 2019, 10:50pm UTC](https://discourse.julialang.org/t/sundials-jl-loaderror-typeerror-in-cfunction-expected-union-got-int32/25059 "2019-06-07T22:50:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boris\_Penaloza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boris_penaloza/32/8800_2.png) [@Boris\_Penaloza](https://discourse.julialang.org/u/Boris_Penaloza)\
**Post date:** [June 7, 2019, 10:50pm UTC](https://discourse.julialang.org/t/sundials-jl-loaderror-typeerror-in-cfunction-expected-union-got-int32/25059/1 "2019-06-07T22:50:23Z")

</div>

Hello guys,  
I am trying to solve a ODE using the CVODE\_BDF() solver of the Sundials package. Here is a snippet of my code:

# Defining the function

function f(dX, X, p, t)  
#A, B, D, E, Inh = p  
#dX = -A\*X + (B - X)\*E - (D + X)\*Inh  
dX[1] = -p[1]\*X[1] + (p[2] - X[1])\*p[4] - (p[3] + X[1])\*p[5]

```
# in case there are more than one output neuron
#for i = 1:length(X)
# dX[i] = -A*X[i] + (B - X[i])*E - (D + X[i])*Inh
#end
return dX[1]

```

end

# ODE

x0 = Array{Float64}(undef, 1)  
fill!(x0, X0) # fill array with initial values  
#x0 = X0  
p = [2.0, 253.0, 16.0, Ex, Inh]  
tspan = (0.0,0.5)  
prob = ODEProblem(f,x0,tspan,p)  
sol = solve(prob,CVODE\_BDF(linear\_solver=:Dense))  
plot(sol)

#Unfortunately, I am getting this Error:

LoadError: TypeError: in cfunction, expected Union{}, got Int32

in expression starting at /Users/Boris/Documents/adaptive\_CS.jl:70

\_\_CVode at cvodes.jl:312 [inlined]

CVode(::Sundials.Handle{Sundials.CVODEMem}, ::Float64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int32) at cvodes.jl:317

#I don’t understand what is going on. Can someone help with this? I will appreciate it.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 8, 2019, 1:17am UTC](https://discourse.julialang.org/t/sundials-jl-loaderror-typeerror-in-cfunction-expected-union-got-int32/25059/2 "2019-06-08T01:17:49Z")

</div>

Can you do `]st` and post your package versions? Do you happen to be using a 32-bit OS?

---

<div class="post-metadata">

**Author:** ![Boris\_Penaloza](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boris_penaloza/32/8800_2.png) [@Boris\_Penaloza](https://discourse.julialang.org/u/Boris_Penaloza)\
**Post date:** [June 10, 2019, 5:54pm UTC](https://discourse.julialang.org/t/sundials-jl-loaderror-typeerror-in-cfunction-expected-union-got-int32/25059/3 "2019-06-10T17:54:41Z")

</div>

Hey Chris,  
Thanks for the reply. For some reason the code [sol = solve(prob,CVODE\_BDF(linear\_solver=:Dense))] works perfectly fine now. I just restarted Atom I guess. For the record I am using Julia version 1.1.1 on a MacBook air 64-bit.
