Hello,
I am using MATLAB 2019a and trying to create a MEX file from Fortran code.
My Fortran compiler is 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2017'.
The MEX configuration has a default compiler switch /integer-size:64. However, I have some legacy Fortran code, where integers are not explicitly declared, and I don't want these to be taken as 64-bit integers. So, I try to override this by
mex -v COMPFLAGS='$COMPFLAGS /integer-size:32' -largeArrayDims filename
But this results in the command line
ifort /c /nologo /fpp /Qprec /MD /fp:source /assume:bscc -I"C:\Program Files\MATLAB\R2019a\extern\include" /DMX_COMPAT_64 /DMATLAB_DEFAULT_RELEASE=R2017b /DUSE_MEX_CMD /DMATLAB_MEX_FILE /integer-size:32 /integer-size:64 /O2 /DNDEBUG filename
where somehow the compiler switch /integer-size:64 gets stuck in after my switch, and I get the warning,
ifort: command line warning #10121: overriding '/integer-size:32' with '/integer-size:64'
I am not finding the /integer-size switch in my mex_FORTRAN_win64.xml file, and I don't know what is causing it to get appended.
Any advise on how I could stop that switch from getting appended to the commandline, or how I could override it?
Thank you.
Siva

댓글 수: 8

Walter Roberson
Walter Roberson 2019년 8월 2일
편집: Walter Roberson 2019년 8월 2일
On Mac, there is a switch generated automatically that is incompatible with gfortran. I ended up having to write a some filter code named after the compiler that removed the option and then passed the rest of the command line to the real gfortran compiler.
James Tursa
James Tursa 2019년 8월 2일
편집: James Tursa 2019년 8월 2일
Sigh ... TMW should have never put that switch in there in the first place, for this very reason. Better to let the users decide for themselves what they want default integers to be.
Siva
Siva 2019년 8월 2일
Thank you Walter and James for your input.
I made a batch file with the compile and link command lines, with the proper switches, and ran it in the Intel Fortran console in Windows (where paths and environment variables have been appropriately set).
This seems to work. I will probably write a makefile, and I am hoping this will work for my purposes now.
It will still be better if some configuration can be changed, so that I can execute mex from the MATLAB environment.
dpb
dpb 2019년 8월 2일
TMW has made such a mess of mex by trying to be too clever by half. :(
They should just tell folks how to compile and have a simple batch file that is user-accessible AND FULLY DOCUMENTED.
James Tursa
James Tursa 2019년 8월 2일
I guess one improvement is that I don't see the /fixed option anymore. Did TMW finally get rid of it?
Siva
Siva 2019년 8월 2일
I was able to remove the /fixed switch in the configuration file.
James Tursa
James Tursa 2019년 8월 2일
Oh, you did that one yourself. Guess I was hoping for too much ...
dpb
dpb 2019년 8월 2일
Hope is about all there is for TMW ever doing anything really useful with the mex interface it seems...
I railed at them extensively 20+ years ago and all fell on totally deaf and apparently completely disinterested ears...

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

 채택된 답변

Siva
Siva 2019년 8월 4일
편집: Siva 2019년 8월 4일

1 개 추천

This is what I ended up doing.
  1. Following https://www.mathworks.com/help/matlab/matlab_external/using-mex-script-options-to-custom-build.html, mex -v -n filename
  2. Get the list of command lines
  3. Make a batch file or makefile, adding/deleting compiler switches
Although not as convenient as simply being able to use mex in the MATLAB environment, this seems to give the necessary flexibility. Perhaps this is the intention of Mathworks.
This is simple enough, but just wanted to post it as an accepted answer to close this question.
Thank you all for your input.
Siva

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

질문:

2019년 8월 2일

편집:

2019년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by