[petsc-users] Problem with encapsulation of PETSc/SLEPc in Fortran

Smith, Barry F. bsmith at mcs.anl.gov
Thu Nov 2 10:02:40 CDT 2017

> On Nov 1, 2017, at 10:23 AM, Thibaut Appel <t.appel17 at imperial.ac.uk> wrote:
> Dear PETSc/SLEPc users,
> I am encountering a problem when I try to isolate my calls to PETSc/SLEPc routines in a module. When I have a single file everything works fine, but when I have, say:
> - modA.f90 (Independant modules)
> - modB.F90 (Contains all the calls to PETSc and SLEPc)
> - main.f90 or main.F90
> When calling EPSSolve, I keep having the error "[1]PETSC ERROR: Caught signal number 8 FPE: Floating Point Exception,probably divide by zero" plus "User provided function() line 0 in  unknown file."
> With gdb: "Thread 1 "main" received signal SIGFPE, Arithmetic exception. 0x00007ffff1662cf6 in dlamch_ () from /home/linuxbrew/.linuxbrew/lib/libopenblas.so.0"
> The PETSc/SLEPc module looks like
>   USE SlepcEps
> #include <slepc/finclude/slepcepsdef.h>
> which is the only preprocessed directive used. I tried to add more (petscsys, petscmat, petscvec, slepseps), tried to change main.f90 to main.F90 and incorporate the preprocessed directives there as well without any effect. My code calls CHKERRQ(ierr) systematically. My makefile looks like
>     include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
>     INCL = -I$(PETSC_DIR)/include/ -I$(SLEPC_DIR)/include/
>     %.o: %.f90
>         $(FC) $(FLAGS) $(INCL) -c $< -o $@ $(SLEPC_EPS_LIB)
>     %.o: %.F90
>         $(FC) $(FLAGS) $(INCL) -c $< -o $@ $(SLEPC_EPS_LIB)
>     $(EXEC): $(OBJS)
>         $(FC) $(FLAGS) $(INCL) $(OBJS) -o $@ $(SLEPC_EPS_LIB)
> Could you spot anything I am doing wrong or dangerous?

  No idea. Run in the debugger to find out where the problem occurs.

> Furthermore, do you know how to avoid the warnings "Same actual argument associated with INTENT(IN) argument 'errorcode' and INTENT(OUT) argument 'ierror' at (1)" when calling CHKERRQ(ierr) when ierr is declared as INTEGER?

  Upgrade PETSc to remove this error.

> Thanks in advance for your continued support,
> Thibaut

More information about the petsc-users mailing list