PDA

View Full Version : Printing certain values from a DO loop in Fortran


johnwalton84
Dec7-04, 08:01 AM
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?

imabug
Dec7-04, 08:19 AM
if (mod(i,100) .eq. 0) then
print stuff
endif

johnwalton84
Dec7-04, 08:43 AM
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?

johnwalton84
Dec7-04, 09:37 AM
Obviously not cos its worked :smile:

Thanks for that imabug!