How to convert from FORTRAN TO MATLAB

Dear all,
Please am working on a project and now found a FORTRAN code to speed up my research but I having been using MATLAB and so, I need to convert the newly found FORTRAN code to MATLAB. Please kindly help me out on this conversion or give a detail explanation on how best I can convert from FORTRAN to MATLAB. The FORTRAN code is in the attachment. Thanks in anticipation!

1 Kommentar

KSSV
KSSV am 3 Okt. 2020
Options:
  1. Convert the FORTRAN code to MATLAB line by line going through the code.
  2. If problem is known, try knowing the inbuilt functions, toolboxes in MATLAB.

Melden Sie sich an, um zu kommentieren.

Antworten (4)

Ben Barrowes
Ben Barrowes am 3 Okt. 2020

0 Stimmen

My f2matlab can do this kind of conversion. Please download from the file exchange and give it a try. You will have to split the code up into the five files in the pdf and run f2matlab on each file.
I might also do a free conversion if I get time, but in any case, if you run into trouble PM me.

9 Kommentare

Oluwaseyi Aliu
Oluwaseyi Aliu am 3 Okt. 2020
Thanks so much for this, ve downloaded f2matlab but still dont understand how to use.
Ben Barrowes
Ben Barrowes am 3 Okt. 2020
See the README file after unzipping the f2matlab distribution.
Oluwaseyi Aliu
Oluwaseyi Aliu am 3 Okt. 2020
Ok, thank you sir; but the code is written with FORTRAN 77
Ben Barrowes
Ben Barrowes am 3 Okt. 2020
Yes, I see that. In the README file, it suggests using to_f90 or some other tool to convert to f90 format before trying f2matlab.
Let me see what I can do next week to provide a free but untested conversion with my tools.
Oluwaseyi Aliu
Oluwaseyi Aliu am 4 Okt. 2020
ok sir, thanks a bunch!
roborrr
roborrr am 23 Aug. 2023
I have 92 Fortran subroutines that call each other and are controlled by one main program, most of which have input and output data. is it possible to create a full-fledged executable file from this, which will run in matlab using the software you suggested in the letter: My f2matlab? If it's possible, could you give step by step instructions on how to implement this?
Ben Barrowes
Ben Barrowes am 23 Aug. 2023
Sure it's possible. Here are the major steps.
Convert all the programs to f90 format (also refactor all GOTO's).
Compile and run the fortran.
Use f2matlab on each routine.
Debug resulting matlab code.
Compile matlab code into an executable.
Email me at barrowes@alum.mit.edu if you run into trouble.
roborrr
roborrr am 23 Aug. 2023
HI Ben Barrowes, Thank you so much for responding so kindly to my question. I'm just starting to study this topic and some questions arose that I could not solve on my own from the instructions you suggested. With your permission, I will later send questions in a personal mail that I have not resolved, after I try to solve it myself.
Ben Barrowes
Ben Barrowes am 23 Aug. 2023
Understood. Good luck Rob.

Melden Sie sich an, um zu kommentieren.

ARF
ARF am 15 Feb. 2025
Bearbeitet: Stephen23 am 15 Feb. 2025

0 Stimmen

I used codeconvert.ai and it worked perfectly!

1 Kommentar

Ben Barrowes
Ben Barrowes am 15 Feb. 2025
The ai converters can do many things well, but not others. Memory manipulation is difficult for them (common's, equivalence, etc.) for example. Other fortran constructs are also difficult. But for simple codes, ai conversion works.

Melden Sie sich an, um zu kommentieren.

阔
am 12 Mai 2025

0 Stimmen

Recently I was working on the conversion of .f90 files to matlab code, but the amount of fortran code is very large. Is there any quick way to achieve an accurate conversion?

1 Kommentar

Ben Barrowes
Ben Barrowes am 12 Mai 2025
You can try to give each routine separately to an AI converter. Then reassemble all the outputs.
I could also take a look if you PM me: barrowes@alum.mit.edu

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Fortran with MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 3 Okt. 2020

Kommentiert:

am 12 Mai 2025

Community Treasure Hunt

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

Start Hunting!

Translated by