# Help with updating fortran wrapper

**URL:** <https://discourse.julialang.org/t/help-with-updating-fortran-wrapper/86221>\
**Category:** General Usage\
**Tags:** fortran\
**Created:** [August 23, 2022, 8:15pm UTC](https://discourse.julialang.org/t/help-with-updating-fortran-wrapper/86221 "2022-08-23T20:15:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackDunnNZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jackdunnnz/32/3749_2.png) [@JackDunnNZ](https://discourse.julialang.org/u/JackDunnNZ)\
**Post date:** [August 23, 2022, 8:15pm UTC](https://discourse.julialang.org/t/help-with-updating-fortran-wrapper/86221/1 "2022-08-23T20:15:00Z")

</div>

I maintain the [GLMNet.jl](https://github.com/JuliaStats/GLMNet.jl) package, which wraps the fortran internals of the [glmnet](https://cran.r-project.org/web/packages/glmnet/index.html) R package. This fortran dependency is shipped as glmnet\_jll, and currently uses the version built [here](https://github.com/JuliaPackaging/Yggdrasil/blob/2ef51824a420a6366377b3485c82de21d1ccec6f/G/glmnet/build_tarballs.jl)

This version of the fortran code dates from 2014, and there have been a number of updates since, so I would like to update the JLL to build the latest version of the code, however I am running into problems with the resulting binary. I am not the original developer of the package and know next to nothing about fortran so am not sure what is going wrong.

I had already updated the JLL to use a more recent source a while ago ([here](https://github.com/JuliaPackaging/Yggdrasil/blob/master/G/glmnet/build_tarballs.jl)) which builds successfully, but when the resulting library is used from the existing GLMNet.jl, it runs into a segfault:

```julia
(GLMNet) pkg> test
...
     Testing Running tests...

signal (11): Segmentation fault: 11
in expression starting at /private/tmp/GLMNet.jl/test/runtests.jl:16
getindex at ./array.jl:924 [inlined]
#glmnet!#10 at /private/tmp/GLMNet.jl/src/GLMNet.jl:264
glmnet! at /private/tmp/GLMNet.jl/src/GLMNet.jl:271
#glmnet#40 at /private/tmp/GLMNet.jl/src/GLMNet.jl:485 [inlined]
glmnet at /private/tmp/GLMNet.jl/src/GLMNet.jl:485 [inlined]
#glmnet#41 at /private/tmp/GLMNet.jl/src/GLMNet.jl:487
glmnet at /private/tmp/GLMNet.jl/src/GLMNet.jl:487 [inlined]
glmnet at /private/tmp/GLMNet.jl/src/GLMNet.jl:487

```

The line it is crashing on is [this one](https://github.com/JuliaStats/GLMNet.jl/blob/8eff4c4f07374c6f6f7878b16dc02e90d444e9a1/src/GLMNet.jl#L264), where it tries to access `alm` to get results after calling the fortran code. Right above this, it accessed the value of `lmu_ref` which was also passed into the fortran code, so some parts seem to be working. I am wondering if there is something about the `ccall` that needs to be updated, but don’t know enough about fortran to know what to try next.

To help narrow the problem, I bisected the fortran code inside the glmnet R package to find which changes led to this error, and found that the last working version was [`2.0-13`](https://github.com/cran/glmnet/blob/2.0-13/src/glmnet5.f90) and was broken in [`2.0-16`](https://github.com/cran/glmnet/blob/2.0-16/src/glmnet5dp.f). I added the fortran files and a cleaned diff to a gist here:

> <https://gist.github.com/JackDunnNZ/f551fe378aa2c5186255cd936817981b>

Most of the changes seem to be updating the type declarations from `real` to `double precision`, which I think is supposed to be a no-op (all the relevant variables were/are passed as `Ref{Float64}`)

I would appreciate any guidance or help in getting this working!

---

<div class="post-metadata">

**Author:** ![viralbshah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viralbshah/32/54_2.png) [@viralbshah](https://discourse.julialang.org/u/viralbshah)\
**Post date:** [August 23, 2022, 9:55pm UTC](https://discourse.julialang.org/t/help-with-updating-fortran-wrapper/86221/2 "2022-08-23T21:55:16Z")

</div>

Is there a branch with these changes?

-viral

---

<div class="post-metadata">

**Author:** ![JackDunnNZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jackdunnnz/32/3749_2.png) [@JackDunnNZ](https://discourse.julialang.org/u/JackDunnNZ)\
**Post date:** [August 23, 2022, 10:16pm UTC](https://discourse.julialang.org/t/help-with-updating-fortran-wrapper/86221/3 "2022-08-23T22:16:14Z")

</div>

I just pushed a branch to [GitHub - JuliaStats/GLMNet.jl at jd/jll](https://github.com/JuliaStats/GLMNet.jl/tree/jd/jll)

The only change is altering the compat for glmnet\_jll
