From: tlaloc on
I am running MATLAB 7.0 (R14) on a mac (OS X 10.4.5) and tried to
compile a mex file using the free fortran compiler g95 (btw g95 works
fine on my system when used
from the command line). I edited the mexopts.sh file in ~/.matlab as
Aaron Schmidt's post (http://g95.sourceforge.net/howto.html#matlab)
suggested. However, unlike him I have had no success yet.
The modified lines in the mexopts.sh file look like this

FC='/usr/local/g95-install/bin/powerpc-apple-darwin6.8-g95'
FFLAGS='-ffree-form'
FLIBS='-L/usr/local/g95-install/lib/gcc-lib/powerpc-apple-darwin6.8/4.0.1/
-lf95'
FOPTIMFLAGS='-O'
FDEBUGFLAGS='-g'

And when running the matlab supplied test example
mex -v yprimef.f yprimefg.f

I do get the following error:
-----------------------------------------------------------------------------------------------------------------------
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /Users/Markus/.matlab/R14/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB7
-> CC = gcc-3.3
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O3 -DNDEBUG
CLIBS = -L/Applications/MATLAB7/bin/mac -lmx
-lmex -lmat -lstdc++
arguments =
-> CXX = g++-3.3
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O3 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB7/bin/mac -lmx
-lmex -lmat -lstdc++
arguments =
-> FC =
/usr/local/g95-install/bin/powerpc-apple-darwin6.8-g95
-> FC flags:
FFLAGS = -ffree-form
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS =
-L/usr/local/g95-install/lib/gcc-lib/powerpc-apple-darwin6.8/4.0.1/
-lf95
arguments =
-> LD = gcc-3.3
-> Link flags:
LDFLAGS = -bundle -Wl,-flat_namespace -undefined
suppress
-Wl,-exported_symbols_list,/Applications/MATLAB7/extern/lib/mac/fexport.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmac
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------

-> /usr/local/g95-install/bin/powerpc-apple-darwin6.8-g95 -c
-I/Applications/MATLAB7/extern/include -ffree-form -O yprimef.f

In file yprimef.f:1

C The actual YPRIME subroutine in FORTRAN
1
Error: Unclassifiable statement at (1)
In file yprimef.f:2

C
1
Error: Unclassifiable statement at (1)
In file yprimef.f:3

C Copyright 1984-2000 The MathWorks, Inc.
1
Error: Unclassifiable statement at (1)
In file yprimef.f:4

C $Revision: 1.4 $
1
Error: Unclassifiable statement at (1)
In file yprimef.f:5

C
1
Error: Unclassifiable statement at (1)
In file yprimef.f:19

YP(2) = 2*Y(4) + Y(1) - MUS*(Y(1)+MU)/(R1**3) -
1
Error: Syntax error in expression at (1)
In file yprimef.f:20

& MU*(Y(1)-MUS)/(R2**3)
1
Error: Unclassifiable statement at (1)
In file yprimef.f:23

YP(4) = -2*Y(2) + Y(3) - MUS*Y(3)/(R1**3) -
1
Error: Syntax error in expression at (1)
In file yprimef.f:24

& MU*Y(3)/(R2**3)
1
Error: Unclassifiable statement at (1)

mex: compile of 'yprimef.f' failed.

??? Error using ==> mex
Unable to complete successfully

------------------------------------------------------------------------------------

I suspect it might have to do with the library link. Does anyone have
an idea? Maybe it's really trivial, but I am fairly new to this.

thanks a lot.

From: Richard Maine on
tlaloc <mfrey(a)hwr.arizona.edu> wrote:

> FFLAGS='-ffree-form'

Why did you specifically tell it free form? Looks to me like the errors
are typical of those I would expect from trying to interpret fixed
source form as free form. In particular, I notice many of the errors
appear to be about lines that look like fixed source formcomment lines.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
From: tlaloc on
thanks a lot, changing the flag to -ffixed-form helped. so g95 runs
fine now.

Markus.