Header Ads

Header ADS

Nested Loop in Fortran

nested loop is a loop within a loop, an inner loop within the body of an outer one. How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again. This repeats until the outer loop finishes.


Syntax:
iloop: do ....
   .....
   
   jloop: do ....        
      .....        
      
      kloop: do ....
        .....
         
      end do kloop
   end do jloop  
end do iloop

Example:

Output:

No comments

Theme images by enot-poloskun. Powered by Blogger.