next up previous
Next: I/O and FORMAT statement Up: FORTRAN specific statements Previous: EQUIVALENCE statement

Labeled DO statement

It is not difficult to deal with labeled DO statements, since the labels for nested DO loops must be properly nested, which have a natural correspondence to nested FOR loops in Java. We simply keep those labels (of course change them to Java labels) and add proper `{' and `}'.

The following program,

      program bbb
      integer a(10)
      integer b(10,10)
      integer c(10,10,10)
      integer i,j,k
      do 20 i=1,10
         do 10 j=10,1,-1
            b(i,j) = i + j
            do 10 k = 1,10,2
10            c(i,j,k) = i + j - k * i / j 
20            a(i)=10 - i
      end

becomes,

   class bbb_mc {
      public static  void main(String args[]) {
         int a[] = new int [10] ;
         int b[][] = new int [10][10] ;
         int c[][][] = new int [10][10][10] ;
         int i,j,k ;
         for (i=1;i<=10;i=i+1) {
            for (j=10;j>=1;j=j-1) {
               b[i-1][j-1]=i+j ;
               for (k=1;k<=10;k=k+2) 
j10:              c[i-1][j-1][k-1]=i+j-k*i/j ;
            }
j20:        a[i-1]=10-i ;
         }
      }
   }




Tue Dec 1 01:57:28 EST 1998