Fortran re-engineering example (5)

There is one final goto in this code, and that goto is a loop in disguise. So removing it requires adding a do-while loop, and removing both the if statement, the associated goto and the label 5.

This is what the code looks like now (underlined code is the code of interest):

 5 if ( goto 10
       tower = 1
   totdis = totdis+10

   if (totdis.le.1000) goto 5

Now we replace this with a do-while construct:

   do while (totdis.le.1000)
       tower = 1
   totdis = totdis+10

   end do

Easy right? here’s the current state of the code:





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s