(block, vars, args, tab='', as_interface=False)
| 3354 | |
| 3355 | |
| 3356 | def 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 |
no test coverage detected
searching dependent graphs…