-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathscrape_PASS_FTN.py
38 lines (35 loc) · 1.34 KB
/
scrape_PASS_FTN.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
A script to scrape all the function exports from the PASS_FTN.FOR
By Ian Bell, NIST, January 2018
"""
import os
from generate_header import generate_interface_file, generate_function_dict
if __name__=='__main__':
generate_interface_file('R:/FORTRAN/PASS_FTN.FOR','REFPROP.PYF',verbose=False,python_exe='python')
funcs = generate_function_dict('REFPROP.PYF')
for func in sorted(funcs):
print(' X(' + func + ') \\')
for func in sorted(funcs):
string_lengths = []
types = []
for arg in funcs[func]['argument_list']:
if len(arg) == 3:
name, _type, size = arg
else:
name, _type = arg
size = 0
if _type == 'double *' and size == 0:
types.append('DOUBLE_REF')
elif _type == 'double *' and size != 0:
types.append('double *')
elif _type == 'int *' and size == 0:
types.append('INT_REF')
elif _type == 'int *' and size != 0:
types.append('int *')
elif _type == 'char *':
types.append('char *')
string_lengths.append('RP_SIZE_T')
else:
print(types)
raise ValueError()
print(' '*4+'#define '+func+'_ARGS '+','.join(types+string_lengths))