MATLAB: Fortran 90 mex on Mac

fortran 90free form sourcegfortranmacmex -setupxcode 3.2

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)

Best Answer

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