hi Barry,

On 18/10/18 11:34 AM, Smith, Barry F. wrote:
    Sorry about this problem. I think the change was only introduced in master 
and should not affect 3.10.x Please confirm that master is where the failed 
compile is?

Yes, it's on master. I have tracked down the commit at which it started to fail: 6f222c9d1e, "type checking for Fortran" (Fri Sep 28).

    Please send us the calling sequence of your routine that won't compile (cut 
and paste).

I've attached a minimal example program which fails with the following error:

   call SNESSetConvergenceTest(snes, convergence, context, &
                                                 1
Error: Actual argument at (1) to assumed-type dummy is of derived type with type-bound or FINAL procedures

Cheers, Adrian

On Oct 17, 2018, at 5:21 PM, Adrian Croucher <[email protected]> wrote:

hi

A colleague has just reported that my code no longer builds with PETSc 3.10.2, 
though it builds OK with 3.10.1.

The problem appears to be the Fortran interface to SNESSetConvergenceTest(), 
which was changed at commit f9a1a4d.

It now complains about the context argument we are passing in to this function 
('cctx' in the interface, which is declared there as type(*)). The error is:

"Error: Actual argument at (1) to assumed-type dummy is of derived type with 
type-bound or FINAL procedures"

This is true, the argument being passed in is of derived type with type-bound 
procedures. Previously this didn't bother it, but it looks like it does now.

Is its complaint legitimate? or perhaps a compiler bug? (this is using gcc 
6.3.0)

- Adrian

--
Dr Adrian Croucher
Senior Research Fellow
Department of Engineering Science
University of Auckland, New Zealand
email: [email protected]
tel: +64 (0)9 923 4611

module context_module

#include <petsc/finclude/petsc.h>

  use petsc

  implicit none
  private

  type, public ::  context_type
     private
     PetscInt :: foo
   contains
     procedure, public :: init => context_init
  end type context_type

contains

  subroutine context_init(self, foo)
    class(context_type), intent(in out) :: self
    PetscInt, intent(in) :: foo
    self%foo = foo
  end subroutine context_init

end module context_module

!------------------------------------------------------------------------

program test_snes

  ! tests SNESSetConvergenceTest()
  
#include <petsc/finclude/petsc.h>

  use petsc
  use context_module

  implicit none

  SNES :: snes
  type(context_type) :: context
  PetscErrorCode :: ierr

  call PetscInitialize(PETSC_NULL_CHARACTER, ierr)
  call SNESCreate(PETSC_COMM_WORLD, snes, ierr)
  call context%init(1)

  call SNESSetConvergenceTest(snes, convergence, context, &
       PETSC_NULL_FUNCTION, ierr)

  call SNESDestroy(snes, ierr)
  call PetscFinalize(ierr)

contains

  subroutine convergence(snes, num_iterations, xnorm, pnorm, &
       fnorm, reason, context, ierr)

    SNES, intent(in) :: snes
    PetscInt, intent(in) :: num_iterations
    PetscReal, intent(in) :: xnorm, pnorm, fnorm
    SNESConvergedReason, intent(out) :: reason
    type(context_type), intent(in out) :: context
    PetscErrorCode, intent(out) :: ierr
  
    reason = 0
    ierr = 0

  end subroutine convergence
    
end program test_snes

Reply via email to