Linking Fortran to matlab
6 次查看(过去 30 天)
显示 更早的评论
Hi I'm using a matlab on a linux machine and am having trouble using xfoil with it. I'm trying to use xfoil with the system command but am getting the error. At line 135 of file ../src/userio.f (unit = 5, file = 'fort.5') Fortran runtime error: End of file ans = 2
I can run xfoil from outside matlab without incident. As an aside while researching the solution to this problem I found a post where somebody talked about compiling xfoil to a mex file and using it this way. What if any are the advantages to this approach.
4 个评论
dpb
2013-6-17
'Fraid I can't help you much on unix-like installation questions--I've never worked on a system w/ it other than a very long time ago did some compiling on already-configured Sun workstation for the plant simulator and a previous life's day job.
AFAIK redirection is basically the same on the command line aren't they? The error message indicated the Fortran code was explicitly trying to read a file named fort.5, however. I used implicit i/o units so rarely I have to admit I've forgotten the Fortran rules for implicit open precisely as to sequence, etc. The name itself is compiler-specific, of course.
What command are you using at command line and what did you use for the system() command?
You can also do something like return the output of a simple 'ls' or the like to determine the working directory of a shell and see if that's what you want/think it should be. Beyond that you probably a more unix-savvy respondent as even my crystal ball is untrained in the area. :)
Marco.Caboni
2013-7-12
Hello Reuben,
I am having the same your problem. Trying to execute Xfoil through Matlab, I get: "At line 135 of file ../src/userio.f (unit = 5, file = 'fort.5') Fortran runtime error: End of file".
Did you manage to solve it eventually?
Thanks,
Marco
回答(2 个)
K
2013-10-25
I realise this is a bit old, but it's a top hit on Google, so I will respond with the answer that worked for me.
Before running xfoil, execute the following commands:
setenv(‘GFORTRAN_STDIN_UNIT’, ‘5’)
setenv(‘GFORTRAN_STDOUT_UNIT’, ‘6’)
setenv(‘GFORTRAN_STDERR_UNIT’, ‘0’)
To restore the environment the way it was afterwards:
setenv(‘GFORTRAN_STDIN_UNIT’, ‘-1’)
setenv(‘GFORTRAN_STDOUT_UNIT’, ‘-1’)
setenv(‘GFORTRAN_STDERR_UNIT’, ‘-1’)
2 个评论
benho
2016-2-17
Is this meant to work on windows as well? I have inserted the commands but I am still getting the same error
At line 85 of file ../src/userio.f (unit = 5, file = 'fort.5') Fortran runtime error: End of file ans = 2
Daniel
2016-3-30
I had the same problem and resetting the environment variables worked for me. For the record, I am running Matlab 2013b on Ubuntu 12.04 LTS.
Cheers!
Jason Botha
2014-1-23
Thank you! I've been struggling since 2012 to get matlab to talk to xfoil.
Is there any explanation about why this works?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fortran with MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!