Clear Filters
Clear Filters

mex -setup cannot find ifort on Mac

5 views (last 30 days)
I'm using matlab R2020b and I have Intel® Parallel Studio XE Composer Edition for Fortran macOS* 2019 installed.
When I run the command
mex -setup -v Fortran
I get the following
Verbose mode is on.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'IFORT_COMPILER20' ...No.
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Executing command 'which ifort' ...No.
Did not find installed compiler 'Intel Fortran Composer XE'.
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
If I run the command "which ifort" in my terminal, I get
/usr/local/bin/ifort
I don't understand why matlab doesn't find my ifort compiler. Any help is appreciated!
  1 Comment
dpb
dpb on 27 Dec 2021
It appears it's looking for specific versions -- with one of the specific environment variables above for a match and either the version installed isn't one of those or the "Composer XE" install didn't create the environment variable it should have.
The first message makes it look like it does know the Intel Fortran is installed; just a version mismatch in that you have an unsupported version. TMW is way overly persnickity in the way the setup works based on what they support and don't...
I don't have Mac nor Intel Fortran so can't poke around and see much here, what do you get if you run the compiler with it's -version flag for comparison, and what Intel Fortran environment variables do exist?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 31 Dec 2021
It looks to me as if /usr/local/bin is not on your PATH during the mex command.
When a program is launched from an icon, it inherits only the basic system environment variables, and any setup that would normally be done in shells such as ~/.bash_profile is not executed -- because bash is not executed while launching a program from icon.
The system PATH environment variable is pretty sparse.
You might be able to modify a system plist file:
On the other hand, mex does, if I recall, invoke the shell to process the commands, so you might be able to setenv() at the MATLAB level.
With earlier MacOS versions you could have just linked /usr/bin/ifort to the appropriate location, but Big Sur and later seal some system directories and getting a permanent change into them is a nuisance.
Setting IFORT_COMPILER20 instead of setting PATH to be able to find ifort is probably a better idea (as suggested by @Anshika Chourasia ) -- but you might still need tricks to push it into the environment. It might be easier to put a setenv() call into your setup.m

More Answers (1)

Anshika Chourasia
Anshika Chourasia on 31 Dec 2021
Hi Haomin,
The issue could be that MATLAB is not able to pick the FORTRAN compiler. Setting a environment variable should fix this issue. If you are using Intel FORTRAN 2020 set the environment variable ‘IFORT_COMPILER20’ to the original installation folder of the compiler.
Also, please note that the environment variable needs to be the actual installation folder and not a symbolic link for MATLAB R2020b.

Categories

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

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!