Logo Cineca Logo SCAI

You are here

BLACS exercise

Write a program that initializes the BLACS environment, defines a matrix and writes it to file. Then modify the program to make it able to read the matrix from the file created before and rewrite it to standard output. For I/O use ScaLAPACK routines.


Use the attached wrapper files as a basis for the exercise (C programmers only):

wrapper.c
wrapperc2f.f90
wrapper.h


To compile (on Galileo):

GNU Compilers:

module load autoload profile/advanced
module load scalapack/2.0.2--openmpi--1.8.4--gnu--4.9.2

LALIB="-L${SCALAPACK_LIB} -lscalapack \
       -L${LAPACK_LIB} -llapack -L${BLAS_LIB} -lblas"

#FORTRAN:
mpif90 -o program.x program.f90 ${LALIB}

#C: remember to include wrapper.h
mpicc -c wrapper.c
mpif90 -c wrapperc2f.f90
mpicc -o program.x wrapper.o wrapperc2f.o program.c ${LALIB} -lgfortran

 

Intel Compilers:

module load autoload intelmpi/5.0.2--binary
module load mkl/11.2--binary
module load scalapack/2.0.2--intelmpi--5.0.2--binary

#FORTRAN:
mpiifort -o program.x program.f90 -mkl -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 \
           -L${SCALAPACK_LIB} -lscalapack -lpthread -lm

#C: remember to include wrapper.h
mpiicc -c wrapper.c -I${MKL_INC} -DMKL
mpiifort -c wrapperc2f.f90
mpiicc -o program.x wrapper.o wrapperc2f.o program.c -I${MKL_INC}  -DMKL \
      -mkl -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 \
      -L${SCALAPACK_LIB} -lscalapack -lpthread -lm -lifcore 

https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor