MATLAB - Fortran interface

Thanks @shahmoradi.
I have a Fortran code for solving stiff differential equations. Matlab also has it - ode23s, but it is orders of magnitude slower than Fortran implementation.
Just to outline it’s working -
I have 3 stiff set of odes and are to be integrated together wrt time (independent variable).
My solver takes time steps t and t+1 and 3 dependent variables from the previous step (t) as input and solves for 3 dependent variables at t+1 as output.
To be more clear on C-interop, do I just need to define the interface such that on my Fortran side I expose the inputs and outputs to the c-mex file and rest of the workings (variables and subroutines and function) can be in Fortran ? Or should I change some internal workings also ? In other words, should my c-mex file know anything other than inputs and outputs ?

1 Like