I have a mex -setup file for Intel oneAPI 24 FORTRAN ifort which reports success but mex still insists on running gfortran to compile

20 views (last 30 days)
The attached file runs sucessfully in mex setup and reports
MEX configured to use 'Intel oneAPI 2024 for Fortran with Microsoft Visual Studio 2022' for FORTRAN language compilation.
It then sets my roaming profile AppData\Roaming\MathWorks\MATLAB\R2023b\mex_FORTRAN_win64.xml with the following information
COMPILER="ifort"
CMDLINE100="$COMPILER
FORTRANROOT="C:\Program Files (x86)\Intel\oneAPI\2024.0"
Yet when I run mex it insists on looking for gfortran!
>> mex -v -R2018a timestwo.F
Verbose mode is on.
... Looking for compiler 'gfortran' ...
... Looking for environment variable 'MINGWROOT' ...No.
... Looking for file '$$\bin\gfortran.exe' ...No.
Did not find installed compiler 'gfortran'.
Any pointers for getting it to run the ifort compiler would be appreciated.

Answers (1)

Maneet Kaur Bagga
Maneet Kaur Bagga on 29 Mar 2024 at 8:48
Hi,
As per my understanding you want to compile a Fortran File using the mex command with the verbose mode enabled (mex -v -R2018a twotimes.F), and MATLAB does not attempt to use the configures "ifort" compiler and it looks for the "gfort" compiler which is not found.
One of the possible workarounds for this is as follows:
Firstly Please refer to the following documentation to refer to the Supported and Compatible Compilers and check if you have all the requirements already setup:
  • Edit "/usr/local/MATLAB/R2016b/bin/glnxa64/mexopts/gfortran.xml"
  • In the line beginning with "LINKLIBS=..." remove both references to gfortranbegin
  • Add "-lgcc_s.1" to the end of that line inside the quotes
  • At the bottom of the file, within the "GFORTRANBEGIN_LIBDIR" block, replace 'dirExists name="$$"' with 'dirExists name="/"'.
  • Save the file and set up the Fortran compiler as normal. This worked for me on Gentoo using gfortran 8.2.0-r6.
The following MATLAB Asnwer has a similar workaround. Please refer to the link below for further understanding:
Hope this helps!
  1 Comment
Adrian Cherry
Adrian Cherry on 4 Apr 2024 at 7:24
Thanks for the reply, I have ifort working perfectly well on Linux, I should have specified this is for Windows platform and for various reasons I want to use the Intel ifort (or ifx) compiler not gfortran.

Sign in to comment.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!