Install PGI free Fortran compiler

Related: Install Flang LLVM Fortran compiler


The PGI Community Edition compilers are a set of no-cost, non-open-source, high performance compilers for:

  • C pgcc
  • C++ pgc++
  • Fortran pgf90 including Fortran CUDA support.

Like Flang, PGI is building up support for:

  • Fortran 2008 (including submodule)
  • Fortran 2018 (including do concurrent)

Install

  1. Download, extract and install PGI Community Edition to ~/.local/pgi (sudo not required). This is over 2 GB download, and must be extracted to a filesystem capable of symbolic links (e.g. not ExFAT). You don’t need to install CUDA support unless you have and want to use a CUDA-capable GPU.
  2. add to ~/.bashrc:
    export PATH="$PATH:$HOME/.local/pgi/linux86-64/2018/bin/"
    

    or whichever directory you find with

    find $HOME/.local/pgi -name pgf90
    
  3. open a new terminal to use PGI pgf90 pgcc pgc++

Graphical Debugger

PGI is known for its Java-based pgdbg graphical debugger for Fortran, C and C++. The PGI debugger is included in the no-cost Community Edition as well. As usual, be sure the program to be debugged is compiled with -g -O0 to provide maximum debugging information.

Example with hello.f90:

  1. pgf90 -g hello.f90
  2. pgdbg a.out opens the graphical Fortran debugger.

If you don’t see code in the upper left of the graphical PGI debugger for your program, be sure you compiled the executable with -g -O0 options.

CMake

CMake ≥ 3.10 distinguishes between PGI and Flang compilers. Set compiler-specific options in CMakeLists.txt for various Fortran compilers like:

cmake_minimum_required (VERSION 3.10)
project(myproj Fortran)

if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
  add_compile_options(-check all -fpe0 -warn -traceback -debug extended)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) # gfortran
  add_compile_options(-Wall -Werror=array-bounds -Wextra -Wpedantic)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI)
  add_compile_options(-traceback)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Flang) # cmake >= 3.10
  link_libraries(-static-flang-libs)
endif()

and then clear out your build directory and select the PGI compilers with

FC=pgf90 CC=pgcc CXX=pgc++ cmake ..

Notes

Tags: ,

Categories:

Written by Michael Hirsch, Ph.D. //

Comments