From: ksept Solis on
Similarly, does anybody happens to know the steps to mix matlab 7.5.0 with fortran using a Windows OS (win 32), and with fortran compilers either g95 or
Silverfrost FTN95?

"Ben Abbott" <bpabbott(a)mac.com> wrote in message <ef5bcac.-1(a)webcrossing.raydaftYaTP>...
> As a mac user who has been less than thrilled with Absoft's support
> of their compilers (imo, asking a paying customer to purchase the
> next version is not an acceptable manner to address compiler bugs),
> I've gone through the effort of figuring out how to compile mex-files
> using GNU's free Fortran 77/90/95 compilers on Apple's OS X.
>
> To mex using one of the GNU Fortan 90/95 compilers you'll need to
> edit setup mex to use fortran and then modify your mexopts.sh file
> which resides in /Users/<user-name>/.matlab/R2006b.
>
> (1) edit your mexopts.sh file. You'll find it here
> ~/.matlab/R2006b/mexopts.sh
> (2) locate the Macintosh section. It is marked by the tag "mac)"
> (3) The only f90 compiler supported by Mathworks is by Absoft. You'll
> find the lines below in the mac section of the mexopts.sh file.
>
> FC='f90'
> FFLAGS='-YEXT_NAMES=LCS -YEXT_SFX=_ -N11 -s -Q51'
> ABSOFTLIBDIR=`which $FC | sed -n -e '1s|bin/'$FC'|lib|p'`
> FLIBS="-L$ABSOFTLIBDIR -lfio -lf77math"
> FOPTIMFLAGS='-O -cpu:g4'
> FDEBUGFLAGS='-g'
>
> Comment out these lines by placing a "#" preceding the text of each
> line.
>
> #FC='f90'
> #FFLAGS='-YEXT_NAMES=LCS -YEXT_SFX=_ -N11 -s -Q51'
> #ABSOFTLIBDIR=`which $FC | sed -n -e '1s|bin/'$FC'|lib|p'`
> #FLIBS="-L$ABSOFTLIBDIR -lfio -lf77math"
> #FOPTIMFLAGS='-O -cpu:g4'
> #FDEBUGFLAGS='-g'
>
> (4) If you want to use GNU's gfortran compiler, which is now part of
> the gcc suite of compilers, add the following lines to replace their
> Absoft equivalents.
>
> FC='/sw/bin/gfortran'
> FFLAGS='-DMX_COMPAT_32 -fno-common'
> FLIBS=' '
> FOPTIMFLAGS='-O5 -funroll-loops -ftree-vectorize'
> FDEBUGFLAGS='-g'
>
> (5) If you'd like to use GNU's g95 instead, you'll need to add the
> following lines in place of their Absoft equivalents.
>
> FC='/sw/bin/g95'
> FFLAGS='-DMX_COMPAT_32 -fno-common'
> FLIBS='-L/sw/lib/gcc-lib/powerpc-apple-darwin8/4.0.3/ -lf95'
> FOPTIMFLAGS='-O3'
> FDEBUGFLAGS='-g'
>
> If you haven't installed g95 using Fink, then the path to g95 and its
> library will need to be modified to suit your installation. The
> library directory containes the file "libf95.a" which is the file the
> option "-lf95" refers to.
>
> For versions of g95, specifically 0.90 and earlier, their exists a
> problem between the g95 library and Matlab. The result is that Matlab
> will cleanly exit about 10 minutes after a mex-file has been run. If
> you run from a terminal window, you will notice that it exist
> immediately after passing the message "Alarm clock" to the terminal.
> This *feature* has been corrected in versions later than 0.90.
>
> The version of gfortran I'm using is from gcc 4.2.
>
> (6) Test your fortran mex on yprimef.f which you can find in
> /Applications/MATLAB73/exterm/examples/mex. Navigate Matlab to that
> directory and type
>
> mex yprimef.F yprimefg.F
>
> Then test the yprimef.mexmac file
>
> yprimef(1,1:4)
> ans =
> 2.0000 8.9685 4.0000 -1.0947
>
> That's all there is to it.