Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing certain values from a Fortran DO loop

Status
Not open for further replies.

johnwalton84

Technical User
Dec 7, 2004
2
GB
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. i=100,200,300,400...20000), can anyone suggest a way to do this?
 
Code:
do i = 0, 20000, 100
...
end do
 
Yeah, that would be fine expect the program needs to write all of the intermediate values do the screen. I've found the answer though, adding

if (mod(i,100) .eq. 0) then
write(unit=7,fmt="(3e15.7)") variable1, v2, v3
end if

at the end of the DO loop, where 7 is an output file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top