Installing GFortran for Source-code GEMPACK

The GFortran compiler

GFortran is the name of the GNU Fortran compiler, which is part of the GNU Compiler Collection (GCC). The compiler is free and open-source. More details on the GNU website here.

Since Release 11 (2011), source-code versions of GEMPACK support GFortran as an alternative compiler on Windows PCs. However, since GFortran is rapidly evolving and easy to customize, only the GEMPACK-compatible GFortran downloaded from this page is supported by us for use with source-code GEMPACK.


Our GFortran install packages are provided as a convenience to GEMPACK customers. But anyone is free to download them, for whatever use they wish. However, we will only support their use for GEMPACK purposes.

We remind downloaders that GFortran use is covered by the terms of the GNU General Public License. Probably you only need to know about this if you intend to redistribute all or part of GFortran to others.

If you wish to use GFortran for non-GEMPACK purposes, you may well be better off downloading the latest version from the official site.

Installing the GEMPACK compatible GFortran compiler

The install packages available below provide a GFortran which makes both 32-bit and 64-bit programs. During the installation of Source-code GEMPACK you choose which one to use. Most Windows PCs are now 64-bit so it is likely that during the installation of GEMPACK you will be able to select 64-bit GFortran, which we recommend. More details on 32-bit and 64-bit installations and why you might choose a 32-bit installation are available here.

Download the GEMPACK compatible GFortran install package suitable for your GEMPACK release:

GFortran package Compatible GEMPACK releases
mingw-w64-gcc-6.4.0-setup.exe (93 MB).
If downloading EXE files is a problem, try this zip version.
12.0 to 12.1
mingw-builds-gcc-4.8.1-setup.exe (90 MB).
If downloading EXE files is a problem, try this zip version.
11.2 to 11.4
mingw-w64-1.0-gcc4.5.4pre-win32win64-toolchains.exe (104 MB) 11.0 to 11.3

GFortran 6.4.0 has faster compile times (LTG times) and makes EXEs with faster run runtimes than the older version 4 GFortrans.

Both version 4 GFortrans produce EXEs with similar runtimes. However, the more modern version (gcc481-based, only for GEMPACK 11.2 to 11.4) compiles much more quickly, reducing LTG times.

Note that GEMPACK 12.0 requires GFortran 6.4.0. And GEMPACK 11.4 (Jan 2016) requires GFortran version 4.8.1. Compilation (during installation of GEMPACK) will fail with the wrong GFortran. If upgrading first uninstall the older GFortran as appropriate. [In Control Panel "Programs and Features" uninstall "MinGW-w64 version 1.0 GCC 4.5.4 prerelease (GEMPACK compatible)" or "MinGW-builds GCC version 4.8.1 (GEMPACK compatible)"].

Administrator rights are needed for the installation. When downloaded, run the simple install program. The installation directroy may be modified, but we recommend you accept the default installation directory. The installer will put the installation directory on the system path.

Finally, you might need to reboot the PC: some users of the older mingw-w64-1.0-gcc4.5.4pre-win32win64-toolchains.exe package have found that GFortran compiles very slowly the first time it is used. The problem seems to disappear after rebooting.

"Hello World" test for GFortran

Before installing GEMPACK, you should test your installation of GFortran as follows. Right click and choose "Save Link As" or "Save Target As" depending on your browser, to save the small program hello.for into a temporary folder, say C:\test. When compiled and executed this program will write "Hello World" to the terminal. Next, open a command prompt in the C:\test folder (containing hello.for). To test the 32-bit GFortran installation, type the following commands.

C:\test>gfortvars ia32
C:\test>gfortran hello.for -o hello.exe

To test the 64-bit installation (this only works on 64-bit Windows), type the following commands:

C:\test>gfortvars intel64
C:\test>gfortran hello.for -o hello.exe

The first command, gfortvars ia32 (or gfortvars intel64), sets up the environment for the compiler. The second command, gfortran hello.for -o hello.exe, compiles the program hello.exe. And the third command, hello, runs the hello.exe program which will write the words "Hello World" to the terminal. If you see "Hello World" then your compiler installation is working.

See also:

Fortran Compilers for Use with Source-Code GEMPACK