This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Reallocate code from Numerical Recipes - problem at run time
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: Edmund J Dunlop <edunlop at utvinternet dot ie>
- Cc: fortran at gcc dot gnu dot org
- Date: Sat, 13 Aug 2005 11:25:55 +0200
- Subject: Re: Reallocate code from Numerical Recipes - problem at run time
- References: <ddk7b1$rq3$1@sea.gmane.org>
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