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

조회 수: 11 (최근 30일)
Avinash
Avinash 2012년 12월 31일
답변: Aarne Pohjonen 2016년 6월 16일
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
3s
3s 2013년 4월 25일
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?

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

답변 (3개)

Avinash
Avinash 2013년 4월 28일
편집: Walter Roberson 2013년 4월 28일
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 2013년 4월 28일

Aarne Pohjonen
Aarne Pohjonen 2016년 6월 16일
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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by