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

15 vues (au cours des 30 derniers jours)
Avinash
Avinash le 31 Déc 2012
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 commentaire
3s
3s le 25 Avr 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?

Connectez-vous pour commenter.

Réponses (3)

Avinash
Avinash le 28 Avr 2013
Modifié(e) : Walter Roberson le 28 Avr 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 le 28 Avr 2013

Aarne Pohjonen
Aarne Pohjonen le 16 Juin 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

Catégories

En savoir plus sur Fortran with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by