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: (Re)allocation of allocatable arrays on assignment - F2003


Reduced test case for nf.f90

program NF
implicit none
integer,parameter :: dpkind=kind(1.0D0)
integer :: nx=9 , ny=10 , nz=9
real(dpkind),allocatable,dimension(:) :: ad,g
integer :: nxyz , nxy 
                           
nxy = nx*ny ; nxyz = nxy*nz
allocate(ad(nxyz),g(nxyz))
ad=111.001d0
call GetGI3D(1,nxyz)    
deallocate(ad,g)
contains

subroutine GetGI3D(i1,i2)
integer :: i1 , i2
integer :: i
g = ad
print *, g(i1), g(i2), ad(i2), maxval(abs(ad-g))
end subroutine GetGI3D

end

result without patch
   111.00100000000000        111.00100000000000        111.00100000000000        0.0000000000000000     

with patch
   111.00100000000000        0.0000000000000000        111.00100000000000        111.00100000000000     

i.e., the last element of 'ad' is not assigned to 'g',
probably the signature of what Tobias reported in
http://gcc.gnu.org/ml/fortran/2010-10/msg00112.html

Dominique


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