Matlab Fortran MEX setup

Test that Matlab MEX C / C++ compiler wrapper is working on your system with a supported compiler. These commands are all from within Matlab.

Setup Matlab for Fortran compiler:

mex -setup -v fortran

Verify configuration by

mex.getCompilerConfigurations('fortran')

Copy over an example Fortran program.

copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.F'), pwd)
copyfile(fullfile(matlabroot,'extern','include','fintrf.h'), pwd)

Compile:

mex timestwo.F

Run:

timestwo(3)

ans = 6.0

If problems, check Matlab compiler setup.

Matlab and Fortran on Windows can use Intel oneAPI to compile Fortran.

GNU Octave and Gfortran MEX are available on Windows, macOS and Linux.