Printing certain values from a DO loop in Fortran

AI Thread Summary
To print every 100th value of the loop variable 'i' in a Fortran program, the use of the modulus operator is effective. The condition `if (mod(i,100) .eq. 0)` correctly identifies values of 'i' that are multiples of 100, including 100, 200, 300, and so on, up to 20000. This ensures that the program will print the desired values at each iteration where 'i' meets the condition, confirming that it works as intended.
johnwalton84
Messages
16
Reaction score
0
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?
 
Computer science news on Phys.org
if (mod(i,100) .eq. 0) then
print stuff
endif
 
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?
 
Obviously not cos its worked :smile:

Thanks for that imabug!
 
I came across a video regarding the use of AI/ML to work through complex datasets to determine complicated protein structures. It is a promising and beneficial use of AI/ML. AlphaFold - The Most Useful Thing AI Has Ever Done https://www.ebi.ac.uk/training/online/courses/alphafold/an-introductory-guide-to-its-strengths-and-limitations/what-is-alphafold/ https://en.wikipedia.org/wiki/AlphaFold https://deepmind.google/about/ Edit/update: The AlphaFold article in Nature John Jumper...
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...

Similar threads

Replies
8
Views
1K
Replies
13
Views
2K
Replies
5
Views
2K
Replies
8
Views
4K
Replies
7
Views
4K
Replies
19
Views
2K
Replies
9
Views
3K
Back
Top