Now to call **savgol()** from Julia requires some information, namely what the interface to the subroutine looks like. The Fortran 90 code for the subroutine header looks something like this:

subroutinesavgol(c,np,nl,nr,ld,m)integerld,m,nl,np,nrrealc(np)

It specifies 6 parameters, the first of which is an array of **real** numbers, and the remaining five of which are** integer**‘s. The variable **c** returns an array of coefficients (to be used for further processing). So the trick is to associate the parameters in **savgol()** with their associated input values in **ccall()**. This is what the call the **ccall()** looks like:

ccall((:savgol_, "SG.so"), Int32, (Ptr{Cfloat},Ptr{Cint}, Ptr{Cint},Ptr{Cint},Ptr{Cint},Ptr{Cint}), c, &d, &nl, &nr, &0, &m)

Recall that a call to **ccall()** has four arguments:

- A “function” – library pair. This is
**savgol_**and**“SG.so”**. - A return type –
**Int32**in this case, but the subroutine does not return anything. - A tuple of input values. In this case
**Ptr{Float}**, etc. - The arguments actually passed to
**savgol()**.

Note that unlike C, all Fortran arguments must be passed by reference, hence the use of **Ptr{}** on all the arguments. The tricky part was again linking the datatypes, but this really just means tracing the required Julia type which can be found here. The Fortran **integer** type meshes well with **Cint**, and the Fortran **real** type associates with Julia’s **Cfloat**.

There isÂ a cornucopia of existing libraries out there in Fortran, especially for math… why not use them?