MCPcopy Create free account
hub / github.com/numpy/numpy / vars2fortran

Function vars2fortran

numpy/f2py/crackfortran.py:3356–3478  ·  view source on GitHub ↗
(block, vars, args, tab='', as_interface=False)

Source from the content-addressed store, hash-verified

3354
3355
3356def vars2fortran(block, vars, args, tab='', as_interface=False):
3357 setmesstext(block)
3358 ret = ''
3359 nout = []
3360 for a in args:
3361 if a in block['vars']:
3362 nout.append(a)
3363 if 'commonvars' in block:
3364 for a in block['commonvars']:
3365 if a in vars:
3366 if a not in nout:
3367 nout.append(a)
3368 else:
3369 errmess(
3370 f'vars2fortran: Confused?!: "{a}" is not defined in vars.\n')
3371 if 'varnames' in block:
3372 nout.extend(block['varnames'])
3373 if not as_interface:
3374 for a in list(vars.keys()):
3375 if a not in nout:
3376 nout.append(a)
3377 for a in nout:
3378 if 'depend' in vars[a]:
3379 for d in vars[a]['depend']:
3380 if d in vars and 'depend' in vars[d] and a in vars[d]['depend']:
3381 errmess(
3382 f'vars2fortran: Warning: cross-dependence between variables "{a}" and "{d}\"\n')
3383 if 'externals' in block and a in block['externals']:
3384 if isintent_callback(vars[a]):
3385 ret = f'{ret}{tab}intent(callback) {a}'
3386 ret = f'{ret}{tab}external {a}'
3387 if isoptional(vars[a]):
3388 ret = f'{ret}{tab}optional {a}'
3389 if a in vars and 'typespec' not in vars[a]:
3390 continue
3391 cont = 1
3392 for b in block['body']:
3393 if a == b['name'] and b['block'] == 'function':
3394 cont = 0
3395 break
3396 if cont:
3397 continue
3398 if a not in vars:
3399 show(vars)
3400 outmess(f'vars2fortran: No definition for argument "{a}".\n')
3401 continue
3402 if a == block['name']:
3403 if block['block'] != 'function' or block.get('result'):
3404 # 1) skip declaring a variable that name matches with
3405 # subroutine name
3406 # 2) skip declaring function when its type is
3407 # declared via `result` construction
3408 continue
3409 if 'typespec' not in vars[a]:
3410 if 'attrspec' in vars[a] and 'external' in vars[a]['attrspec']:
3411 if a in args:
3412 ret = f'{ret}{tab}external {a}'
3413 continue

Callers 1

crack2fortrangenFunction · 0.85

Calls 9

setmesstextFunction · 0.85
errmessFunction · 0.85
isintent_callbackFunction · 0.85
isoptionalFunction · 0.85
true_intent_listFunction · 0.85
joinMethod · 0.80
outmessFunction · 0.70
keysMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…