Silverfrost Forums

Welcome to our forums

This statement will never be executed...

21 Jul 2009 3:01 #4816

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 real8 c,mean_square_h,square_h real8 suma_alturas,w1,w,delta integer4 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)%ymatrix(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

21 Jul 2009 5:11 #4817

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.

21 Jul 2009 5:52 #4818

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 real8 c,mean_square_h,square_h real8 suma_alturas,w1,w,delta,xmin,xmax,h_mean type coordenate real8 x real8 y end type coordenate type(coordenate),dimension(:),allocatable :: matrix integer4 npt,n,ventana,x_start,x_stop,intervalo,j,i real8, dimension(:),allocatable :: width_alfa,length_alfa intervalo=10 allocate(matrix(1000)) do i=1,1000 matrix(i)%x = i matrix(i)%y = sqrt(Real(ii)) 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)%ymatrix(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

27 Jul 2009 5:48 #4824

I do not get the warning on my machine. What version of FTN95 are you running?

27 Jul 2009 3:18 #4826

Ftn95 version 5.20 with either checkmate or debug switches. If I use 'release' in Plato, the warning does not appear.

27 Jul 2009 6:19 #4827

It looks like this bug has already been fixed since the release of 5.30 so the fix will appear in the next release.

28 Jul 2009 11:03 #4833

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

Please login to reply.