This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reallocate code from Numerical Recipes - problem at run time


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]