# How to Get Outputs from ccall

**URL:** <https://discourse.julialang.org/t/how-to-get-outputs-from-ccall/42864>\
**Category:** General Usage\
**Created:** [July 10, 2020, 6:42pm UTC](https://discourse.julialang.org/t/how-to-get-outputs-from-ccall/42864 "2020-07-10T18:42:40Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [July 10, 2020, 8:10pm UTC](https://discourse.julialang.org/t/how-to-get-outputs-from-ccall/42864/3 "2020-07-10T20:10:45Z")

</div>

This looks like a Fortran library, so the following note from the manual here: [Calling C and Fortran Code · The Julia Language](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/) applies:

> When calling Fortran, all inputs must be passed by pointers to heap- or stack-allocated values, so all type correspondences above should contain an additional `Ptr{..}` or `Ref{..}` wrapper around their type specification.

There’s more information about wrapping Fortran subroutines here: [Calling C and Fortran Code · The Julia Language](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#When-to-use-T,-Ptr%7BT%7D-and-Ref%7BT%7D-1)

And another related question here: [Calling fortran function - #8 by simonbyrne](https://discourse.julialang.org/t/calling-fortran-function/2288/8)

Basically, all of your input types in the `ccall` should be `Ref{Cdouble}`, `Ref{Cint}`, etc. The return type must be `Cvoid` because Fortran subroutines don’t return anything in the sense we’re talking about.

I would suggest starting with a _much_ simpler example to get an idea of what’s going on. If you can write your own Fortran code, start with a subroutine with one argument and make sure you can call it correctly, then try a subroutine with one input and one output. If you can’t, then maybe you can start with a simpler function in the same library, just to get a sense of what’s going on.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-get-outputs-from-ccall/42864)._
