diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/f2py/capi_maps.py | 11 | ||||
-rw-r--r-- | numpy/f2py/func2subr.py | 11 | ||||
-rw-r--r-- | numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap | 1 | ||||
-rw-r--r-- | numpy/f2py/tests/src/assumed_shape/foo_use.f90 | 19 | ||||
-rw-r--r-- | numpy/f2py/tests/src/assumed_shape/precision.f90 | 4 | ||||
-rw-r--r-- | numpy/f2py/tests/test_assumed_shape.py | 10 | ||||
-rw-r--r-- | numpy/f2py/tests/util.py | 6 |
7 files changed, 55 insertions, 7 deletions
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index c10e3ee84..beff1e212 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -192,8 +192,8 @@ if os.path.isfile('.f2py_f2cmap'): else: errmess("\tIgnoring map {'%s':{'%s':'%s'}}: '%s' must be in %s\n"%(k,k1,d[k][k1],d[k][k1],c2py_map.keys())) outmess('Succesfully applied user defined changes from .f2py_f2cmap\n') - except: - errmess('Failed to apply user defined changes from .f2py_f2cmap. Skipping.\n') + except Exception, msg: + errmess('Failed to apply user defined changes from .f2py_f2cmap: %s. Skipping.\n' % (msg)) cformat_map={'double':'%g', 'float':'%g', 'long_double':'%Lg', @@ -251,8 +251,9 @@ def getctype(var): try: ctype=f2cmap[str(var['kindselector']['kind'])] except KeyError: - errmess('getctype: "%s(kind=%s)" not supported (use .f2py_f2cmap).\n'\ - %(typespec,var['kindselector']['kind'])) + errmess('getctype: "%s(kind=%s)" is mapped to C "%s" (to override define dict(%s = dict(%s="<C typespec>")) in %s/.f2py_f2cmap file).\n'\ + %(typespec,var['kindselector']['kind'], ctype, + typespec,var['kindselector']['kind'], os.getcwd())) else: if not isexternal(var): @@ -436,7 +437,7 @@ def getinit(a,var): v = eval(v,{},{}) ret['init.r'],ret['init.i']=str(v.real),str(v.imag) except: - raise ValueError('sign2map: expected complex number `(r,i)\' but got `%s\' as initial value of %r.' % (init, a)) + raise ValueError('getinit: expected complex number `(r,i)\' but got `%s\' as initial value of %r.' % (init, a)) if isarray(var): init='(capi_c.r=%s,capi_c.i=%s,capi_c)'%(ret['init.r'],ret['init.i']) elif isstring(var): diff --git a/numpy/f2py/func2subr.py b/numpy/f2py/func2subr.py index 4fee8c3c1..02401d504 100644 --- a/numpy/f2py/func2subr.py +++ b/numpy/f2py/func2subr.py @@ -126,6 +126,12 @@ def createfuncwrapper(rout,signature=0): add('external %s'%(fortranname)) #if not return_char_star: l = l + ', '+fortranname + + if need_interface: + for line in rout['saved_interface'].split('\n'): + if line.lstrip().startswith('use '): + add(line) + args = args[1:] dumped_args = [] for a in args: @@ -201,6 +207,11 @@ def createsubrwrapper(rout,signature=0): if not need_interface: add('external %s'%(fortranname)) + if need_interface: + for line in rout['saved_interface'].split('\n'): + if line.lstrip().startswith('use '): + add(line) + dumped_args = [] for a in args: if isexternal(vars[a]): diff --git a/numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap b/numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap new file mode 100644 index 000000000..2665f89b5 --- /dev/null +++ b/numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap @@ -0,0 +1 @@ +dict(real=dict(rk="double")) diff --git a/numpy/f2py/tests/src/assumed_shape/foo_use.f90 b/numpy/f2py/tests/src/assumed_shape/foo_use.f90 new file mode 100644 index 000000000..337465ac5 --- /dev/null +++ b/numpy/f2py/tests/src/assumed_shape/foo_use.f90 @@ -0,0 +1,19 @@ +subroutine sum_with_use(x, res) + use precision + + implicit none + + real(kind=rk), intent(in) :: x(:) + real(kind=rk), intent(out) :: res + + integer :: i + + !print *, "size(x) = ", size(x) + + res = 0.0 + + do i = 1, size(x) + res = res + x(i) + enddo + + end subroutine diff --git a/numpy/f2py/tests/src/assumed_shape/precision.f90 b/numpy/f2py/tests/src/assumed_shape/precision.f90 new file mode 100644 index 000000000..ed6c70cbb --- /dev/null +++ b/numpy/f2py/tests/src/assumed_shape/precision.f90 @@ -0,0 +1,4 @@ +module precision + integer, parameter :: rk = selected_real_kind(8) + integer, parameter :: ik = selected_real_kind(4) +end module diff --git a/numpy/f2py/tests/test_assumed_shape.py b/numpy/f2py/tests/test_assumed_shape.py index 6a562ebdc..3e5502cb0 100644 --- a/numpy/f2py/tests/test_assumed_shape.py +++ b/numpy/f2py/tests/test_assumed_shape.py @@ -9,8 +9,11 @@ import util def _path(*a): return os.path.join(*((os.path.dirname(__file__),) + a)) -class TestMixed(util.F2PyTest): - sources = [_path('src', 'assumed_shape', 'foo_free.f90')] +class TestAssumedShapeSumExample(util.F2PyTest): + sources = [_path('src', 'assumed_shape', 'foo_free.f90'), + _path('src', 'assumed_shape', 'foo_use.f90'), + _path('src', 'assumed_shape', 'precision.f90'), + ] @dec.slow def test_all(self): @@ -20,6 +23,9 @@ class TestMixed(util.F2PyTest): r = self.module.sum([1,2]) assert r==3,`r` + r = self.module.sum_with_use([1,2]) + assert r==3,`r` + if __name__ == "__main__": import nose nose.runmodule() diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index 422d5965e..a5816b96f 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -106,6 +106,12 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None): shutil.copyfile(fn, dst) dst_sources.append(dst) + fn = os.path.join(os.path.dirname(fn), '.f2py_f2cmap') + if os.path.isfile(fn): + dst = os.path.join(d, os.path.basename(fn)) + if not os.path.isfile(dst): + shutil.copyfile(fn, dst) + # Prepare options if module_name is None: module_name = get_temp_module_name() |