 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Jul 21, 2009 4:01 pm Post subject: This statement will never be executed... |
|
|
When I compile the following subroutine, the compiler (/checkmate option) says that "width_alfa(j)=w1/n" will never be executed, a statement that in fact results false, because it is executed. Is this a bug in the compiler?
subroutine determinar_alfa
use mswin
use datos_celulas
implicit none
real*8 c,mean_square_h,square_h
real*8 suma_alturas,w1,w,delta
integer*4 npt,n,ventana,x_start,x_stop
if(allocated(width_alfa)) deallocate(width_alfa)
if(allocated(length_alfa)) deallocate(length_alfa)
allocate(width_alfa(intervalo),length_alfa(intervalo))
xmax=MAXVAL(matrix%x)
xmin=MINVAL(matrix%x)
delta=xmax-xmin
do j=intervalo,1,-1
square_h=0.0
npt=0
suma_alturas=0.0
w1=0.0
n=0
w=0.0
ventana=INT(delta/j)
x_stop=xmin+ventana
x_start=xmin
do
do i=1,pixels_contorno
if(matrix(i)%x >= x_start) then
write(*,*) i, matrix(i)%x,matrix(i)%y
if(matrix(i)%x>x_stop)exit
if(matrix(i)%y==0) stop
square_h=square_h+matrix(i)%y*matrix(i)%y
suma_alturas=suma_alturas+matrix(i)%y
npt=npt+1
endif
end do
h_mean= suma_alturas/npt
mean_square_h=square_h/npt
c=mean_square_h-(h_mean*h_mean)
w=sqrt(c)
w1=w1+w
n=n+1
x_start=x_stop
x_stop=x_start+ventana
if(x_stop>xmax) exit
square_h=0.0
suma_alturas=0.0
end do
width_alfa(j)=w1/n
length_alfa(j)=ventana
end do
call graficar_alfa(intervalo)
end subroutine determinar_alfa
Agustin |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue Jul 21, 2009 6:11 pm Post subject: |
|
|
It is almost certainly a bug.
Can you post a simpler version of the program or include the missing module so that I can reproduce the problem. |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Jul 21, 2009 6:52 pm Post subject: |
|
|
This is a simple version. I removed the need of the module. It seems that the compiler thinks that the EXIT in the inner DO loop will jump out of the outer DO loop, i.e. does not recognise where the exit belongs. Hope this helps... I can use the statement "while(x_stop<=xmax) do..." and avoid the warning, but I usually heard that it is better use the DO instead of the WHILE, although I do not know why.
Agustin
Program alfa
implicit none
real*8 c,mean_square_h,square_h
real*8 suma_alturas,w1,w,delta,xmin,xmax,h_mean
type coordenate
real*8 x
real*8 y
end type coordenate
type(coordenate),dimension( ,allocatable :: matrix
integer*4 npt,n,ventana,x_start,x_stop,intervalo,j,i
real*8, dimension( ,allocatable :: width_alfa,length_alfa
intervalo=10
allocate(matrix(1000))
do i=1,1000
matrix(i)%x = i
matrix(i)%y = sqrt(Real(i*i))
end do
if(allocated(width_alfa)) deallocate(width_alfa)
if(allocated(length_alfa)) deallocate(length_alfa)
allocate(width_alfa(intervalo),length_alfa(intervalo))
xmax=MAXVAL(matrix%x)
xmin=MINVAL(matrix%x)
delta=xmax-xmin
do j=intervalo,1,-1
square_h=0.0
npt=0
suma_alturas=0.0
w1=0.0
n=0
w=0.0
ventana=INT(delta/j)
x_stop=xmin+ventana
x_start=xmin
do
do i=1,1000
if(matrix(i)%x >= x_start) then
if(matrix(i)%x>x_stop)exit
if(matrix(i)%y==0) stop
square_h=square_h+matrix(i)%y*matrix(i)%y
suma_alturas=suma_alturas+matrix(i)%y
npt=npt+1
endif
end do
h_mean= suma_alturas/npt
mean_square_h=square_h/npt
c=mean_square_h-(h_mean*h_mean)
w=sqrt(c)
w1=w1+w
n=n+1
npt=0
x_start=x_stop
x_stop=x_start+ventana
if(x_stop>xmax) exit
square_h=0.0
suma_alturas=0.0
end do
width_alfa(j)=w1/n
length_alfa(j)=ventana
end do
do i=1,intervalo
print *, width_alfa(i), length_alfa(i)
end do
end program alfa |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Jul 27, 2009 6:48 am Post subject: |
|
|
I do not get the warning on my machine.
What version of FTN95 are you running? |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Mon Jul 27, 2009 4:18 pm Post subject: |
|
|
Ftn95 version 5.20 with either checkmate or debug switches. If I use "release" in Plato, the warning does not appear. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Jul 27, 2009 7:19 pm Post subject: |
|
|
It looks like this bug has already been fixed since the release of 5.30 so the fix will appear in the next release. |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Wed Jul 29, 2009 12:03 am Post subject: |
|
|
I have upgraded to version 5.30 and the bug is no more there. You are right: it has been already fixed in this version. I am afraid that due to the problems I had with my notebook and the "release" version of my program, I switched back to a previous version of FNT95, but I went "too back". Thanks a lot for your help.
Agustin |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|