Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran: inner loop dependence on outer loop

  1. May 14, 2012 #1
    Hello,

    I want to write an inner loop which takes values based on the variable values of the outer loop. For outer loop, m=1, Nmax and for inner loop, I want n to take values from 1 to Nmax-m. But I am not sure if I can directly specify n = 1, Nmax-m. Also I want to use Nmax-m value for one of the calculation inside the loop, how should I specify that?

    Thanks a lot for your help,
    Swati
     
  2. jcsd
  3. May 14, 2012 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    You mean
    Code (Text):

    do m = 1, nmax
    * calculate something
       do n = 1, nmax-m
    *    calculate something else
       enddo
    enddo
     
    Fortran won't have any problem with that (unless your compiler only understands Fortran 66, which is unlikely!)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran: inner loop dependence on outer loop
  1. Fortran Help (Do Loop) (Replies: 3)

Loading...