F90 Pointer Problem

F90 Pointer Problem

Bild des Benutzers baurle

Hello,

I have a strange error associated with a Fortran 90 pointer. I have included the relevant code segments below:

real(kind=flt_kind), pointer, dimension(:,:,:) :: prop
!
if (associated(prop)) then
write(*,*)
write(*,*) '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
write(*,*) '!!! MEMORY ALREADY ALLOCATED FOR prop !!!'
write(*,*) '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
stop
endif
allocate (prop(1:nimax,1:nprop,nbbeg:nbend),stat=istat)
if (istat /= 0) then
write(*,*) '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
write(*,*) '!!! MEMORY UNAVAILABLE FOR prop !!!'
write(*,*) '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
stop
endif
!
! This section of code yields incorrect results unless
! compiled with -O0
!
do i=1,idim(1,n)
prop(i,iprop,n) = 0.0_flt_kind
do k=2,idim(3,n)
do j=2,idim(2,n)
prop(i,iprop,n) = prop(i,iprop,n) + flux(i,j,k)
enddo
enddo
enddo
write(99,*) prop(1,iprop,n)
!
! This section of code yields correct results regardless
! of the optimization used (-O0,-O1,-O2) when compiled.
! Here, a write statement was added which in all liklihood
! disabled the compilers attempt to optimize this loop.
!
do i=1,idim(1,n)
prop(i,iprop,n) = 0.0_flt_kind
do k=2,idim(3,n)
do j=2,idim(2,n)
write(99,*) flux(i,j,k)
prop(i,iprop,n) = prop(i,iprop,n) + flux(i,j,k)
enddo
enddo
enddo
write(99,*) prop(1,iprop,n)
!
! This section of code yields correct results regardless
! of the optimization used (-O0,-O1,-O2) when compiled.
! Here, the loop was rearranged so that the inner-most
! index corresponds to the 1st nested loop
!
do i=1,idim(1,n)
prop(i,iprop,n) = 0.0_flt_kind
enddo
do k=2,idim(3,n)
do j=2,idim(2,n)
do i=1,idim(1,n)
prop(i,iprop,n) = prop(i,iprop,n) + flux(i,j,k)
enddo
enddo
enddo
write(99,*) prop(1,iprop,n)

The first do-loop structure yields correct results with the Lahey F90 compiler. This do-loop structure also yields correct results with the Intel compiler if I define prop to be an allocatable array rather than a pointer. This appears to be a bug in the compiler, so I thought I would throw it at this forum to see if anyone else has experienced this anomoly. Any experience others have had with this will be greatly apprecieated. Oh, and BTW, I am using Intel Fortran Compiler Version 7.0 for Linux.

4 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Steve Lionel (Intel)

Have you tried a more recent compiler? 7.0 is going on a year old at this point.

Steve

Steve
Bild des Benutzers baurle

I will look into downloading the latest version and having our sysAdmin install it. I will post the results of the update as soon as this is done. Thanks.

Bild des Benutzers baurle

The latest version of the compiler did not fix the problem.

Melden Sie sich an, um einen Kommentar zu hinterlassen.