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

조회 수: 12 (최근 30일)
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.

답변 (1개)

Maneet Kaur Bagga
Maneet Kaur Bagga 2024년 3월 29일
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
Adrian Cherry
Adrian Cherry 2024년 4월 4일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by