Libraries - more examples for linking

Examples of linking with the math libraries

[ BLAS | LAPACKBLACS | SCALAPACK | FFTWPARMETIS ]

Note If you want to use the Intel compilers, you are strongly encouraged to use MKL with them.

BLAS

The installed BLAS is OpenBLAS on Abisko.

Abisko, C, PathScale, threaded:

module load psc
module load openblas/psc
pathcc program.c -o program $OPENBLAS_LDFLAGS $OPENBLAS_MP_LIBS -lpathfortran

Abisko, C, PathScale, non-threaded:

module load psc
module load openblas/psc
pathcc program.c -o program $OPENBLAS_LDFLAGS $OPENBLAS_LIBS -lpathfortran

Abisko, Fortran, PathScale, threaded:

module load psc
module load openblas/psc
pathf90 program.f -o program $OPENBLAS_LDFLAGS $OPENBLAS_MP_LIBS

Abisko, Fortran, PathScale, non-threaded:

module load psc
module load openblas/psc
pathf90 program.f -o program $OPENBLAS_LDFLAGS $OPENBLAS_LIBS

The number of threads/cores used by the smp version can be controlled by the OMP_NUM_THREADS environment variable.

Abisko, makefile

If you are using a makefile, you should add the following

Add $OPENBLAS_LDFLAGS to LDFLAGS
Add $OPENBLAS_LIBS to LIBS
Add $OPENBLAS_MP_LIBS to LIBS to link with the smp version

Like this:
LDFLAGS=$$OPENBLAS_LDFLAGS
LIBS=$$OPENBLAS_LIBS

LAPACK

Lapack requires a blas implementation to link with like intel-mkl, openblas, or acml (abisko)

Abisko, C, PathScale

module load psc
module load lapack/psc
module load openblas/psc
pathcc program.c -o program $LAPACK_LDFLAGS $LAPACK_LIBS $OPENBLAS_LDFLAGS $OPENBLAS_LIBS -lpathfortran

Abisko, Fortran, PathScale

module load psc
module load lapack/psc
module load openblas/psc
pathf90 program.f90 -o program $LAPACK_LDFLAGS $LAPACK_LIBS $OPENBLAS_LDFLAGS $OPENBLAS_LIBS

Abisko, makefile

If you are using a makefile, you should add the following (Lapack, Blas)

Add $LAPACK_LDFLAGS $OPENBLAS_LDFLAGS to LDFLAGS
Add $LAPACK_LIBS $OPENBLAS_LIBS to LIBS (Add $OPENBLAS_MP_LIBS to LIBS instead, to link with the smp version)
Add $LAPACKX_LIBS to LIBS to link with the extra precise version which requires xblas

Like this:

LDFLAGS=$$LAPACK_LDFLAGS $$OPENBLAS_LDFLAGS
LIBS=$$LAPACK_LIBS $$OPENBLAS_LIBS

BLACS

Blacs is now included with Scalapack.

SCALAPACK

Abisko, C, OpenMPI, PathScale

module load openmpi/psc
module load openblas/psc
module load lapack/psc
module load scalapack/psc
mpicc program.c -o program $SCALAPACK_LDFLAGS -lscalapack_ompi $LAPACK_LDFLAGS $LAPACK_LIBS $OPENBLAS_LDFLAGS $OPENBLAS_LIBS -lpathfortran

Abisko, Fortran, OpenMPI, PathScale

module load openmpi/psc
module load openblas/psc
module load lapack/psc
module load scalapack/psc
mpif90 program.f90 -o program $SCALAPACK_LDFLAGS -lscalapack_ompi $LAPACK_LDFLAGS $LAPACK_LIBS $OPENBLAS_LDFLAGS $OPENBLAS_LIBS

Abisko, makefile

If you are using a makefile, you should add the following (Scalapack, Lapack, OpenMPI, Blas)

Add $SCALAPACK_LDFLAGS $LAPACK_LDFLAGS $OPENBLAS_LDFLAGS to LDFLAGS
Add $SCALAPACK_INCLUDE to CFLAGS
Add -lscalapack_ompi $LAPACK_LIBS $OPENBLAS_LIBS or -lscalapack_impi $LAPACK_LIBS $OPENBLAS_LIBS to LIBS ($OPENBLAS_MP_LIBS instead to link with the smp version)

Like this:

LDFLAGS=$$SCALAPACK_LDFLAGS $$LAPACK_LDFLAGS $$OPENBLAS_LDFLAGS
CFLAGS=$$SCALAPACK_INCLUDE
LIBS=-lscalapack_ompi $$LAPACK_LIBS $$OPENBLAS_LIBS

FFTW

Abisko C, OpenMPI, PathScale, FFTW 3.3 (all versions of FFTW on Abisko support MPI)

module load openmpi/psc
module load libfftw
pathcc program.c -o program -lfftw3 -lm $FFTW_INCLUDE $FFTW_LDFLAGS

Abisko, Fortran, OpenMPI, PathScale, FFTW 3.3 (all versions of FFTW on Abisko support MPI)

module load openmpi/psc
module load libfftw
pathf90 program.f90 -o program -lfftw3 -lm $FFTW_INCLUDE $FFTW_LDFLAGS

makefile
If you are using a makefile, you should add the following

Add $FFTW_INCLUDE to CFLAGS/FFLAGS/FCFLAGS
Add $FFTW_LDFLAGS to LDFLAGS

Add the wanted library (-lfftw3) to LIBS

Like this:

CFLAGS=$$FFTW_INCLUDE
LDFLAGS=$$FFTW_LDFLAGS

There is also a $FFTW_INCPATH and a $FFTW_LDPATH available

PARMETIS

C, PathScale

module load psc
module load parmetis
pathcc program.c -o program -lparmetis $PARMETIS_INCLUDE $PARMETIS_LDFLAG $PARMETIS_LIBS

Fortran, PathScale

module load psc
module load parmetis
pathf90 program.f90 -o program -lparmetis $PARMETIS_INCLUDE $PARMETIS_LDFLAG $PARMETIS_LIBS

Using the bundled Metis, PathScale, Fortran

module load psc
module load parmetis
pathf90 program.f90 -o program -lparmetis -lmetis $METIS_INCLUDE $METIS_LDFLAG $METIS_LIBS

makefile

If your are using a makefile, add the following to it

Add $PARMETIS_INCLUDE to CFLAGS
Add $PARMETIS_LDFLAG to LDFLAGS
Add $PARMETIS_LIBS to LIBS

To use the bundled Metis:
Add $METIS_INCLUDE to CFLAGS
Add $METIS_LDFLAG to LDFLAGS
Add $METIS_LIBS to LIBS
Updated: 2017-12-06, 15:21