diff options
author | mattip <matti.picus@gmail.com> | 2019-12-03 08:30:50 +0200 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-12-03 09:08:37 +0200 |
commit | 522e6241c5d95522345ebe2611e8d006388e575c (patch) | |
tree | aeac34e7dbccf9319ab7ae3e28c2f5492cf0f871 /numpy/f2py | |
parent | 3a9a63f81aa37b48bc3eb4efdc2e695210805aa5 (diff) | |
download | numpy-522e6241c5d95522345ebe2611e8d006388e575c.tar.gz |
BUG: add endfunction, endsubroutine to valid fortran end words
Diffstat (limited to 'numpy/f2py')
-rwxr-xr-x | numpy/f2py/crackfortran.py | 3 | ||||
-rw-r--r-- | numpy/f2py/tests/test_crackfortran.py | 39 |
2 files changed, 41 insertions, 1 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2aaf5d7c6..2db4a47e8 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -558,7 +558,8 @@ groupbegins90 = groupbegins77 + \ r'|module(?!\s*procedure)|python\s*module|interface|type(?!\s*\()' beginpattern90 = re.compile( beforethisafter % ('', groupbegins90, groupbegins90, '.*'), re.I), 'begin' -groupends = r'end|endprogram|endblockdata|endmodule|endpythonmodule|endinterface' +groupends = (r'end|endprogram|endblockdata|endmodule|endpythonmodule|' + r'endinterface|endsubroutine|endfunction') endpattern = re.compile( beforethisafter % ('', groupends, groupends, r'[\w\s]*'), re.I), 'end' # endifs='end\s*(if|do|where|select|while|forall)' diff --git a/numpy/f2py/tests/test_crackfortran.py b/numpy/f2py/tests/test_crackfortran.py new file mode 100644 index 000000000..8af1b4d80 --- /dev/null +++ b/numpy/f2py/tests/test_crackfortran.py @@ -0,0 +1,39 @@ +from __future__ import division, absolute_import, print_function + +import pytest + +import numpy as np +from numpy.testing import assert_array_equal +from . import util + + +class TestNoSpace(util.F2PyTest): + code = """ + subroutine subb(k) + real(8), intent(inout) :: k(:) + k=k+1 + endsubroutine + + subroutine subc(w,k) + real(8), intent(in) :: w(:) + real(8), intent(out) :: k(size(w)) + k=w+1 + endsubroutine + + function t0(value) + character value + character t0 + t0 = value + endfunction + + """ + + def test_module(self): + k = np.array([1, 2, 3], dtype = np.float) + w = np.array([1, 2, 3], dtype = np.float) + self.module.subb(k) + assert_array_equal(k, w + 1) + self.module.subc([w, k]) + assert_array_equal(k, w + 1) + assert self.module.t0(23) == b'2' + |