Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Fix regression with f2py wrappers when modules and subroutines are present #25468

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

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/f2py/f90mod_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def dadd(line, s=doc):
mfargs.append(n)
outmess('\t\tConstructing F90 module support for "%s"...\n' %
(m['name']))
if m['name'] in usenames:
if m['name'] in usenames and not onlyvars:
outmess(f"\t\t\tSkipping {m['name']} since it is in 'use'...\n")
continue
if onlyvars:
Expand Down
8 changes: 8 additions & 0 deletions numpy/f2py/tests/src/regression/gh25337/data.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module data
real(8) :: shift
contains
subroutine set_shift(in_shift)
real(8), intent(in) :: in_shift
shift = in_shift
end subroutine set_shift
end module data
6 changes: 6 additions & 0 deletions numpy/f2py/tests/src/regression/gh25337/use_data.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
subroutine shift_a(dim_a, a)
use data, only: shift
integer, intent(in) :: dim_a
real(8), intent(inout), dimension(dim_a) :: a
a = a + shift
end subroutine shift_a
11 changes: 11 additions & 0 deletions numpy/f2py/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ def test_include_path():
fnames_in_dir = os.listdir(incdir)
for fname in ("fortranobject.c", "fortranobject.h"):
assert fname in fnames_in_dir


class TestModuleAndSubroutine(util.F2PyTest):
module_name = "example"
sources = [util.getpath("tests", "src", "regression", "gh25337", "data.f90"),
util.getpath("tests", "src", "regression", "gh25337", "use_data.f90")]

@pytest.mark.slow
def test_gh25337(self):
self.module.data.set_shift(3)
assert "data" in dir(self.module)