Reallocate code from Numerical Recipes - problem at run time
Paul Thomas
paulthomas2@wanadoo.fr
Sun Aug 14 10:01:00 GMT 2005
Edmund,
>
>professional. Is there a workaround or is this a bug which must be fixed?
>
>
The answer is yes to both. Would you please submit a bug report to
http://gcc.gnu.org/bugzilla/ It takes a couple of moments to obtain an
account and then to submit the bug.
In the mean time, the following works:
program Realloc
USE nrtype; USE nrutil
IMPLICIT NONE
REAL(SP), DIMENSION(:), POINTER :: x, y
INTEGER(I4B) :: i
allocate(x(10))
forall(i=1:ubound(x,1)) x(i)=i
write(*,"(10F6.2)") x
y => reallocate(x,20) ! Use y...
x => y ! ...and then point x to y
forall(i=1:ubound(x,1)) x(i)=2*i
write(*,"(20F6.2)") x
end program Realloc
For some reason, the compiler is not detecting the dependency and
putting the result of reallocate in a temporary. What happens is that
reallocate does all the right things, up until the deallocate..... which
it does to the lhs, being the same as the result, ie to x! An
alternative fix is to comment out the deallocate.
I'll take a look see over the next few days. It's a bit of code that I
need to revisit for another reason.
Best regards
Paul T
More information about the Fortran
mailing list