Printing certain values from a DO loop in Fortran


by johnwalton84
Tags: fortran, loop, printing, values
johnwalton84
johnwalton84 is offline
#1
Dec7-04, 08:01 AM
P: 16
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?
Phys.Org News Partner Science news on Phys.org
SensaBubble: It's a bubble, but not as we know it (w/ video)
The hemihelix: Scientists discover a new shape using rubber bands (w/ video)
Microbes provide insights into evolution of human language
imabug
imabug is offline
#2
Dec7-04, 08:19 AM
P: 345
if (mod(i,100) .eq. 0) then
print stuff
endif
johnwalton84
johnwalton84 is offline
#3
Dec7-04, 08:43 AM
P: 16
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
johnwalton84 is offline
#4
Dec7-04, 09:37 AM
P: 16

Printing certain values from a DO loop in Fortran


Obviously not cos its worked

Thanks for that imabug!


Register to reply

Related Discussions
[SOLVED] Riding a Loop the Loop (velocity at the bottom of the loop) Introductory Physics Homework 13
Fortran v.s. Visual Fortran Programming & Computer Science 0
Binomial Theorem - small values of x and approximate values Precalculus Mathematics Homework 7
C prog: printing values from array of structures Computing & Technology 36
PDF and printing Computing & Technology 13