Install Nvidia HPC C, C++, Fortran compilers

The free-to-use Nvidia HPC SDK is indicated to build systems by environment variables:

CC=nvc
CXX=nvc++
FC=nvfortran

Ensure the HPC SDK bin/ directory is in environment variable PATH.

Nvidia HPC binaries can offer speed improvements over GNU GCC / GFortran, but Intel oneAPI binaries can be significantly faster than Nvidia-compiled binaries for CPU-only workloads. Unless one specifically needs the GPU features of Nvidia HPC SDK consider GNU or Intel oneAPI that have more modern Fortran features.

Nvidia HPC compilers current language standard support: C11, C++17. Fortran 2003 standard with some Fortran 2008 including submodule and error stop.

Download and install Nvidia HPC SDK. Sudo is not required, but the install must be on symbolic-link-aware drive (not ExFAT) Add the Nvidia “bin” directory to your “~/.bashrc” PATH environment variable. Open a new terminal to use Nvidia compilers.

Cmake: set compiler-specific options in CMakeLists.txt like:

project(myproj Fortran)

if(CMAKE_Fortran_COMPILER_ID STREQUAL NVHPC)
  add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-Mdclchk>)
endif()