Makefile for compiling multiple source files

Vijay M vijay.m at gmail.com
Mon May 14 10:04:35 CDT 2007


Hi,

I've been trying to use PETSc for one of my projects lately and I was
wondering how to create the makefile to compile multiple source files
with and without PETSc calls in fortran efficiently. I am sure it is a
newbie question but I could not find much information about this
anywhere.

For example, you could take 4 files. A.f90, B.f90 without petsc calls
and C.f90 and D.f90 with petsc calls. If I were to compile them I have
to use

f90 -c A.f90 -o A.o
f90 -c B.f90 -o B.o
cpp C.f90 -I<include dir> > Ctemp.f90
f90 -c Ctemp.f90 -o C.o
cpp  D.f90 -I<include dir> > Dtemp.f90
f90 -c Dtemp.f90 -o D.o

g77 <PETSC options> A.o B.o C.o D.o -o out.exe

PETSc is configured to use g77 as the linker in my server but since I
am compiling each file separately, I cannot quite use the linker
directly (It treats the source as a linker script). Is there a
simplified way to do this or have I missed something vital ?!

I would appreciate any kind of help you can provide. If you need more
information, let me know. Thanks.

vijay




More information about the petsc-users mailing list