need help with makefile

Satish Balay balay at
Thu Mar 1 16:56:29 CST 2007

The idea is to use a PETSc example makefile - and modify it

And with fortran codes - we require preprocessing [i.e source files
that call PETSc routines should be .F]

A minimal PETSc makefile is as follows: 
CFLAGS           = 
FFLAGS           = 
CPPFLAGS         = 
FPPFLAGS         =

include ${PETSC_DIR}/bmake/common/base

ex1f: ex1f.o  chkopts
	-${FLINKER} -o ex1f ex1f.o  ${PETSC_KSP_LIB}
	${RM} ex1f.o

So you'll just make the change [with the variables CMD and SOBJS properly defined]

ex1f -> $(CMD)
ex1f.o -> $(SOBJS)

Note: Necessary FFLAGS should already be PETSc config files. Some
additional flags can be specified with FFLAGS variable 


On Thu, 1 Mar 2007, P. Aaron Lott wrote:

> Hi,
> I have a fortran90 code and I would like to use petsc's  preconditioners
> inside of it. I'm having trouble setting up a makefile that will allow me
> include a petsc. It seems the problem is from the use of the c-preprocessor.
> My old makefile looked something like this:
> $(CMD)  : $(SOBJS)
> 	$(F90) $(FLAGS) -o $(EXENAME) $(SOBJS)
> where SOBJ is a list of all of my object files.
> I was hoping to be able to make a petsc object file and include it in this
> list. Is this possible? Is there a tutorial on how to get petsc setup inside
> of your existing code?
> Thanks,
> -Aaron
> P. Aaron Lott
> Ph.D. Candidate
> 4239 Computer and Space Sciences Building
> University of Maryland
> College Park, MD 20742-4015
> palott at
> Office: 301.405.4894
> Fax:      301.314.0827

More information about the petsc-users mailing list