Re: Matlab -> Fortran



On Feb 27, 5:55 pm, Gib Bogle <g.bo...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Is there a program to convert Matlab code to Fortran?

Thanks
Gib

Yes, there is matlab2fmex https://sourceforge.net/projects/matlab2fmex/
.. I think it requires Matlab to run.

Your question is asked occasionally on comp.soft-sys.matlab, where
NZTideman wrote as follows:

"I've transferred a lot of Fortran programs to Matlab (and also the
reverse).
The best way I've found is to do it by hand, translating line by line
in an editor, changing "do" to "for" and "end do" to "end", etc.
If your Fortran is 90/95, it's pretty easy because the vector
operations translate directly, but if you have Fortran IV, with
goto's
and computed goto's, then it's very difficult to do it by hand. I've
usually found that in that case, it's better to start over in Matlab."

If you go the manual route you may find useful the "language tables"
of John Akin at
http://www.owlnet.rice.edu/%7Emech517/F90_docs/tables.pdf

which shows the equivalent constructs in C++ Fortran 90, Fortran 77,
and Matlab.

.



Relevant Pages

  • Re: MATLAB <-> FORTRAN
    ... When you do A\b it just calls the basic solvers Matlab knows, ... in some cases Gauss Elimination. ... In this case you can find a Gauss Solver, ... I've bitten the bullet and converted to Fortran ...
    (comp.soft-sys.matlab)
  • Re: Matlab Vectorisation Speed - How is it done in c++?
    ... Beating the performance of vectorized Matlab code is very ... Matlab makes calls to optimized C and Fortran libraries ... Use optimization level 3 on numerical code and level 2 on non- ...
    (comp.soft-sys.matlab)
  • Re: Calling MATLAB from Fortran
    ... Fortran saves the data which Matlab m-file needs and then Matlab would read them as input from the file and after calculation save then in a file for Fortran. ... returns mxArray * ...
    (comp.soft-sys.matlab)
  • Re: pass 1D vector from matlab to fortran
    ... matlab to fortran: ... %input: timeseries ts and constants ... polynomial in seasonal smoothing ...
    (comp.soft-sys.matlab)
  • Re: Problems when calling functions from a .dll
    ... > I have quite some problems with calling functions from a .dll. ... originally written in Fortran and compiled by ... > PRECISION (double in Matlab); ... > as a basic for my header file, which is based on the example file ...
    (comp.soft-sys.matlab)