Large array sizes not allowed on 64-bit platforms

We have a critical bug in our compiler, the latest 6.1-6 Fortran for Linux x86-64. We have also tested this with 6.1-5 and 6.1-3.

I already sent email to your engineer folks, please - PLEASE, don’t tell me to do that. I’d rather have answers to problems.

Here’s the reproducer code:

! array_bug
! Demonstrates the case where the modern 64-bit PGI compiler cannot handle array indices in the defined Fortran
! range of -2^63 to 2^63-1
!

PROGRAM array_bug
IMPLICIT NONE

INTEGER, PARAMETER :: k11 = SELECTED_INT_KIND(11)
INTEGER (KIND=k11), PARAMETER :: testsize = 100000000000
REAL (KIND=8) :: tester(testsize)
INTEGER :: i

tester = 1.0

do i=1,testsize
tester(i)=2*tester(i+2) + 5.4
end do
END PROGRAM array_bug

Here’s the error outputted when trying to compile, using the -v flag to capture details:
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/bin/pgf901 array_bug.f90 -opt 1 -nohpf -nostatic -x 19 0x400000 -
quad -x 59 4 -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -x 57 0xfb0000 -x 58 0x780
31040 -x 48 4608 -x 49 0x100 -x 120 0x200 -stdinc /net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/include:/usr/lo
cal/include:/usr/lib/gcc/x86_64-redhat-linux/3.4.4/include:/usr/lib/gcc/x86_64-redhat-linux/3.4.4//include:/usr/include
-def unix -def __unix -def unix -def linux -def __linux -def linux -def inline= -def NO_INLINE -def __NO
_MATH_INLINES -def x86_64 -def LONG_MAX=9223372036854775807L -def ‘SIZE_TYPE=unsigned long int’ -def ‘PTRD
IFF_TYPE
=long int’ -def __THROW= -def amd64 -freeform -vect 48 -output /tmp/pgf90D2jexGHPfHucYWey.ilm
PGF90-W-0128-Integer constant truncated to fit data type: 23 (array_bug.f90: 13)
PGF90-W-0128-Integer constant truncated to fit data type: 23 (array_bug.f90: 18)
0 inform, 2 warnings, 0 severes, 0 fatal for array_bug
PGF90/any Linux/x86-64 6.1-6: compilation completed with warnings

/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/bin/pgf902 /tmp/pgf90D2jexGHPfHucYWey.ilm -fn array_bug.f90 -opt
1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 16 -x 19 0x400000 -x 28 0x40000 -quad -x 120 0x80
000000 -x 59 4 -x 59 4 -y 80 0x1000 -x 80 0x10800000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -
x 120 0x200 -astype 0 -x 124 1 -cmdline ‘+pgf90 array_bug.f90 -v’ -asm /tmp/pgf90p2jeTPy8h9zq260c.s
0 inform, 0 warnings, 0 severes, 0 fatal for array_bug
PGF90/x86 Linux/x86-64 6.1-6: compilation successful

/usr/bin/as /tmp/pgf90p2jeTPy8h9zq260c.s -o /tmp/pgf90v2je-Lj_9XmAhE-T.o

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/3.4.4//crtbegin.o /net/scratch1/dog/fla
sh64/PGI/pgi_6.1-6/linux86-64/6.1/lib/f90main.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /net/scratch1/
dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/pgi.ld /tmp/pgf90v2je-Lj_9XmAhE-T.o -L/net/scratch1/dog/flash64/PGI/pgi_6.1
-6/linux86-64/6.1/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/3.4.4/ -rpath /net/scratch1/dog/flash64/PGI/pgi_6.
1-6/linux86-64/6.1/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/li
b/gcc/x86_64-redhat-linux/3.4.4//crtend.o /usr/lib64/crtn.o
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x2): In function __hpf_myprocnu m': : relocation truncated to fit: R_X86_64_PC32 __hpf_lcpu /net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x9): In function __hpf_ncpus’:
: relocation truncated to fit: R_X86_64_PC32 __hpf_tcpus
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x10): In function __hpf_getiopr oc': : relocation truncated to fit: R_X86_64_PC32 __hpf_ioproc /net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x17): In function __hpf_is_iopr
oc’:
: relocation truncated to fit: R_X86_64_PC32 __hpf_lcpu
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x1d): In function __hpf_is_iopr oc': : relocation truncated to fit: R_X86_64_PC32 __hpf_ioproc /net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x41): In function __hpf_abort’:
: relocation truncated to fit: R_X86_64_PC32 __hpf_lcpu
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0xa5): In function __hpf_abortp' : : relocation truncated to fit: R_X86_64_PC32 __hpf_lcpu /net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0xdc): In function __hpf_initarg
‘:
: relocation truncated to fit: R_X86_64_PC32 .bss
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x103): In function __hpf_initar g': : relocation truncated to fit: R_X86_64_PC32 .bss /net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x115): In function __hpf_initar
g’:
: relocation truncated to fit: R_X86_64_PC32 .bss
/net/scratch1/dog/flash64/PGI/pgi_6.1-6/linux86-64/6.1/lib/libpgf90.a(initpar.o)(.text+0x131): In function `__hpf_initar
g’:
: additional relocation overflows omitted from the output
pgf90-Fatal-linker completed with exit code 1

Unlinking /tmp/pgf90D2jexGHPfHucYWey.ilm
Unlinking /tmp/pgf90p2jeTPy8h9zq260c.s
Unlinking /tmp/pgf90v2je-Lj_9XmAhE-T.o

Hi David,

You need to add “-mcmodel=medium -i8” to your compilation.

Example: (Note that I only have 8GB of memory on my system so I needed to reduce the test size to ~7.5GB)

% cat ~/tmp/arr.f90
! array_bug
! Demonstrates the case where the modern 64-bit PGI compiler cannot handle array indices in the defined Fortran
! range of -2^63 to 2^63-1
!

PROGRAM array_bug
IMPLICIT NONE

INTEGER, PARAMETER :: k11 = SELECTED_INT_KIND(11)
INTEGER (KIND=k11), PARAMETER :: testsize = 1000000000
!INTEGER (KIND=k11), PARAMETER :: testsize = 100000000000
REAL (KIND=8) :: tester(testsize)
INTEGER :: i

print *, 'START'
tester = 1.0
do i=1,testsize
tester(i)=2*tester(i) + 5.4
end do
print *, 'END'
END PROGRAM array_bug

%pgf90 -mcmodel=medium -i8 -V6.1 ~/tmp/arr.f90
% a.out
 START
 END

Hope this helps,
Mat