The HECToR Service is now closed and has been superceded by ARCHER.

FAQ: Compiling

This section covers basic compiler features.

Go back to the FAQ index.


Q. Why does the pgi/gnu/mpif90... compiler not function as expected?

A. HECToR handles the setting up of environment variables and knows about common (e.g. MPI) library paths through use of the module command. You then only need interact with the following compiler drivers, regardless of which compiler/version you have loaded into your environment settings:

  • ftn = Fortran 90
  • f77 = FORTRAN 77
  • cc = c
  • CC = C++

See the documentation in the HECToR User Guide for more information about using modules.

Q. What do I need to specify to get 64-bit by default and to promote all MPI definitions?

A. For MPI applications the -default64 option directs the linker to use the default64 version of the MPI library. Note: 64-bit versions of the MPI library are only available for the PGI and Cray compilers.

Q. I need to link with the NETcdf/NAG/... library. How do I specify it for my compiler and chosen precision?

A. Use the module command (see Environment).

Q. Why do I get errors when compiling/running code on the login nodes?

A. The compiler scripts ftn, cc and CC are for code that will execute on the compute nodes. These scripts take care of cross compiling for the compute nodes. See the HECToR User Guide for instructions on how to compile for the login nodes. Always remember to use the serial batch queues for long serial tasks rather than running them interactively on the login nodes. See batch processing in the HECToR User Guide for more information about the serial queues.

Q. Why do I get the error message "Relocation truncated to fit" when compiling?

A. It is probably large static arrays that are causing this. You could use allocatable arrays instead. If this is not possible, here are some tips on using the Pathscale and PGI compilers to overcome this problem.

The Pathscale compiler contains "Large Object Support". Statically allocated data (.bss) objects such as Fortran COMMON blocksand C variables with file scope are currently limited to 2GB in size. If the total size exceeds that, compilation (without the -mcmodel=medium option) will likely fail with the message: relocation truncated to fit: R_X86_64_PC32. For Fortran programs with only one COMMON block or with no COMMON blocks after the one that exceeds the 2GB limit, the program may compile and run correctly. At higher optimization levels (-O3, -Ofast), -OPT:reorg_common is set to ON by default. This might split a COMMON block such that a block begins beyond the 2GB boundary. If a program builds correctly at -O2 or below but fails at -O3 or -Ofast, try adding -OPT:reorg_common=OFF to the flags. Alternatively, using the -mcmodel=medium option will allow this optimization.

For the PGI compiler the -mcmodel=medium and -Mlarge_arrays compiler and linker options are supported under 64-bit linux environments (they are not supported under 32-bit linux environments). The -mcmodel=medium option must be used to compile/link a program whose data and .bss sections exceed 2GB. In order for the program to use these large data sections, additional addressing instructions that support 64-bit offsets need to be generated. The effect this option has on performance is a function of the amount of data-use in the application. Therefore, this option should be used only when the aggregate data size exceeds 2GB. The -Mlarge_arrays option tells the compiler that you have at least one single static data section (array) larger than 2GB. In this case, array accesses require 64-bit index arithmetic. This option must be used in conjunction with -mcmodel=medium. A tell-tale sign that you might need -mcmodel=medium occurs when you get warnings from the linker that mention relocation truncated to fit. There are other limitations to -mcmodel=medium (with respect to -fpic or position-independent code, shared libraries, etc.). The workaround with -fpic may have a small performance degradation in memory access due to reference indirection.

Q. Why do I get errors like "undefined reference to `_gfortran_pow_r8_i4' when linking code compiled with gcc/gfortran v 4.3?

A. GCC 4.3.2 requires libraries built with GCC 4.3 or later. In particular, users should load the modules xt-mpt/3.2.0 & xt-libsci/10.3.4 before linking. Also note that Fortran modules are incompatible with previous versions of GCC.


Go back to the FAQ index.