mex -setup cannot find ifort on Mac

6 vues (au cours des 30 derniers jours)
Haomin Wang
Haomin Wang le 27 Déc 2021
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 commentaire
dpb
dpb le 27 Déc 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?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 31 Déc 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

Plus de réponses (1)

Anshika Chourasia
Anshika Chourasia le 31 Déc 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.

Catégories

En savoir plus sur Fortran with MATLAB dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by