[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables

Filippo Spiga filippo.spiga at disco.unimib.it
Thu Aug 5 10:39:29 CDT 2010


  Dear users,
     I look at different examples but I'm not sure to have well 
understood how to compile and link correctly using the contents of 
"conf/petscvariables" and "conf/variables". My program uses both linear 
and non linear solvers and different external packages such as 
superlu_dist, hypre and umfpack. I looked at 
"${PETSC_ROOT}/${PETSC_ARCH}/conf/petscvariables" to extract the right 
path to compile and link my code. Inside this file there are all these 
lines:

PETSC_CONTRIB_BASIC = -lpetsc
PETSC_SNES_LIB_BASIC = -lpetsc
PETSC_KSP_LIB_BASIC = -lpetsc
PETSC_MAT_LIB_BASIC = -lpetsc
PETSC_LIB_BASIC = -lpetsc
PETSC_VEC_LIB_BASIC = -lpetsc
PETSC_DM_LIB_BASIC = -lpetsc
PETSC_TS_LIB_BASIC = -lpetsc
PETSC_SYS_LIB_BASIC = -lpetsc
PACKAGES_LIBS = ...

but there isn't a single entry that collect in the right order all of 
them. Then if I look at "${PETSC_ROOT}/${PETSC_ARCH}/conf/variables" I 
can find these lines:

PETSC_EXTERNAL_LIB_BASIC = ${EXTERNAL_LIB} ${PACKAGES_LIBS} 
${PCC_LINKER_LIBS}
PETSC_SYS_LIB_BASIC      = -lpetscsys
PETSC_VEC_LIB_BASIC      = -lpetscvec ${PETSC_SYS_LIB_BASIC}
PETSC_MAT_LIB_BASIC      = -lpetscmat ${PETSC_VEC_LIB_BASIC}
PETSC_DM_LIB_BASIC       = -lpetscdm ${PETSC_MAT_LIB_BASIC}
PETSC_KSP_LIB_BASIC     = -lpetscksp ${PETSC_DM_LIB_BASIC}
PETSC_SNES_LIB_BASIC     = -lpetscsnes ${PETSC_KSP_LIB_BASIC}
PETSC_TS_LIB_BASIC       = -lpetscts ${PETSC_SNES_LIB_BASIC}
PETSC_LIB_BASIC          = ${PETSC_TS_LIB_BASIC}
PETSC_CONTRIB_BASIC      = -lpetsccontrib

PETSC_SYS_LIB     = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_SYS_LIB_BASIC}  ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_VEC_LIB     = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_VEC_LIB_BASIC}  ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_MAT_LIB     = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_MAT_LIB_BASIC}  ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_DM_LIB      = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_DM_LIB_BASIC}   ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_KSP_LIB     = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_KSP_LIB_BASIC}  ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_SNES_LIB    = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_SNES_LIB_BASIC} ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_TS_LIB      = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_TS_LIB_BASIC}   ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_LIB         = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_LIB_BASIC}      ${PETSC_EXTERNAL_LIB_BASIC}
PETSC_CONTRIB     = ${C_SH_LIB_PATH} -L${PETSC_LIB_DIR} 
${PETSC_CONTRIB_BASIC}

that are pretty clear. However if I look inside 
"${PETSC_ROOT}/${PETSC_ARCH}/lib" I don't  see all the -lpetsc* 
libraries mentioned above" I only have one single "libpetsc.a"

So, what's the right env variable to use? what is the right order of 
-lpetsc* statements? Can I only link "libpetsc.a"? In this last case, is 
my Makefile fully compatible and maintenable with all the future version 
of PETSc?

Thank you very much in advance,
Regards

-- 

Filippo SPIGA

«Nobody will drive us out of Cantor's paradise.»
      -- David Hilbert



More information about the petsc-users mailing list