Problem with executing Fortran codes using unix command in Matlab R2012a for MAC

9 views (last 30 days)
Hi,
I am using Matlab R2012a Student version on MAC Mountain Lion.
I am trying to execute a fortran code using Unix() function in Matlab.
For example,
unix('sac2asc GSLA01_BHZ00.sac');
sac2asc is the fortran executable and GSLA.. is the input file name. I have already added the path to the executable in Matlab file in the bin directory.I get error,
_________________
dyld: lazy symbol binding failed: Symbol not found: __gfortran_transfer_real_write Referenced from: /Users/avinash/Programs/SAC2ASCfolder/sac2asc Expected in: /Applications/MATLAB_R2012a_Student.app/sys/os/maci64/libgfortran.3.dylib
dyld: Symbol not found: __gfortran_transfer_real_write Referenced from: /Users/avinash/Programs/SAC2ASCfolder/sac2asc Expected in: /Applications/MATLAB_R2012a_Student.app/sys/os/maci64/libgfortran.3.dylib
sac2asc GSLA01_BHZ00.sac: Trace/breakpoint trap
ans =
133
_____________________________
I get errors for other Fortran codes too. The same command (sac2asc GSLA01_BHZ00.sac), however, works fine when I run it normally from a UNIX terminal. I use gfortran. Curiously, this whole thing used to work fine on my previous Matlab (Matlab R2009b for Linux) installed on Ubuntu.
Can anyone help me :(
Thanks.
  1 Comment
3s
3s on 25 Apr 2013
I am having the same issue on mountain lion. Any compiled fortran source code does not allow interaction with the screen and keyboard when run from matlab. Instead the fort.5 and fort.6 files are generated. The compiled versions run fine in terminal though.
did you manage to find a fix for this?

Sign in to comment.

Answers (3)

Avinash
Avinash on 28 Apr 2013
Edited: Walter Roberson on 28 Apr 2013
Hey I managed to fix it.
I removed the default Matlab fortran library libgfortran.3.dylib from Matlab (Don't delete it. store it somewhere else just in case).
I did the following changes -
go to your matlab root directory
cd(matlabroot)
go to the bin folder
open the file matlab
in the first few lines after comments, i made the following changes
export DYLD_LIBRARY_PATH="/usr/local/bin/gfortran" (or where ever your fortran library is)
export GFORTRAN_STDOUT_UNIT=6
export GFORTRAN_STDIN_UNIT=5
export PATH
this worked..dont blame me if anything goes wrong :P

Avinash
Avinash on 28 Apr 2013

Aarne Pohjonen
Aarne Pohjonen on 16 Jun 2016
This is reply to old question, but for those who are googling for this, the solution is to statically to link your code, e.g. gfortran -static-libgfortran -static-libgcc parabole.f90

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!