I am having trouble compiling some code that uses large address space for an Opteron cluster. I am using -tp k8-64 -mcmodel=medium and with or without -Mlarge_arrays I get errors from the linker that look like the section below. Does anybody have an idea of what is going wrong here?

/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x2): In function `__hpf_myprocnum':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_lcpu' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x9): In function `__hpf_ncpus':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_tcpus' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x10): In function `__hpf_getioproc':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_ioproc' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x17): In function `__hpf_is_ioproc':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_lcpu' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x1d):initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_ioproc' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x41): In function `__hpf_abort':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_lcpu' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0xa5): In function `__hpf_abortp':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_lcpu' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x5c0): In function `__hpf_istat':
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_quiet' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x5e6):initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_quiet' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x60c):initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_quiet' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x632):initpar.c: additional relocation overflows omitted from the output
gmake: *** [flash2] Error 2

The problem in your case is the "-Wl,-Bstatic" flag. The static libraries that accompany the 5.2 compilers were compiled for the small memory model and can't be used with the "-mcmodel=medium" flag. Linking dynamically, i.e remove "-Wl,-Bstatic", will fix your issue.

Note that starting with the 6.0 compilers, two version of the runtime libraries are included. The small memory model versions are located in the "lib" directory while the medium memory model versions are located in the "libso" directory. In other words, with 6.0 and later versions of the compilers, linking "-mcmodel=medium" with static libraries is supported.