Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Routines including procedure arguments (callbacks) are excluded #195

Open
HugoMVale opened this issue Jun 5, 2023 · 1 comment
Open

Comments

@HugoMVale
Copy link

  • Routines containing explicit interfaces are excluded by f90wrap.
  • Routines containing abstract interfaces are not excluded, but are incorrectly wrapped.

Input

! test.f90
module test
    implicit none
    private
    public :: foo, bar

    abstract interface
        function fx(x)
            integer :: x
            integer :: fx
        end function
    end interface
 
 contains
 
    subroutine foo(fnc, a, b)
        interface
            function fnc(x)
                integer :: x
                integer :: fnc
            end function
        end interface
       integer, intent(in) :: a
       integer, intent(out) :: b
       b = fnc(a)
    end subroutine

    subroutine bar(fnc, a, b)
       procedure(fx) :: fnc
       integer, intent(in) :: a
       integer, intent(out) :: b
       b = fnc(a)
    end subroutine
 
 end module test

Intermediate Result
Note how foo is gone.

! Module test defined in file test.f90

subroutine f90wrap_bar(fnc, a, b)
    use test, only: bar
    implicit none
    
    real :: fnc
    integer, intent(in) :: a
    integer, intent(out) :: b
    call bar(fnc=fnc, a=a, b=b)
end subroutine f90wrap_bar

! End of module test defined in file test.f90

Python module
Note how bar is called as a function, when it is actually a subroutine.

from __future__ import print_function, absolute_import, division
import _fortranmodule
import f90wrap.runtime
import logging
import numpy

class Test(f90wrap.runtime.FortranModule):
    """
    Module test
    
    
    Defined at test.f90 lines 1-27
    
    """
    @staticmethod
    def bar(fnc, a):
        """
        b = bar(fnc, a)
        
        
        Defined at test.f90 lines 23-27
        
        Parameters
        ----------
        fnc : float
        a : int
        
        Returns
        -------
        b : int
        
        """
        b = _fortranmodule.f90wrap_bar(fnc=fnc, a=a)
        return b
    
    _dt_array_initialisers = []
    

test = Test()
@HugoMVale HugoMVale changed the title Routines including procedure arguments (callbacks) are excluded BUG: Routines including procedure arguments (callbacks) are excluded Jun 6, 2023
@currodri
Copy link

currodri commented Jul 1, 2023

Hi! I've noticed this problem too. When defining abstract interface it is wrapped incorrectly. I have not been able to fix it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants