Logo Cineca Logo SCAI

You are here

PETSc exercises

1_petsc_hello

Try to create a simple "hello world" using the most simple PETSc directives.
Compile it with the makefile provided and make it run!

 

2_petsc_vec

Starting with the source code provided try to use properly the PETSc vectors:
- Duplicate a vector
- Create a vector
- Set some vector values (remember VecAssemblyXXX() calls!)
- Try some numerical operations

You can use as input data the files linked below:

va_200.bin   vb_200.bin


3_petsc_mat
Starting with the source code provided try to use properly the PETSc matrices:
- Duplicate a matrix
- Create a matrix
- Set some matrix values (remember MatAssemblyXXX() calls!)
- Try some numerical operations

You can use as input data the files linked below:

mA_300x200.bin   mB_300x200.bin   mC_200x200.bin


 

Makefile (FERMI)

PETSC_DIR = $(PETSC_HOME)
PETSC_ARCH = bgq-power
ALL: 1_petsc_hello 2_petsc_vec 3_petsc_mat
CFLAGS = -g -O0
CPPFLAGS =
CLEANFILES = 1_petsc_hello 2_petsc_vec 3_petsc_mat

include ${PETSC_DIR}/conf/variables
include ${PETSC_DIR}/conf/rules 1_petsc_hello: 1_petsc_hello.o chkopts -${CLINKER} -o 1_petsc_hello 1_petsc_hello.o ${PETSC_LIB} ${RM} 1_petsc_hello.o 2_petsc_vec: 2_petsc_vec.o chkopts -${CLINKER} -o 2_petsc_vec 2_petsc_vec.o ${PETSC_LIB} ${RM} 2_petsc_vec.o 3_petsc_mat: 3_petsc_mat.o chkopts -${CLINKER} -o 3_petsc_mat 3_petsc_mat.o ${PETSC_LIB} ${RM} 3_petsc_mat.o