[petsc-users] Petsc makefile and PETSC_COMPILE variable
Alex Koshkarov
okoshkarov at tae.com
Wed Dec 16 16:48:12 CST 2020
Thanks for this.
I now use modified version of `share/petsc/Makefile.user`. However, now I am not sure if I do linking correctly. All my code is pure C, so I use
$(OBJ) - variable with all object files
driver: $(OBJ)
$(LINK.c) $^ $(LDFLAGS) $(LDLIBS) -o $@
I am not sure if I need to pass variable $(LDFLAGS) or not, since in Makefile.user examples does not, it uses only $(LDLIBS). Also, I cannot find the definition of LINK.c in `make -p` to make sure.
Also, after reading Jed's and mine petsc.pc, I noticed that I do not have optimization flags, however I compile petsc with optimization flags. (I also add additional -O3 into compilation rule when compile my code)
Namely, I add during petsc configuration/compilation (I use gcc and openmpi):
--with-debugging=0 COPTFLAGS='-O3 -march=native -mtune=native' CXXOPTFLAGS='-O3 -march=native -mtune=native' FOPTFLAGS='-O3 -march=native -mtune=native'
So how do I check if my petsc is compiled with optimizations?
And my petsc.pc is:
prefix=/home/kosh/Documents/NEPIC/libs/petsc-3.14.2/optim
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib
ccompiler=mpicc
cflags_extra=-fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden
cflags_dep=-MMD -MP
ldflag_rpath=-Wl,-rpath,
cxxcompiler=mpicxx
cxxflags_extra=-Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden -fPIC
fcompiler=mpif90
fflags_extra=-fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument
Name: PETSc
Description: Library to solve ODEs and algebraic equations
Version: 3.14.2
Cflags: -I${includedir} -I/home/kosh/Documents/NEPIC/libs/petsc-3.14.2/include
Libs: -L${libdir} -lpetsc
Libs.private: -L/home/kosh/Documents/NEPIC/libs/petsc-3.14.2/optim/lib -L/usr/lib/openmpi -L/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0 -lHYPRE -lscalapack -llapack -lblas -lX11 -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5 -lm -lstdc++ -ldl -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lpthread -lquadmath -lstdc++ -ldl
Thank you and best regards,
Alex.
On 12/16/20, 9:15 AM, "Jed Brown" <jed at jedbrown.org> wrote:
Alex Koshkarov <okoshkarov at tae.com> writes:
> Thanks Barry,
>
> It makes much more sense! And thanks for clarifying what “P” indicates. I like this explicit approach over implicit because I am bad with makefile syntax. However, share/petsc/Makefile.user looks much cleaner, but I need to learn how pkg-config works to understand it.
Open a petsc.pc to see what is specified there. We define a number of extra variables that can help with checking for common compilers/wrappers and how to use RPATH if needed.
prefix=/home/jed/petsc/ompi-optg
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib
ccompiler=mpicc
cflags_extra=-fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden -O2 -march=native -ffp-contract=fast -g
cflags_dep=-MMD -MP
ldflag_rpath=-Wl,-rpath,
cxxcompiler=mpicxx
cxxflags_extra=-Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden -g -O -fPIC
fcompiler=mpif90
fflags_extra=-fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g -O
Name: PETSc
Description: Library to solve ODEs and algebraic equations
Version: 3.13.99
Cflags: -I${includedir} -I/home/jed/petsc/include
Libs: -L${libdir} -lpetsc
Libs.private: -L/home/jed/petsc/ompi-optg/lib -L/usr/lib/openmpi -L/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0 -lHYPRE -lumfpack -lklu -lcholmod -lbtf -lccolamd -lcolamd -lcamd -lamd -lsuitesparseconfig -lsuperlu -lsuperlu_dist -lml -llapack -lblis -ltriangle -lX11 -lexodus -lnetcdf -lpnetcdf -lcgns -lmedC -lmed -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5 -lparmetis -lmetis -lm -lz -lstdc++ -ldl -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lpthread -lquadmath -lstdc++ -ldl
More information about the petsc-users
mailing list