[petsc-users] Question on PETSc makefile

Satish Balay balay at mcs.anl.gov
Thu Aug 25 14:11:01 CDT 2011


PETSc makefiles don't support multiple source dirs properly.

As an alternative - you can try using gnumake's vpath feature [thats
lets you treat multiple sourcedirs as a single source dir].

Attaching makefile with this change..

Satish

On Thu, 25 Aug 2011, Alan Wei wrote:

> Dear all,
>     I hope you're having a nice day.
>     I met a problem on makefile of PETSc. Original PETSc has the makefile in
> the same directory of the .c files. However, I want to put all .c files to
> another directory. I changed the makefile also; however it always has a
> error saying the PETSc header files can not be found:
> 
> /home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/bin/mpicc -Wall
> -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g3  -o
> ComputerRHS.o  Programs/ComputeRHS.c
> -L/home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/lib  -lpetsc
> -Wl,-rpath,/home/zlwei/soft/mercurial/petsc-dev/arch-linux2-c-debug/lib
> -lflapack -lfblas -lm -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -ldl -lmpich
> -lopa -lmpl -lrt -lpthread -lgcc_s -lmpichf90 -lgfortran -lm -lm -ldl
> -lmpich -lopa -lmpl -lrt -lpthread -lgcc_s -ldl
> Programs/ComputeRHS.c:1:23: error: petscdmda.h: No such file or directory
> Programs/ComputeRHS.c:2:22: error: petscksp.h: No such file or directory
> Programs/ComputeRHS.c:3:23: error: petscpcmg.h: No such file or directory
> Programs/ComputeRHS.c:4:23: error: petscdmmg.h: No such file or directory
> In file included from Programs/ComputeRHS.c:5:
> Programs/def.h:6:22: error: petscsys.h: No such file or directory
> In file included from Programs/ComputeRHS.c:5:
> Programs/def.h:25: error: expected specifier-qualifier-list before PetscReal
> Programs/def.h:29: error: expected specifier-qualifier-list before
> PetscScalar
> Programs/def.h:35: error: expected specifier-qualifier-list before PetscInt
> Programs/def.h:41: error: expected specifier-qualifier-list before
> PetscScalar
> Programs/ComputeRHS.c:10: error: expected =, ,, ;, asm or __attribute__
> before ComputeRHS
> make: [ComputeRHS.o] Error 1 (ignored)
> make: *** No rule to make target `Initialization.o', needed by `ex29'.
>  Stop.
> 
>     My codes are attached. Could you please help me to figure this out?
> 
> thanks,
> Alan
> 
-------------- next part --------------

CFLAGS	         =
FFLAGS	         =
CPPFLAGS         =
FPPFLAGS         =
CLEANFILES       = 

include ${PETSC_DIR}/conf/variables
include ${PETSC_DIR}/conf/rules

VPATH=Programs

ex29.o: ex29.c
ComputeRHS.o: ComputeRHS.c ComputeRHS.h def.h
Initialization.o: Initialization.c Initialization.h def.h

OBJS = ex29.o ComputeRHS.o Initialization.o

ex29: ${OBJS} chkopts
	-${CLINKER} -o ex29 ${OBJS} ${PETSC_SNES_LIB}

runex29:
	-@${MPIEXEC} -n 1 ./ex29 -ksp_monitor_short  -dmmg_nlevels 9 > ex29_1.tmp 2>&1;	  \
	   if (${DIFF} output/ex29_1.out ex29_1.tmp) then true; \
	   else echo "Possible problem with ex29_1, diffs above"; fi; \
	   ${RM} -f ex29_1.tmp

runex29_2:
	-@${MPIEXEC} -n 1 ./ex29 -ksp_monitor_short  -bc_type neumann -dmmg_nlevels 9 > ex29_2.tmp 2>&1;	  \
	   if (${DIFF} output/ex29_2.out ex29_2.tmp) then true; \
	   else echo "Possible problem with ex29_2, diffs above"; fi; \
	   ${RM} -f ex29_2.tmp


More information about the petsc-users mailing list