Install and use Intel MKL Scalapack library

Intel MKL has Scalapack, which is installed when you select “Cluster Support” for C and/or Fortran from the Intel Compiler/MKL installer. The files installed under $MKLROOT=~/intel/mkl are

include/mkl_scalapack.h
lib/intel64_lin/libmkl_scalapack_ilp64.a
lib/intel64_lin/libmkl_scalapack_ilp64.so
lib/intel64_lin/libmkl_scalapack_lp64.a
lib/intel64_lin/libmkl_scalapack_lp64.so

MKL Scalapack examples

The MKL Scalapack examples for Gfortran are compiled by:

cd $MKLROOT/examples/

tar xf examples_cluster_f.tgz

cd scalapackf

make sointel64 mpi=openmpi compiler=gnu mpidir=/usr/

The resulting “exe” files are under scalapackf/_results/.

non-MKL Scalapack

Obtain non-MKL ScalaPack by:

  • Debian/Ubuntu: apt install libscalapack-mpi-dev
  • CentOS: yum install scalapack-openmpi-devel

Cmake Scalapack

CMakeLists.txt will automatically select MKL or non-MKL Scalapack by:

cmake_minimum_required(VERSION 3.1)
project(MyProject Fortran C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")

find_package(SCALAPACK REQUIRED)

add_executable(myexe myprogram.f90)
target_link_libraries(myexe PRIVATE ${SCALAPACK_LIBRARIES})
target_include_directories(myexe PRIVATE ${SCALAPACK_INCLUDE_DIRS})

FindSCALAPACK.cmake

You will need the FindSCALAPACK.cmake file, available at my GitHub repo under cmake/Modules