How to Get Outputs from ccall

This looks like a Fortran library, so the following note from the manual here: Calling C and Fortran Code · The Julia Language 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

And another related question here: Calling fortran function - #8 by simonbyrne

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.

2 Likes