Skip to content

BUG: f2py generation loses intent specs on using --no-lower option #20943

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

Closed
dwr-psandhu opened this issue Jan 30, 2022 · 1 comment · Fixed by #24555
Closed

BUG: f2py generation loses intent specs on using --no-lower option #20943

dwr-psandhu opened this issue Jan 30, 2022 · 1 comment · Fixed by #24555

Comments

@dwr-psandhu
Copy link

Describe the issue:

f2py generation of .pyf files works with default options but loses the intent specs when --no-lower is specified

See example below, its missing intent specs. If run without the --no-lower option it works fine.

Reproduce the code example:

f2py --no-lower -m testnl -h test_nolower.pyf

E.g. with a test file with this code
MODULE Test_Module
    IMPLICIT NONE
    CONTAINS
  SUBROUTINE Test_Routine(len_fname,fname,iStat) BIND(C,NAME='Test_Routine')
    INTEGER,INTENT(IN)    :: len_fname
    CHARACTER,INTENT(IN) :: fname(len_fname)
    INTEGER,INTENT(OUT)   :: iStat
  END SUBROUTINE
END MODULE

Error message:

!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module testnl ! in 
    interface  ! in :testnl
        module Test_Module ! in :testnl:test_f2py_intent.f90
            subroutine Test_Routine(len_fname,fname,iStat) ! in :testnl:test_f2py_intent.f90:Test_Module
                integer, optional,check(len(fname)>=len_fname),depend(fname) :: len_fname=len(fname)
                character dimension(len_fname) :: fname
                integer :: iStat
            end subroutine Test_Routine
        end module Test_Module
    end interface 
end python module testnl

! This file was auto-generated with f2py (version:1.21.2).
! See http://cens.ioc.ee/projects/f2py2e/

NumPy/Python version information:

1.21.2 3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)]

@HaoZeke
Copy link
Member

HaoZeke commented Apr 28, 2022

--no-lower isn't actually doing what is expected (i.e. things are still in scream-case). Also, although the intent specs are present, they are also mangled.

!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module testnl ! in 
    interface  ! in :testnl
        module test_module ! in :testnl:repro.f90
            subroutine test_routine(len_fname,fname,istat) ! in :testnl:repro.f90:test_module
                integer, optional,intent(in),check(shape(fname, 0) == len_fname),depend(fname) :: len_fname=shape(fname, 0)
                character dimension(len_fname),intent(in) :: fname
                integer intent(out) :: istat
            end subroutine test_routine
        end module test_module
    end interface 
end python module testnl

! This file was auto-generated with f2py (version:1.23.0.dev0+1087.g0eaa40db3).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e

Note that the istat variable gets integer intent(out) :: istat instead of integer, intent(out).

Then again, it also is unclear why it is valid to pass --no-lower to what is clearly not F77 code (module / bind(c) are both F90 features). A warning should be issued.

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

Successfully merging a pull request may close this issue.

3 participants