Install Nvidia HPC C, C++, Fortran compilers

The free-to-use Nvidia HPC SDK offers possible speed improvements over GNU GCC / GFortran. Intel oneAPI binaries can be significantly faster than Nvidia-compiled binaries for CPU-only workloads on Intel CPUs. A typical reason for using Nvidia HPC SDK is the Cuda GPU features. Nvidia HPC compilers support C11, C++20, and partial Fortran 2018 including submodule and error stop.

Download and install Nvidia HPC SDK. Create a script nvidia.sh:

To use NVIDIA HPC SDK, source the script:

source ~/nvidia.sh

For CMake use, set NVIDIA HPC compiler-specific options in CMakeLists.txt like:

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