PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

pgf90 v6.0 array problem

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
jcalahan



Joined: 30 Aug 2005
Posts: 1

PostPosted: Tue Aug 30, 2005 9:06 am    Post subject: pgf90 v6.0 array problem Reply with quote

I'm seeing a difference in Fortran 90 array sections and/or pointers from version 5.2. The following scaled down code snippet demonstrates:

Code:
PROGRAM main
   PARAMETER (n=5)
   REAL t(n)

   INTERFACE
     SUBROUTINE sub(n, t)
       INTEGER :: n
       REAL :: t(:)
     END SUBROUTINE
   END INTERFACE

   DO i = 1,n
      t(i) = FLOAT(i)
      WRITE(*,"('MAIN T(',i1,') = ',F4.1)") i,t(i)
   ENDDO

   CALL sub(n, t(:))
END

SUBROUTINE sub(n, p_t)
   REAL, POINTER :: t(:)
   REAL, TARGET :: p_t(:)
   t => p_t

   DO i = 1,n
     WRITE(*,"('SUB T(',i1,') = ',F4.1)") i,t(i)
   ENDDO
END


5.2 output:
Quote:
MAIN T(1) = 1.0
MAIN T(2) = 2.0
MAIN T(3) = 3.0
MAIN T(4) = 4.0
MAIN T(5) = 5.0
SUB T(1) = 1.0
SUB T(2) = 2.0
SUB T(3) = 3.0
SUB T(4) = 4.0
SUB T(5) = 5.0


6.0 output:
Quote:
MAIN T(1) = 1.0
MAIN T(2) = 2.0
MAIN T(3) = 3.0
MAIN T(4) = 4.0
MAIN T(5) = 5.0
SUB T(1) = 2.0
SUB T(2) = 3.0
SUB T(3) = 4.0
SUB T(4) = 5.0
SUB T(5) = 0.0


The 6.0 output is shifted by one. It seems to be assuming zero-based array indexing on the pointer.

Calling the subroutine without specifying an array section works. Example:
Code:
CALL sub(n, t)
My real code is passing a 2d array section extracted from a 3d array to a subroutine using pointers, so this isn't an option.

Suggestions?

Thanks,
Josh
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Tue Aug 30, 2005 11:46 am    Post subject: Reply with quote

Hi John,


Thank you for the report. The problem appears to be on how we're setting up the call using the section. I've filled TPR #3618 and have ask our compiler team to investigate further. I've also listed you as the contact.

The work arround as you have already determined is to remove the array section from the actual argument list or use the 5.2 compiler.

Thanks again,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group