Code Monkey home page Code Monkey logo

Comments (5)

 avatar commented on July 18, 2024

Thanks for reporting, I will have a look at the asterisk parsing.

For the real(kind=8) case, note that you need to supply a file containing the mapping from kinds to C types as no attempt is made to interpret the kind strings (I admit that this is silly when they are simply numbers like kind=8, I'll try to fix this soon too...). Here's an example kind_map for your case:

$ cat kind_map
{
 'real':     {'': 'float',
              '8': 'double'}
}
$ f90wrap -k kind_map test.f90

which results in the correct wrapper:

subroutine f90wrap_foo(a, b)
    implicit none
    external foo

    real(8), intent(in) :: a
    integer :: b
    call foo(a, b)
end subroutine f90wrap_foo

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

(Oops, signed in as wrong GitHub user, previous comment was by me as well)

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Interfaced functions of a f90 module are translated to static methods in the auto generate python class, however in the function list for the overloaded call loop, the function names are not prefixed by Class_name, i.e. [Class_name.method1(a,b), Class_name.method1(a,b,c), ... ]

Understood. Do you have a simple test case I could use to speed up debugging this issue?

from f90wrap.

csullivan avatar csullivan commented on July 18, 2024

Hi, sure no problem.

example.F90

!-*-f90-*-                                                                                                                                                                             
module class_example

  implicit none
  private
  public :: Example, return_example

  interface return_example
     module procedure return_example_first, return_example_second, return_example_third
  end interface return_example

  type Example
     integer :: first
     integer :: second
     integer :: third
  end type Example

  ! singleton                                                                                                                                                                          
  type(Example) :: this 

contains

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

  function return_example_first(first) result(instance)

    implicit none
    integer :: first
    type(Example) :: instance

    this%first = first
    instance = this

    return

  end function return_example_first

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

  function return_example_second(first,second) result(instance)                                                                                                                        

    implicit none
    integer :: first
    integer :: second
    type(Example) :: instance

    this%first = first
    this%second = second

    instance = this
    return

  end function return_example_second

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

  function return_example_third(first,second,third) result(instance)

    implicit none
    integer :: first
    integer :: second
    integer :: third
    type(Example) :: instance

    this%first = first
    this%second = second
    this%third = third

    instance = this
    return

  end function return_example_third

!------------------------------------------------------------------------------------!                                                                                                 
end module class_example

Then f90wrap -m example ./example.F90 produces example.py, which contains the following loop over interfaced member functions (which should be prefixed with the class name since they are static, or not be static):

example.py (abridged)

...
    @staticmethod
    def _return_example_third(first, second, third):
        ...

    @staticmethod
    def return_example(*args, **kwargs):
        """                                                                                                                                                                            
        return_example(*args, **kwargs)                                                                                                                                                


        Defined at ./example.F90 lines 8-10                                                                                                                                            

        Overloaded interface containing the following procedures:                                                                                                                      
          _return_example_first                                                                                                                                                        
          _return_example_second                                                                                                                                                       
          _return_example_third                                                                                                                                                        

        """
        for proc in [_return_example_first, _return_example_second, \
            _return_example_third]:
            try:
                return proc(*args, **kwargs)
            except TypeError:
                continue                                                                                                                                                               

Manually changing the above list to,

for proc in [Class_Example._return_example_first, \
            Class_Example._return_example_second, \
            Class_Example._return_example_third]:

Fixes the python runtime error (NameError: global function return_example* is not defined).

from f90wrap.

jameskermode avatar jameskermode commented on July 18, 2024

Interface generation should now be fixed. I didn't look at the asterisk parsing yet.

from f90wrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.