[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables
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
[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables
On Thu, Aug 5, 2010 at 10:39 AM, Filippo Spiga filippo.spiga at disco.unimib.it wrote: 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? Is is always correct to use include ${PETSC_DIR}/conf/variables include ${PETSC_DIR}/conf/rules foo: foo.o ${CLINKER} -o foo foo.o ${PETSC_TS_LIB} We switched in the latest release to having a single library, libpetsc. Matt Thank you very much in advance, Regards -- Filippo SPIGA ?Nobody will drive us out of Cantor's paradise.? -- David Hilbert -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100805/956cb181/attachment.htm
[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables
The idea here is - you would: include conf/variables in your makefile and use PETSC_LIB in the target - so everything works correctly. The complexity you mention is to manage --with-single-lib=0/1. So Instead of trying to list libraries directly in your makefile [which becomes unportable] - I suggest you use the recommended procedure above. PETSC_LIB will pick up all exteranlpackages currently installed with PETSc [so even this part of the makefile will become portable] The best thing would be to also use conf/rules as well in your makefile and use PETSc compile targets for both petsc non-petsc sources that go into your application. Satish On Thu, 5 Aug 2010, Filippo Spiga wrote: 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
[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables
Dear Matthew, Matthew Knepley wrote: include ${PETSC_DIR}/conf/variables include ${PETSC_DIR}/conf/rules foo: foo.o ${CLINKER} -o foo foo.o ${PETSC_TS_LIB} I already have a Makefile. But most important I have a autoconf script that generates my configure that generates my Makefile. So I have two possibilities: - modify every single Make template to use conf/variables and conf/rules as you suggested (long, boring and useless strategy because all my current Makefiles work. I only want to generalize the configure as much as possible replacing one single line); - or starting from conf/petscvariables I can try to compose by myself the only information I need to generalize my scripts. I only need the name of the library. That's all. Or, if it was compiled splitting it in different indipendent libraries, I need the right order to link {PETSC_CONTRIB_BASIC, PETSC_SNES_LIB_BASIC, PETSC_KSP_LIB_BASIC, PETSC_MAT_LIB_BASIC, PETSC_LIB_BASIC, PETSC_VEC_LIB_BASIC, PETSC_DM_LIB_BASIC, PETSC_TS_LIB_BASIC, PETSC_SYS_LIB_BASIC}. I don't understand why conf/petscvariables doesn't provide that information. I guess it's easy to store it in one single explicit line. I'm looking for a easy way to ensure portability, I don't want to increase the complexity of the makefile/configure. If starting from the last stable release PETSc is compiled by default in one single library (and it is), I can ignore all these stuffs until that kind of portability problem will arise. I will probably do that at this point... Thank you very much for your explanations, Regards -- Filippo SPIGA ?Nobody will drive us out of Cantor's paradise.? -- David Hilbert
[petsc-users] Compile and link correctly using conf/petscvariables and conf/variables
You configure script would have to create this makefile and echo ${PETSC_LIB} - and other stuff you need form a given install of PETSc - to detect what you want. Anythings else is not portable. [And won't work across different PETSc installations - of the same version] If you want a simple solution - then you should just use PETSc from makefile directly - and not introduce an extra configure step in the middle. satish On Thu, 5 Aug 2010, Filippo Spiga wrote: Dear Matthew, Matthew Knepley wrote: include ${PETSC_DIR}/conf/variables include ${PETSC_DIR}/conf/rules foo: foo.o ${CLINKER} -o foo foo.o ${PETSC_TS_LIB} I already have a Makefile. But most important I have a autoconf script that generates my configure that generates my Makefile. So I have two possibilities: - modify every single Make template to use conf/variables and conf/rules as you suggested (long, boring and useless strategy because all my current Makefiles work. I only want to generalize the configure as much as possible replacing one single line); - or starting from conf/petscvariables I can try to compose by myself the only information I need to generalize my scripts. I only need the name of the library. That's all. Or, if it was compiled splitting it in different indipendent libraries, I need the right order to link {PETSC_CONTRIB_BASIC, PETSC_SNES_LIB_BASIC, PETSC_KSP_LIB_BASIC, PETSC_MAT_LIB_BASIC, PETSC_LIB_BASIC, PETSC_VEC_LIB_BASIC, PETSC_DM_LIB_BASIC, PETSC_TS_LIB_BASIC, PETSC_SYS_LIB_BASIC}. I don't understand why conf/petscvariables doesn't provide that information. I guess it's easy to store it in one single explicit line. I'm looking for a easy way to ensure portability, I don't want to increase the complexity of the makefile/configure. If starting from the last stable release PETSc is compiled by default in one single library (and it is), I can ignore all these stuffs until that kind of portability problem will arise. I will probably do that at this point... Thank you very much for your explanations, Regards