(block, tab='\n', as_interface=False)
| 3268 | |
| 3269 | |
| 3270 | def crack2fortrangen(block, tab='\n', as_interface=False): |
| 3271 | global skipfuncs, onlyfuncs |
| 3272 | |
| 3273 | setmesstext(block) |
| 3274 | ret = '' |
| 3275 | if isinstance(block, list): |
| 3276 | for g in block: |
| 3277 | if g and g['block'] in ['function', 'subroutine']: |
| 3278 | if g['name'] in skipfuncs: |
| 3279 | continue |
| 3280 | if onlyfuncs and g['name'] not in onlyfuncs: |
| 3281 | continue |
| 3282 | ret = ret + crack2fortrangen(g, tab, as_interface=as_interface) |
| 3283 | return ret |
| 3284 | prefix = '' |
| 3285 | name = '' |
| 3286 | args = '' |
| 3287 | blocktype = block['block'] |
| 3288 | if blocktype == 'program': |
| 3289 | return '' |
| 3290 | argsl = [] |
| 3291 | if 'name' in block: |
| 3292 | name = block['name'] |
| 3293 | if 'args' in block: |
| 3294 | vars = block['vars'] |
| 3295 | for a in block['args']: |
| 3296 | a = expr2name(a, block, argsl) |
| 3297 | if not isintent_callback(vars[a]): |
| 3298 | argsl.append(a) |
| 3299 | if block['block'] == 'function' or argsl: |
| 3300 | args = '(%s)' % ','.join(argsl) |
| 3301 | f2pyenhancements = '' |
| 3302 | if 'f2pyenhancements' in block: |
| 3303 | for k in list(block['f2pyenhancements'].keys()): |
| 3304 | f2pyenhancements = '%s%s%s %s' % ( |
| 3305 | f2pyenhancements, tab + tabchar, k, block['f2pyenhancements'][k]) |
| 3306 | intent_lst = block.get('intent', [])[:] |
| 3307 | if blocktype == 'function' and 'callback' in intent_lst: |
| 3308 | intent_lst.remove('callback') |
| 3309 | if intent_lst: |
| 3310 | f2pyenhancements = '%s%sintent(%s) %s' %\ |
| 3311 | (f2pyenhancements, tab + tabchar, |
| 3312 | ','.join(intent_lst), name) |
| 3313 | use = '' |
| 3314 | if 'use' in block: |
| 3315 | use = use2fortran(block['use'], tab + tabchar) |
| 3316 | common = '' |
| 3317 | if 'common' in block: |
| 3318 | common = common2fortran(block['common'], tab + tabchar) |
| 3319 | if name == 'unknown_interface': |
| 3320 | name = '' |
| 3321 | result = '' |
| 3322 | if 'result' in block: |
| 3323 | result = ' result (%s)' % block['result'] |
| 3324 | if block['result'] not in argsl: |
| 3325 | argsl.append(block['result']) |
| 3326 | body = crack2fortrangen(block['body'], tab + tabchar, as_interface=as_interface) |
| 3327 | vars = vars2fortran( |
no test coverage detected