Shohei Sato
Shohei Sato

Reputation: 53

Fortran 66 if() go to

I'm trying to understand a code from a article that I have to read for a project I'm working for, and it's written Fortran 66.

I don't understand the way it will work. I tried to write a similar code with same structures but it doesn't work. It's something similar to this

   if(conditional.1)go to 20
       *some code*
       go to 30
20 if (conditional.2)
       *some code*
       go to 30

30 continue

If the conditional.1 is True it will go to 20 or it will go to 30

And if it's false it will go to20?

It would be similar to this?:

if(conditional.1)then
    *some code*
end if

if(conditional.2)then
    *some code*
end if

Upvotes: 4

Views: 508

Answers (1)

This is an example of spaghetti code that you get from overusing GOTO and from the lack of better structures in FORTRAN 66. You can visualize the evolution using a flowchart.

If conditional 1 is .true. then you skip the first *some code*. So I believe it would be

   if (.not. conditional.1) then
       *some code 1*
   else if (conditional.2) then
       *some code 2*
   end if

in Fortran 77 and later.

Upvotes: 3

Related Questions