[petsc-dev] openmp

Barry Smith bsmith at mcs.anl.gov
Wed Nov 6 08:49:19 CST 2013


   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 $ 




More information about the petsc-dev mailing list