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

Printing certain values from a DO loop in Fortran

  1. Dec 7, 2004 #1
    I've written a program in Fortran which has a do loop of the form

    do i=0,20000


    end do

    I want the program to print the values of the do loop, but only want it to print every 100th value of i (i.e. 100,200,300,400...20000), can anyone suggest a way to do this?
  2. jcsd
  3. Dec 7, 2004 #2
    if (mod(i,100) .eq. 0) then
    print stuff
  4. Dec 7, 2004 #3
    Would that not only work for i=100 though? If i is 200 then the mod(200,100) wouldn't be 0 so it wouldn't print?
  5. Dec 7, 2004 #4
    Obviously not cos its worked :smile:

    Thanks for that imabug!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook