Demonstrate that Matlab MEX Fortran compiler wrapper is working on your system with the following commands. Ensure you are using a supported compiler with Matlab as the supported compilers are distinct across operating systems. These commands are all from within Matlab.
Setup Matlab Fortran compiler
Configure Matlab for Fortran compiler:
mex -setup -v FORTRAN
Verify configuration by
Example Fortran MEX
copy over an example Fortran program.
copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.F'), pwd) copyfile(fullfile(matlabroot,'extern','include','fintrf.h'), pwd)
use the compiled code
ans = 6.0
You may need additional Matlab compiler configuration if you get compiler errors like:
... Looking for folder 'libgfortranbegin.a' ...No. Did not find installed compiler 'gfortran'. Error using mex No supported compiler or SDK was found. For options, visit https://www.mathworks.com/support/compilers/current_release/.
Windows MEX Fortran
Matlab and Fortran on Windows can use the Intel Fortran compiler.
GNU Octave and Gfortran MEX are available on Windows, MacOS and Linux.