- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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
- Marcas:
- Intel® Fortran Compiler
Link copiado
8 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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 !
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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..
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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..
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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
Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora