MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / createfuncwrapper

Function createfuncwrapper

site-packages/numpy/f2py/func2subr.py:80–183  ·  view source on GitHub ↗
(rout, signature=0)

Source from the content-addressed store, hash-verified

78
79
80def createfuncwrapper(rout, signature=0):
81 assert isfunction(rout)
82
83 extra_args = []
84 vars = rout['vars']
85 for a in rout['args']:
86 v = rout['vars'][a]
87 for i, d in enumerate(v.get('dimension', [])):
88 if d == ':':
89 dn = 'f2py_%s_d%s' % (a, i)
90 dv = dict(typespec='integer', intent=['hide'])
91 dv['='] = 'shape(%s, %s)' % (a, i)
92 extra_args.append(dn)
93 vars[dn] = dv
94 v['dimension'][i] = dn
95 rout['args'].extend(extra_args)
96 need_interface = bool(extra_args)
97
98 ret = ['']
99
100 def add(line, ret=ret):
101 ret[0] = '%s\n %s' % (ret[0], line)
102 name = rout['name']
103 fortranname = getfortranname(rout)
104 f90mode = ismoduleroutine(rout)
105 newname = '%sf2pywrap' % (name)
106
107 if newname not in vars:
108 vars[newname] = vars[name]
109 args = [newname] + rout['args'][1:]
110 else:
111 args = [newname] + rout['args']
112
113 l = var2fixfortran(vars, name, newname, f90mode)
114 if l[:13] == 'character*(*)':
115 if f90mode:
116 l = 'character(len=10)' + l[13:]
117 else:
118 l = 'character*10' + l[13:]
119 charselect = vars[name]['charselector']
120 if charselect.get('*', '') == '(*)':
121 charselect['*'] = '10'
122 sargs = ', '.join(args)
123 if f90mode:
124 add('subroutine f2pywrap_%s_%s (%s)' %
125 (rout['modulename'], name, sargs))
126 if not signature:
127 add('use %s, only : %s' % (rout['modulename'], fortranname))
128 else:
129 add('subroutine f2pywrap%s (%s)' % (name, sargs))
130 if not need_interface:
131 add('external %s' % (fortranname))
132 l = l + ', ' + fortranname
133 if need_interface:
134 for line in rout['saved_interface'].split('\n'):
135 if line.lstrip().startswith('use '):
136 add(line)
137

Callers 1

assubrFunction · 0.85

Calls 15

getfortrannameFunction · 0.85
ismoduleroutineFunction · 0.85
var2fixfortranFunction · 0.85
isexternalFunction · 0.85
isintent_inFunction · 0.85
islogicalfunctionFunction · 0.85
startswithMethod · 0.80
isfunctionFunction · 0.70
addFunction · 0.70
isscalarFunction · 0.70
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected