summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-06-16 07:05:03 -0600
committerGitHub <noreply@github.com>2017-06-16 07:05:03 -0600
commit1490ccde8215bc6f4720266259672e34ebcda98f (patch)
treec71c3f13aad0213c2adb5e277b1eb87e4c93f9f0
parent9b450e73e74fb4325598e40051655af6fc7038da (diff)
parent8042526ba48c6d817d32300c1ecbea95d395c62e (diff)
downloadnumpy-1490ccde8215bc6f4720266259672e34ebcda98f.tar.gz
Merge pull request #9247 from bobeldering/f2py-badname-common
BUG: fix missing keyword rename for common block to numpy.f2py
-rwxr-xr-xnumpy/f2py/crackfortran.py2
-rw-r--r--numpy/f2py/tests/src/common/block.f11
-rw-r--r--numpy/f2py/tests/test_common.py26
3 files changed, 38 insertions, 1 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
index 0f05375c7..0f5e6e023 100755
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -2013,7 +2013,7 @@ def analyzecommon(block):
if m.group('dims'):
dims = [x.strip()
for x in markoutercomma(m.group('dims')).split('@,@')]
- n = m.group('name').strip()
+ n = rmbadname1(m.group('name').strip())
if n in block['vars']:
if 'attrspec' in block['vars'][n]:
block['vars'][n]['attrspec'].append(
diff --git a/numpy/f2py/tests/src/common/block.f b/numpy/f2py/tests/src/common/block.f
new file mode 100644
index 000000000..7ea7968fe
--- /dev/null
+++ b/numpy/f2py/tests/src/common/block.f
@@ -0,0 +1,11 @@
+ SUBROUTINE INITCB
+ DOUBLE PRECISION LONG
+ CHARACTER STRING
+ INTEGER OK
+
+ COMMON /BLOCK/ LONG, STRING, OK
+ LONG = 1.0
+ STRING = '2'
+ OK = 3
+ RETURN
+ END
diff --git a/numpy/f2py/tests/test_common.py b/numpy/f2py/tests/test_common.py
new file mode 100644
index 000000000..027d558aa
--- /dev/null
+++ b/numpy/f2py/tests/test_common.py
@@ -0,0 +1,26 @@
+from __future__ import division, absolute_import, print_function
+
+import os
+
+from numpy.testing import run_module_suite, assert_array_equal, dec
+import numpy as np
+import util
+
+
+def _path(*a):
+ return os.path.join(*((os.path.dirname(__file__),) + a))
+
+class TestCommonBlock(util.F2PyTest):
+ sources = [_path('src', 'common', 'block.f')]
+
+ def test_common_block(self):
+ self.module.initcb()
+ assert_array_equal(self.module.block.long_bn,
+ np.array(1.0, dtype=np.float64))
+ assert_array_equal(self.module.block.string_bn,
+ np.array('2', dtype='|S1'))
+ assert_array_equal(self.module.block.ok,
+ np.array(3, dtype=np.int32))
+
+if __name__ == "__main__":
+ run_module_suite()