How to compile single fortran objects using translator f2c?
I have the following problem: I want to simulate some control engineering system. As it is quite complicated I used the computer to开发者_C百科 derive some (complicated) equations which can only be exported to fortran77 code. On my development pc this is no problem (linux machine).
No I want to do it in hardware and here I have to use a windows OS. Unfortunately matlab does not support gfortran on windows. Therefore I can not compile the fortran files on that box.
My idea was now to translate to C as a C compiler is available at matlab on win. Any other (better) options?
I have several SUBROUTINES in the manner of the following.
SUBROUTINE sys_rhs (x, v, dx, param)
REAL*8 x(6)
C code is coming here
RETURN
END SUBROUTINE
Is it good practice and does it work to use the function sys_rhs__
in the interface function written in C?
The problem is, that I can not test it as I do not have massive access to the windows machine. So it should work if I try it and I should not need to experiment a lot.
Also what lib's do I need on windows? Where can I get them?
Thanks Christian
Intel sells a pretty good fortran compiler (http://software.intel.com/en-us/articles/fortran-compilers/) which they used to give away for free for testing ... ;-)
PS No, Im not linked to this company in any way!
You might wanna check the gnumex project, which allows to compile MEX-files using the GNU GCC compiler suite (using either MinGW or Cygwin), with the ability to use g77 to compile Fortran programs.
The answer was quite simple: I had some syntax errors in my fortran code. gfortran
does no such strict syntax checking and therefor interpreted the fortran code correctly. After removing the typos I succceded transcoding with f2c.
Thanks
there is a better solution to all this
use your linux machine or your windows machine to implement the function in c/c++ and then generate a dll file.
In matlab you can load the DLL and make a call to the functions inside it.
here is a simple tutorial that show how to call the dll with matlab.
http://www.mathworks.com/matlabcentral/fileexchange/15065-example-of-loading-c-dll-and-performance-comparison
精彩评论