MATLAB R2022a: MEX does not support intel fortran OneApi 2022

61 views (last 30 days)
I have installed Matlab R2022a, Intel OneApi HPC toolkit 2022 and Visual Studio Community 2022 in order to run MEX command to compile a fortran code but MEX apparently is not able to set some variables throught he command vswhere.exe. I am posting down here what MEX command says in verbose mode. If anyone can help, it would be appreciated. Thanks.
mex -R2018a subtest.f90 -v
Verbose mode is on.
No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'Intel Parallel Studio XE 2018 for Fortran with Microsoft Visual Studio 2015' ...
... Looking for environment variable 'IFORT_COMPILER18' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2018 for Fortran with Microsoft Visual Studio 2015'.
... Looking for compiler 'Intel Parallel Studio XE 2018 for Fortran with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'IFORT_COMPILER18' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2018 for Fortran with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel Parallel Studio XE 2018 for Fortran with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'IFORT_COMPILER18' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2018 for Fortran with Microsoft Visual Studio 2019'.
... Looking for compiler 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2015' ...
... Looking for environment variable 'IFORT_COMPILER19' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2015'.
... Looking for compiler 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'IFORT_COMPILER19' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'IFORT_COMPILER19' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2019'.
... Looking for compiler 'Intel Parallel Studio XE 2020 for Fortran with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'IFORT_COMPILER20' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2020 for Fortran with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel Parallel Studio XE 2020 for Fortran with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'IFORT_COMPILER20' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2020 for Fortran with Microsoft Visual Studio 2019'.
... Looking for compiler 'Intel oneAPI 2021 for Fortran with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'IFORT_COMPILER21' ...Yes ('C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows\').
... Looking for file 'C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows\Bin\intel64\ifort.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
Did not find installed compiler 'Intel oneAPI 2021 for Fortran with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel oneAPI 2021 for Fortran with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'IFORT_COMPILER21' ...Yes ('C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows\').
... Looking for file 'C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows\Bin\intel64\ifort.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Intel\oneAPI\compiler\2022.0.3\windows' ...Yes.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...No.
Did not find installed compiler 'Intel oneAPI 2021 for Fortran with Microsoft Visual Studio 2019'.
Error using mex
Supported compiler not detected. For options, visit https://www.mathworks.com/support/compilers.
  1 Comment
Riccardo Scorretti
Riccardo Scorretti on 6 May 2022
Hi. I had a similar nasty problem with another software (= the library CGAL). The solution that I have found is to embed the computational part of my program into a library. Then, on MATLAB side, I wrote a mex-file which simply calls the (only) function of the library I generated. It works fine because you can compile the mex-file from MATLAB in the usual way, and the complicate program with its own tools (in my case, cmake + make and gcc).

Sign in to comment.

Accepted Answer

Domenico Coiro
Domenico Coiro on 7 May 2022
Thanks for the suggestion but I solved the problem.
it is necessary to change the mex configuration file for the specific compiler found in the folder C:\ProgramFiles\MATLAB\R2022a\bin\win64\mexopts\ which in my case is:
C:\ProgramFiles\MATLAB\R2022a\bin\win64\mexopts\intel_fortran_21_vs2019.xml
Open it with a text editor and looking for the lines containing the string [16.0,17.0) and change this to [16.0,18.0) since this option, used in the command vswhere.exe, check the version of the compiler in the range specified and if the compiler has a version higher than17 (which is the case for latest OneApi HPC) it does not find it! In theory you need to change this line only in the row which relates to your Visual Studio type of installation (for example Microsoft.VisualStudio.Product.Community) but if it is done everywhere is better.
It should be performed the same operation for the file "C:\Users\.......\AppData\Roaming\MathWorks\MATLAB\R2022a\mex_FORTRAN_win64.xml" for fortran compilers or similar file for other compilers.
After this, MEX command works fine.
  3 Comments
Domenico Coiro
Domenico Coiro on 17 Aug 2022
Hi Ines. I do not think that this type of error is connected to the installation of codes; it rather seems connected to your function NUFFT2D1F90 which is seen by the compoiler as an external symbol and is not recognized as external function (as it appers to be...). Maybe you shold declare it as external function....
Ciao
Domenico
Don Loflin
Don Loflin on 15 Oct 2022
Rather than just edit the existing file, I copied intel_fortran_21_vs2019.xml to intel_fortran_22_vs2022.xml, and changed the VS version in that, as well as changing IFORT_COMPILER21 to IFORT_COMPILER22.
Put it in "C:\Program Files\MATLAB\R2022a\bin\win64\mexopts" and then mex -setup fortran should succeed (the attached file ends in .xml.txt, rename to just .xml)
Mathworks please make additional mexopts files like this available for download somewhere. The Intel oneAPI 2021 Fortran compiler is no longer available for download.

Sign in to comment.

More Answers (0)

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!