(rout, signature=0)
| 84 | return useisoc |
| 85 | |
| 86 | def createfuncwrapper(rout, signature=0): |
| 87 | assert isfunction(rout) |
| 88 | |
| 89 | extra_args = [] |
| 90 | vars = rout['vars'] |
| 91 | for a in rout['args']: |
| 92 | v = rout['vars'][a] |
| 93 | for i, d in enumerate(v.get('dimension', [])): |
| 94 | if d == ':': |
| 95 | dn = f'f2py_{a}_d{i}' |
| 96 | dv = {'typespec': 'integer', 'intent': ['hide']} |
| 97 | dv['='] = f'shape({a}, {i})' |
| 98 | extra_args.append(dn) |
| 99 | vars[dn] = dv |
| 100 | v['dimension'][i] = dn |
| 101 | rout['args'].extend(extra_args) |
| 102 | need_interface = bool(extra_args) |
| 103 | |
| 104 | ret = [''] |
| 105 | |
| 106 | def add(line, ret=ret): |
| 107 | ret[0] = f'{ret[0]}\n {line}' |
| 108 | name = rout['name'] |
| 109 | fortranname = getfortranname(rout) |
| 110 | f90mode = ismoduleroutine(rout) |
| 111 | newname = f'{name}f2pywrap' |
| 112 | |
| 113 | if newname not in vars: |
| 114 | vars[newname] = vars[name] |
| 115 | args = [newname] + rout['args'][1:] |
| 116 | else: |
| 117 | args = [newname] + rout['args'] |
| 118 | |
| 119 | l_tmpl = var2fixfortran(vars, name, '@@@NAME@@@', f90mode) |
| 120 | if l_tmpl[:13] == 'character*(*)': |
| 121 | if f90mode: |
| 122 | l_tmpl = 'character(len=10)' + l_tmpl[13:] |
| 123 | else: |
| 124 | l_tmpl = 'character*10' + l_tmpl[13:] |
| 125 | charselect = vars[name]['charselector'] |
| 126 | if charselect.get('*', '') == '(*)': |
| 127 | charselect['*'] = '10' |
| 128 | |
| 129 | l1 = l_tmpl.replace('@@@NAME@@@', newname) |
| 130 | rl = None |
| 131 | |
| 132 | useisoc = useiso_c_binding(rout) |
| 133 | sargs = ', '.join(args) |
| 134 | if f90mode: |
| 135 | # gh-23598 fix warning |
| 136 | # Essentially, this gets called again with modules where the name of the |
| 137 | # function is added to the arguments, which is not required, and removed |
| 138 | sargs = sargs.replace(f"{name}, ", '') |
| 139 | args = [arg for arg in args if arg != name] |
| 140 | rout['args'] = args |
| 141 | add(f"subroutine f2pywrap_{rout['modulename']}_{name} ({sargs})") |
| 142 | if not signature: |
| 143 | add(f"use {rout['modulename']}, only : {fortranname}") |
no test coverage detected
searching dependent graphs…