Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

F90 Pointer Problem

baurle
Beginner
549 Views
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.
0 Kudos
3 Replies
Steven_L_Intel1
Employee
549 Views
Have you tried a more recent compiler? 7.0 is going on a year old at this point.

Steve
0 Kudos
baurle
Beginner
549 Views
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.
0 Kudos
baurle
Beginner
549 Views
The latest version of the compiler did not fix the problem.
0 Kudos
Reply