Install NAG Fortran compiler

The NAG Fortran compiler is a non-free but well-regarded compiler for modern Fortran. NAG is often among the first to support new Fortran standards, and is known for excellent linting / code checking capability.

  • Fortran 2008 coarray is limited to single image only in NAG 6.2.
  • Fortran 2008 submodule is MISSING from NAG 6.2 but according to NAG Support is expected in Spring 2019.


  1. Request a NAG trial. Typically they ask for a little info to help them understand their potential customer’s needs.
  2. Download NAG compiler
  3. extract the compressed folder to a non-ExFAT/FAT32 drive, since symbolic links are used.
  4. run installer:

Consider installing to /home/username/.local/bin and all other choices as default. DO NOT use ~ or $HOME as the NAG 6.2 installer did not recognize these shortcuts! 5. The NAG compiler should be available:


However, compilation is disabled until a license is installed.

License setup

This procedure is for Linux.

  1. License key comes in an email from NAG. Scroll down for the one-line license key and copy it to $HOME/.local/lib/NAG_Fortran/nag.key
  2. add to ~/.bashrc:
   export NAG_KUSARI_FILE=$HOME/.local/lib/NAG_Fortran/nag.key
  1. open a new Terminal and nagfor should now be able to compile programs.

NAG license FAQ

Graphical Debugger

NAG Fortran Builder is for Windows and Mac, we did not evaluate this as we typically run Linux. For NAG debugging on Linux, use dbx90.


CMake detects NAG like other Fortran compilers.