- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Can anyone let me know how to loop through non-integers values like from 0.001 to 9.999
Thanks
Can anyone let me know how to loop through non-integers values like from 0.001 to 9.999
Thanks
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Help
Hello,
Can anyone let me know how to loop through non-integers values like from 0.001 to 9.999
Thanks
Can anyone let me know how to loop through non-integers values like from 0.001 to 9.999
Thanks
First of all why do you want to loop a non integer ??
For example, if you want step size of 0.001b/t 1 and 10 ,you may write as follows
[cpp]real(8) i do i= 1.d0, 10.d0 , 0.001d0 print*, 'whatever you want' end do [/cpp]
Can you be more specific by giving an example what you want to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Non-integer DO loops are deleted from the standard. Our compiler still supports them, but they're a bad idea, especially as you may be surprised at how many times the loop runs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
Non-integer DO loops are deleted from the standard. Our compiler still supports them, but they're a bad idea, especially as you may be surprised at how many times the loop runs.
Steve,
Are you referring to my code ?? If sothere are lot of situations in engineeringproblems that have to loop many times, for example trying to achieve convergence etc.
Ifyou are referring to theoriginal discussion, I did not understand why he/she wants to loop non integer numbers !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Peter
[cpp]real(8) i
do i= 1.d0, 10.d0 , 0.001d0
print*, 'whatever you want'
end do
[/cpp]
integer i
do i=1,9999
write(*,*) i*0.001
enddo
has advantages such as an exactly known loop count.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
This was supported in f77 standard, but later deleted from the standard, as e.g.
integer i
do i=1,9999
write(*,*) i*0.001
enddo
has advantages such as an exactly known loop count.
integer i
do i=1,9999
write(*,*) i*0.001
enddo
has advantages such as an exactly known loop count.
Tim18,
You would want to use "i*0.001D0" or "i*0.001_8" as the original loop code showed use of D variables.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Peter
Steve,
Are you referring to my code ?? If sothere are lot of situations in engineeringproblems that have to loop many times, for example trying to achieve convergence etc.
Ifyou are referring to theoriginal discussion, I did not understand why he/she wants to loop non integer numbers !
Hi Peter,
Thanks for the do loop. It worked for F90.
I wanted to do a small test with non-integer. I have a code where I had to do negative exponential calculations over large values and was never coming out of the loop. So, I had to find the value where it was stuck. This was for the very same purpose (convergence) you have explained.
Thanks again..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Help
Hi Peter,
Thanks for the do loop. It worked for F90.
I wanted to do a small test with non-integer. I have a code where I had to do negative exponential calculations over large values and was never coming out of the loop. So, I had to find the value where it was stuck. This was for the very same purpose (convergence) you have explained.
Thanks again..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Peter
Yeah I kinda figured that you'l be looking for some convergence ! Good luck running your code !
Thanks Peter...and thanks to everyone who replied to this post

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page