I’m not 100% clear on what “-mcmodel=medium” and “-Mlarge_arrays” do. Can someone give an explaination? What impact do they have on performance?
The -mcmodem=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 (w.r.t. -fpic or position-independent code, shared libraries, etc.). Refer to the release notes (page 13) for more information:
Hi, is there equivalent option in Windows (Windows 10, Home edition, 32 GB memory)?
I am using a Fortran code which claims a quite big array. Currently I have to reduce the dimension of that array to make it run on my computer (otherwise it will compile but will not run). However, I am wondering if there is some option for Windows to allow this progoram to use big memory.
Rather than use a -mcmodel=medium switch to allow you to declare
arrays ‘statically’ that do not fit into a 32-bit address space, change
your code to define the ‘large arrays’ as allocatables.
real*8, allocatable :: a
and when you need the array
and use it.
This will work on OS X, Windows and Linux. -mcmodel-medium
only works with OS X and Linux, and it slows down those codes.
You do need to use -Mlarge_arrays, which forces all ‘array-index-to-byte-offset’ calculation to be done with 64–bit integer math.