PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

pgf90 size intrinsic wrong output for large arrays

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



Joined: 27 Jul 2006
Posts: 15

PostPosted: Mon Aug 21, 2006 2:28 pm    Post subject: pgf90 size intrinsic wrong output for large arrays Reply with quote

Hi,

My system is "pgf90 6.1-6 64-bit target on x86-64 Linux". The following code produces the wrong result. What am I missing?

Code:
program mem
  integer(8), parameter :: n=3000000000_8
  integer(8)            :: i, sz
  character             :: y(n)

  sz = size(y)
  print*, n, sz
  do i=1,n
     y(i) = 'c'
  end do
  print*, y(n)
  stop
end program mem


Code:
$ pgf90 -mcmodel=medium samp.f90
$ ./a.out
               3000000000              -1294967296
 c
FORTRAN STOP


I seem to recall documentation saying that by using -Mlarge_arrays, which is implicit with -mcmodel=medium, array intrinsics output INTEGER*8 quantities.

Ed
Back to top
View user's profile
E. Sumbar



Joined: 27 Jul 2006
Posts: 15

PostPosted: Wed Aug 23, 2006 7:48 am    Post subject: Reply with quote

A similar issue was addressed in a different post "Large array sizes not allowed on 64-bit platforms". The solution (workaround?) seems to be to use -i8.

Code:
$ pgf90 -mcmodel=medium -i8 samp.f90
$ ./a.out
               3000000000               3000000000
 c
FORTRAN STOP


Ed
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Aug 28, 2006 9:53 am    Post subject: Reply with quote

Hi Ed,

The Fortran standard requires that lbound, size, and ubound return the default integer kind, which, even with -mcmodel=medium and -Mlarge_arrays, is INTEGER*4. Hence, to use these intrinsics with large arrays you need to change the default kind to 8 (i.e. -i8).

Although it hasn't been added yet, we have a feature request in house to add a "-Mi8intrinsics" flag which would change the default integer kind only for intrinsics.

Thanks,
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