How to convert GO TO (Fortran77) to Matlab

In summary, the problem of translating Fortran77 code to Matlab arises due to the use of "GO TO" statements, which are not valid in Matlab. The solution is to insert a loop starting at line 128 and replacing all instances of "go to 128" with "continue" to replicate the functionality of the original code.
  • #1
Triscas
9
0
I'm translating some code from Fortran77 to Matlab and I'm struggling due to the sentence GO TO is not valid in Matlab.
Usually using sentences while I can solve the problem but in a particular case I don't know how to face it.
To put in situation, i.e:

code
line 1
line 2
...
128 a=a+1

if c==1 && kcount < 20 then
line
line
if (h < 30) then
go to 128
end if
end if
line
line
if (zmax == 0) go to 128
if (zmin. lt. 0.999d0*zmax) go to 128
line
end

The problem, if can be apreciated, is the go to inside the double if statement that also is in normal if statements.


If it's neccesary I could write the code.

Thanks!
 
Physics news on Phys.org
  • #2
You will most probably need to insert a loop starting at line 128. Details will depend on how the program terminates when it doesn't "go to 128" in the last if statement you wrote. Then at every instance of "go to 128", you would replace that with "continue", such that the rest of the code would be skipped and the loop would iterate, which is what appears to be happening here.
 

What is the difference between GO TO (Fortran77) and Matlab?

GO TO (Fortran77) is a language used for scientific and engineering computations, while Matlab is a high-level programming language specifically designed for numerical and matrix operations.

Why would I need to convert GO TO (Fortran77) code to Matlab?

There are several reasons why one might need to convert GO TO (Fortran77) code to Matlab, such as for compatibility with other programs, taking advantage of Matlab's advanced features and graphics capabilities, or for easier debugging and maintenance.

Is it possible to directly convert GO TO (Fortran77) code to Matlab?

No, it is not possible to directly convert GO TO (Fortran77) code to Matlab. However, there are tools and techniques available that can assist in the conversion process.

What are some tips for converting GO TO (Fortran77) code to Matlab?

Some tips for converting GO TO (Fortran77) code to Matlab include understanding the differences in syntax and data types between the two languages, using built-in functions and libraries in Matlab, and testing the code thoroughly to ensure it produces the same results as the original Fortran code.

Are there any online resources available for learning how to convert GO TO (Fortran77) to Matlab?

Yes, there are many online resources available for learning how to convert GO TO (Fortran77) to Matlab. These include tutorials, forums, and code examples that can provide guidance and assistance in the conversion process.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
568
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Computing and Technology
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Back
Top