Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Go to in Fortran

Status
Not open for further replies.

rajabadsha

Programmer
May 4, 2006
11
CA
What would be the go to equivalent of Fortran into C?
 
goto - C has gotos too. There are several ways in which gotos are used
Code:
      do 10 i = 1,10, 1
         ...
         if (...) goto 10 ! equivalent of continue in C
         ...
         if (...) goto 20 ! equivalent of break in C
         ...
10    continue
20    continue

      if (.not. condition) goto 30 ! if (conditon) {
          ...
          goto 40                  ! }
30     continue                    ! else {
          ...
40     continue                    ! }

       goto 50                     ! goto L50
        ...
50     continue                    !L50:

       goto (n) 60, 70, 80         !switch (n) {
       ...                         !default:

       goto 90                     !break;
60     continue                    !case 1:
       ...
       goto 90                     ! break;
70     continue                    !case 2:
       ...
       goto 90                     !   break;
80     continue                    !case 3:
       ...
                                   !   break;
90     continue                    !}
There is also an assigned goto which is the similar to the computed goto.
 
THere is a Unix utility called f2c which will translate from Fortran 66 or 77 to C. Maybe you ought to try that one out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top