Printing certain values from a DO loop in Fortran

  1. I've written a program in Fortran which has a do loop of the form

    do i=0,20000

    (operations)

    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. if (mod(i,100) .eq. 0) then
    print stuff
    endif
     
  4. 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. Obviously not cos its worked :smile:

    Thanks for that imabug!
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?