Attaching the modified makefile. It might need a couple of iterations of fixing.
Hopefully its clear why it would work. Note - if not for different flags required for different sources (opt/opt2/opt3) - you can build all petsc/non-petsc sources with petsc makefile targets. > In my fortran files, do I simply use petsc.h or I have to use specific *.h > depending on what petsc commands are used? With petsc-3.1 you just have to use petsc.h for all F77 interface stuff, and petsc.h90 for all f90 interface stuff [like VecGetArrayF90()] Satish On Thu, 13 May 2010, Wee-Beng TAY wrote: > Hi Satish, > > Sorry for the confusion. > > I have attached my makefile. This was used to compile and link my code before > I used PETSc 3.1. > > I have several fortran files. Some contain PETSc commands and need to use > PETSc include files. Other do not. In the end, they all have to be linked to > form my final code. I used to copy part of the compiling and linking command > from "make ex1f" to compile my code: > > /app1/mvapich2/current/bin/mpif90 -c -O3 > -I/home/svu/g0306332/codes/petsc-3.1-p0/atlas5-mpi-nodebug/include > -I/home/svu/g0306332/codes/petsc-3.1-p0/include > -I/home/svu/g0306332/lib/hypre-2.6.0b_atlas5/include > -I/app1/mvapich2/1.4/include -I/app1/mvapich2/current/include > -I/home/svu/g0306332/codes/petsc-3.1-p0/atlas5-mpi-nodebug/include > -I/home/svu/g0306332/lib/hypre-2.6.0b_atlas5/include > -I/app1/mvapich2/1.4/include -I/app1/mvapich2/current/include -o ex1f.o > ex1f.F > > /app1/mvapich2/current/bin/mpif90 -O3 -o ex1f ex1f.o > -Wl,-rpath,/home/svu/g0306332/codes/petsc-3.1-p0/atlas5-mpi-nodebug/lib > -L/home/svu/g0306332/codes/petsc-3.1-p0/atlas5-mpi-nodebug/lib -lpetsc > -Wl,-rpath,/home/svu/g0306332/lib/hypre-2.6.0b_atlas5/lib > -L/home/svu/g0306332/lib/hypre-2.6.0b_atlas5/lib -lHYPRE -lmpichcxx -lstdc++ > -Wl,-rpath,/app1/intel/mkl/10.0.5.025/lib/em64t > -L/app1/intel/mkl/10.0.5.025/lib/em64t -lmkl_lapack -lmkl -lguide -lpthread > -L/app1/mvapich2/1.4/lib -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -ldl -lmpich > -lpthread -lrdmacm -libverbs -libumad -lrt -lgcc_s -lmpichf90 > -L/app1/intel/Compiler/11.0/074/lib/intel64 -lifport -lifcore -limf -lsvml -lm > -lipgo -lirc -lirc_s -lm -lmpichcxx -lstdc++ -lmpichcxx -lstdc++ -ldl -lmpich > -lpthread -lrdmacm -libverbs -libumad -lrt -lgcc_s -ldl > > However, it doesn't seem to work now. I tried to look at chapter 14 but I > don't really understand since I know very little about makefiles. > > Can you give a rough guide for my case? I will try to read up on the manual to > get more info. > > Moreover, I am confused by the use of: > > #include "finclude/petsc.h" etc. > > In my fortran files, do I simply use petsc.h or I have to use specific *.h > depending on what petsc commands are used? > > Thank you very much and have a nice day! > > Yours sincerely, > > Wee-Beng Tay > > > On 12/5/2010 9:55 AM, Satish Balay wrote: > > Lets step back and deal with this primary issue. > > > > Have you attempted to use makefiles in petsc format? What problems > > have you encountered? Perhaps they are fixable. > > > > The reason to use this format is to make your makefile as portable as > > possible [and avoid such issues]. > > > > Satish > > > > On Tue, 11 May 2010, Satish Balay wrote: > > > > > > > Why not use petsc makefiles - and avoid these hasseles? > > > > > > > > -------------- next part -------------- # PETSC_DIR and PETSC_ARCH should be set either in env or in this makeifle CFLAGS = FFLAGS = -r8 -132 -fPIC -g -w90 -w -w95 -c -O3 # instead of opt2 add these flags to default petsc compile target for .F/.f CPPFLAGS = FPPFLAGS = CLEANFILES = a.out include ${PETSC_DIR}/conf/variables include ${PETSC_DIR}/conf/rules opt = -r8 -w95 -c -O3 opt3 = -w95 -c -O3 libs =/home/svu/g0306332/lib/tecio64.a /home/svu/g0306332/lib/linux64.a OBJS = global.o grid.o flux_area.o bc.o bc_impl.o bc_semi.o set_matrix.o inter_step.o mom_disz.o poisson.o petsc_sub.o cell_data.o fractional.o ns2d_c.o # perhaps -r8 -w95 -fPIC -g -O3 flags not needed here? a.out : $(OBJS) $(FLINKER) -r8 -w95 -fPIC -g -O3 -o a.out $(OBJS) $(libs) $(PETSC_LIB) #compiled these sources with default petsc targets global.o : global.F petsc_sub.o : petsc_sub.F poisson.o ns2d_c.o : ns2d_c.f90 cell_data.o fractional.o # sources compiled separately - as they need different opt/opt3 compiler flags. grid.o : grid.f90 global.o $(FC) $(opt3) grid.f90 flux_area.o : flux_area.f90 global.o $(FC) $(opt) flux_area.f90 bc.o : bc.f90 flux_area.o $(FC) $(opt) bc.f90 bc_impl.o : bc_impl.f90 bc.o $(FC) $(opt) bc_impl.f90 bc_semi.o : bc_semi.f90 bc.o $(FC) $(opt) bc_semi.f90 set_matrix.o : set_matrix.f90 bc_semi.o bc_impl.o $(FC) $(opt) set_matrix.f90 inter_step.o : inter_step.f90 bc_impl.o $(FC) $(opt) inter_step.f90 mom_disz.o : mom_disz.f90 bc_impl.o bc_semi.o set_matrix.o $(FC) $(opt) mom_disz.f90 poisson.o : poisson.f90 set_matrix.o $(FC) $(opt) poisson.f90 cell_data.o : cell_data.f90 grid.o set_matrix.o $(FC) $(opt) cell_data.f90 fractional.o : fractional.f90 mom_disz.o petsc_sub.o inter_step.o $(FC) $(opt) fractional.f90