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?
 

Answers and Replies

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

Thanks for that imabug!
 

Related Threads on Printing certain values from a DO loop in Fortran

Replies
36
Views
33K
  • Last Post
Replies
13
Views
5K
  • Last Post
Replies
4
Views
9K
Replies
2
Views
45K
Replies
7
Views
776
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
4
Views
5K
  • Last Post
Replies
13
Views
3K
Top