Monday, November 3, 2014

How to convert FORTRAN to MATLAB?

Converting from one programming language to other programming language may need some effort and understanding on both programming language. In this post, I will discuss about converting from Fortran to Matlab.

Fortran is general-purpose programming language developed by IBM. It is used primarily for numeric computation and scientific computation. Matlab is array-based programming language that used for scientific computation.

To convert from Fortran to Matlab, here are two alternatives you can do:
1. Convert manually
2. Convert automatically

==== 1. Convert manually =====
To convert manually, you have to understand both language very well. In the converting process, it will be easier for you to display your fortran code and your matlab side-by-side. If you have dual screen, it will be a lot easier. You can put your fortran code in second screen and your matlab in first screen. Or you can print your fortran code and put it beside your workstation.

==== 2. Convert automatically ====
I found a fortran to matlab converter from mathworks developed by Barrowes consulting (http://www.mathworks.com/matlabcentral/fileexchange/5260-f2matlab). To convert, followings are some steps needed:
1. Download and extract f2matlab into your computer
2. In matlab, go to the folder in which you extract f2matlab
3. In matlab command, put >> f2matlab('myfortran.f');
4. The f2matlab.m will do automatically for you

However, I noticed that some files cannot be converted correctly. Therefore, I have to do double check for the converted one. I noticed even some files cannot be converted at all. So, the f2matlab can help you a lot. However, be ready for manual checking and even manual conversion.

Hope this helps.

No comments: