<div dir="ltr">On Wed, Nov 6, 2013 at 4:47 PM, Svetlana Tkachenko <span dir="ltr"><<a href="mailto:svetlana.tkachenko@fastmail.fm" target="_blank">svetlana.tkachenko@fastmail.fm</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Thanks. Could you please send an example makefile for this small example as src/ts/examples/tutorials/makefile is huge and I don't know which part of it manages the -I -L stuff.<br>
</blockquote><div><br></div><div>prog: prog.o</div><div>      ${CLINKER} -o prog prog.o ${PETSC_LIB}</div><div><br></div><div>include ${PETSC_DIR}/conf/variables</div><div>include ${PETSC_DIR}/conf/rules</div><div><br></div>
<div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  Svetlana<br>
<br>
On Thu, 7 Nov 2013, at 1:19, Barry Smith wrote:<br>
><br>
>    Your makefile does not indicate the location of mpif.h to your FORTRAN compiler which in the case of —with-mpi=0 is in ${PETSC}/include/mpiuni<br>
><br>
>    Note that if you simply copy a makefile from PETSc, say src/ts/examples/tutorials/makefile and modify that slightly for you code you don’t need to manage all the -I -L stuff yourself, our makefiles take care of it and are portable for different MPIs etc.<br>

><br>
>     Barry<br>
><br>
><br>
><br>
> On Nov 6, 2013, at 12:25 AM, Svetlana Tkachenko <<a href="mailto:svetlana.tkachenko@fastmail.fm">svetlana.tkachenko@fastmail.fm</a>> wrote:<br>
><br>
> > I have configured petsc-dev (downloaded it today) with these options, and a small example. It appears to fail to compile without MPI with the error message:<br>
> ><br>
> > ./configure --with-cc=gcc --with-fc=gfortran  --download-f-blas-lapack --with-openmp --with-mpi=0<br>
> ><br>
> > ~/dev/test/petsc $ echo $LD_LIBRARY_PATH<br>
> > /home/<username>/petsc/linux-amd64/lib:/opt/openmpi/lib<br>
> > ~/dev/test/petsc $ cat solver.f<br>
> >        subroutine solver()<br>
> > #include <finclude/petscsys.h><br>
> ><br>
> >          PetscErrorCode ierr<br>
> >          print *, "Entered petsc."<br>
> ><br>
> >          ! Init PETSc<br>
> >          call PetscInitialize(PETSC_NULL_CHARACTER,ierr)<br>
> >          CHKERRQ(ierr)<br>
> >          print *, "Init done."<br>
> ><br>
> >          ! Finalise PETSc<br>
> >          call PetscFinalize(ierr)<br>
> >          CHKERRQ(ierr)<br>
> >          print *, "Finalized."<br>
> >         end<br>
> > ~/dev/test/petsc $ cat myexample.f<br>
> >       program myexample<br>
> ><br>
> >           call solver<br>
> >       end<br>
> > ~/dev/test/petsc $ cat makefile<br>
> > include ${PETSC_DIR}/conf/variables<br>
> ><br>
> > myexample: myexample.o solver.o ; gfortran -o myexample myexample.o solver.o -lpetsc -L${PETSC_DIR}/${PETSC_ARCH}/lib -fopenmp<br>
> > solver.o: ; gfortran -c -cpp -I${PETSC_DIR}/include -O0 solver.f -lpetsc -I${PETSC_DIR}/${PETSC_ARCH}/include -L${PETSC_DIR}/${PETSC_ARCH}/lib -lpetsc -fopenmp<br>
> > myexample.o: ; gfortran -c -cpp -I${PETSC_DIR}/include -O0 myexample.f -lpetsc -I${PETSC_DIR}/${PETSC_ARCH}/include -L${PETSC_DIR}/${PETSC_ARCH}/lib -lpetsc -fopenmp<br>
> > ~/dev/test/petsc $ make<br>
> > gfortran -c -cpp -I/home/<username>/petsc/include -O0 myexample.f -lpetsc -I/home/<username>/petsc/linux-amd64/include -L/home/<username>/petsc/linux-amd64/lib -lpetsc -fopenmp<br>
> > gfortran -c -cpp -I/home/<username>/petsc/include -O0 solver.f -lpetsc -I/home/<username>/petsc/linux-amd64/include -L/home/<username>/petsc/linux-amd64/lib -lpetsc -fopenmp<br>
> > In file included from solver.f:3:<br>
> > /home/<username>/petsc/include/finclude/petscsys.h:10: error: mpif.h: No such file or directory<br>
> > /home/<username>/petsc/include/finclude/petscsys.h:163.29:<br>
> >    Included at solver.f:3:<br>
> ><br>
> >      parameter(MPIU_SCALAR = MPI_DOUBLE_PRECISION)<br>
> >                             1<br>
> > Error: Parameter 'mpi_double_precision' at (1) has not been declared or is a variable, which does not reduce to a constant expression<br>
> > /home/<username>/petsc/include/finclude/petscsys.h:171.30:<br>
> >    Included at solver.f:3:<br>
> ><br>
> >      parameter(MPIU_INTEGER = MPI_INTEGER)<br>
> >                              1<br>
> > Error: Parameter 'mpi_integer' at (1) has not been declared or is a variable, which does not reduce to a constant expression<br>
> > make: *** [solver.o] Error 1<br>
> > ~/dev/test/petsc $<br>
><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>