필터 지우기
필터 지우기

fortran 90 mex on Mac

조회 수: 3 (최근 30일)
Petar Bakalov
Petar Bakalov 2011년 10월 24일
I have some fortran 90 code and I have written a mex gateway function for it. Everything compiled and worked OK under Windows. Now I tried compiling on a mac and I run into some problems.
First hurdle was making mex work with the provided examples (yprimef.F). Thanks to some previous posts, after editing my mexopts.sh, I managed to compile and the example seems to work OK.
However, when I try to mex my .f90 files (which are in free-form source), I get the following:
Warning: FD_CVg.f90:1: Illegal preprocessor directive
Warning: FD_CVg.f90:56: Illegal preprocessor directive
Warning: FD_CVg.f90:67: Illegal preprocessor directive
FD_CVg.f90:17.6:
MWPOINTER PLHS(*), PRHS(*)
1
Error: Unclassifiable statement at (1)
FD_CVg.f90:27.6:
MWPOINTER MXCREATEDOUBLEMATRIX, MXGETPR
1
Error: Unclassifiable statement at (1)
FD_CVg.f90:32.6:
MWSIZE MXGETM, MXGETN
1
Error: Unclassifiable statement at (1)
FD_CVg.f90:41.6:
MWPOINTER tp,ndp,nap,edp,eap,eoxp,toxp,skindp,qfp,fmp,vgminp, &
1
Error: Unclassifiable statement at (1)
FD_CVg.f90:49.6:
MWSIZE M, N, NEL
1
Error: Unclassifiable statement at (1)
... and so on ...
the lines 1, 56 and 67 that trigger warnings are:
#include <fintrf.h>
#if defined MSWIND
#endif
respectively.
Any suggestions how to fix that?
(Using gfortran with xcode 3.2 on Mac OS X 10.6.8 with 64 bit matlab)

채택된 답변

fabio freschi
fabio freschi 2011년 10월 29일
The preprocessor directives are not recognized. If your gfortran version supports the -cpp (C PreProcessor) flag, use it. Otherwise just change the file extension to F90 (uppercase F): the preprocessor is automatically invoked.
Fabio
  댓글 수: 1
Petar Bakalov
Petar Bakalov 2011년 11월 3일
Hello,
I checked, and indeed, changing the extension to F90 allows the mex to compile. Many thanks for that!
However, when I call the mex function ML crashes. (In the meantime I tinkered further with my mexopts.sh file, and now also the example mex-function yprime causes ML to crash, even though it seems to compile fine.)
In any case, the original problem of the post is solved, and I will start another thread for the rest.

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

추가 답변 (3개)

James Tursa
James Tursa 2011년 10월 24일
Is there a "/fixed" option (or similar) on the COMPFLAGS line in the mexopts file? If so, remove it. That is the typical problem with compiling free format source code on PC's. Don't know if this applies to mac or not.

Petar Bakalov
Petar Bakalov 2011년 10월 25일
I looked for something of the kind in the mexopts.sh file, and also checked a few other options files in /Applications/MATLAB_R2011b.app/bin, but didn't find anything.
Further suggestions would be appreciated, as it would be somewhat tedious translating all the code to fixed form... (I assume that not only the gateway function, but also the subroutines called from it would have to be rewritten.)

Petar Bakalov
Petar Bakalov 2011년 10월 29일
Thanks for the tip, Fabio. I will try this when I have the mac on Monday and let you know whether it worked out.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by