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

Simple do-loop in Fortran. Please help !

  1. Jun 14, 2010 #1
    I can't figure out how to make a do-loop in Fortran to do the following:

    I have 2 variables. Let's say:

    and I need 10 fields printed out.

    The first field will have the value:

    level + step
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>
    <then the value of the one above + step>

    So I'm sure it's simple but I can't figure out how to use the values of variables in do-loops instead of typing the numbers in.

    Thanks in advance
     
  2. jcsd
  3. Jun 14, 2010 #2

    Mark44

    Staff: Mentor

    I'm a little rusty with Fortran, but this should do what you're asking.
    Code (Text):

    value = level + step
    do i = 1, 10
      write *,* value
      value = value + step
    end do
     
     
  4. Jun 14, 2010 #3
    Thanks so much! It works.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook