[petsc-dev] openmp

Matthew Knepley knepley at gmail.com
Wed Nov 6 16:51:17 CST 2013


On Wed, Nov 6, 2013 at 4:47 PM, Svetlana Tkachenko <
svetlana.tkachenko at fastmail.fm> wrote:

> 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.
>

prog: prog.o
      ${CLINKER} -o prog prog.o ${PETSC_LIB}

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

    Matt


>   Svetlana
>
> On Thu, 7 Nov 2013, at 1:19, Barry Smith wrote:
> >
> >    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
> >
> >    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.
> >
> >     Barry
> >
> >
> >
> > On Nov 6, 2013, at 12:25 AM, Svetlana Tkachenko <
> svetlana.tkachenko at fastmail.fm> wrote:
> >
> > > 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:
> > >
> > > ./configure --with-cc=gcc --with-fc=gfortran  --download-f-blas-lapack
> --with-openmp --with-mpi=0
> > >
> > > ~/dev/test/petsc $ echo $LD_LIBRARY_PATH
> > > /home/<username>/petsc/linux-amd64/lib:/opt/openmpi/lib
> > > ~/dev/test/petsc $ cat solver.f
> > >        subroutine solver()
> > > #include <finclude/petscsys.h>
> > >
> > >          PetscErrorCode ierr
> > >          print *, "Entered petsc."
> > >
> > >          ! Init PETSc
> > >          call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
> > >          CHKERRQ(ierr)
> > >          print *, "Init done."
> > >
> > >          ! Finalise PETSc
> > >          call PetscFinalize(ierr)
> > >          CHKERRQ(ierr)
> > >          print *, "Finalized."
> > >         end
> > > ~/dev/test/petsc $ cat myexample.f
> > >       program myexample
> > >
> > >           call solver
> > >       end
> > > ~/dev/test/petsc $ cat makefile
> > > include ${PETSC_DIR}/conf/variables
> > >
> > > myexample: myexample.o solver.o ; gfortran -o myexample myexample.o
> solver.o -lpetsc -L${PETSC_DIR}/${PETSC_ARCH}/lib -fopenmp
> > > 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
> > > 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
> > > ~/dev/test/petsc $ make
> > > 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
> > > 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
> > > In file included from solver.f:3:
> > > /home/<username>/petsc/include/finclude/petscsys.h:10: error: mpif.h:
> No such file or directory
> > > /home/<username>/petsc/include/finclude/petscsys.h:163.29:
> > >    Included at solver.f:3:
> > >
> > >      parameter(MPIU_SCALAR = MPI_DOUBLE_PRECISION)
> > >                             1
> > > Error: Parameter 'mpi_double_precision' at (1) has not been declared
> or is a variable, which does not reduce to a constant expression
> > > /home/<username>/petsc/include/finclude/petscsys.h:171.30:
> > >    Included at solver.f:3:
> > >
> > >      parameter(MPIU_INTEGER = MPI_INTEGER)
> > >                              1
> > > Error: Parameter 'mpi_integer' at (1) has not been declared or is a
> variable, which does not reduce to a constant expression
> > > make: *** [solver.o] Error 1
> > > ~/dev/test/petsc $
> >
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20131106/c15da8fe/attachment.html>


More information about the petsc-dev mailing list