-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhreader.py
More file actions
121 lines (105 loc) · 3.44 KB
/
Copy pathhreader.py
File metadata and controls
121 lines (105 loc) · 3.44 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#def break_if(line):
import argparse
import varlibs as vl
def load_header(headf,real_list,int_list,char_list,bool_list):
"""load header file
"""
lines=[]
start=True
with open(headf,"r") as foldf:
line = 'x'
line0= ''
while line:
line = foldf.readline()
if "COMMON" in line:
# line1=vl.rm_arr_indexl(line0)
lines.append(line0)
break
if len(line.strip())==0 or vl.is_comment(line):
continue
if vl.is_continue(line):
line0=line0+line[6:].strip().upper()
else:
#new line
if line0:
# line1=vl.rm_arr_indexl(line0)
# print('line1')
# print(line1)
# print('line')
# print(line)
lines.append(line0)
# start=False
line0=line.rstrip().upper()
# print(len(lines))
if not lines:
lines.append(line0)
for line in lines:
# print(line)
head,stem=vl.hline_break(line)
slist=vl.decal_break(stem.strip())
nl=len(slist)
if 'CHARACTER' in head:
for jl in range(nl):
loc=ord(slist[jl][0].upper())-ord('A')
if slist[jl] not in char_list[loc]:
char_list[loc].append(slist[jl])
# vl.add_varlist(char_list,slist)
elif 'REAL' in head:
for jl in range(nl):
loc=ord(slist[jl][0].upper())-ord('A')
if slist[jl] not in real_list[loc]:
real_list[loc].append(slist[jl])
# vl.add_varlist(real_list,stem)
elif 'LOGICAL' in head:
for jl in range(nl):
loc=ord(slist[jl][0].upper())-ord('A')
if slist[jl] not in bool_list[loc]:
bool_list[loc].append(slist[jl])
# vl.add_varlist(bool_list,stem)
elif 'INTEGER' in head:
for jl in range(nl):
loc=ord(slist[jl][0].upper())-ord('A')
if slist[jl] not in int_list[loc]:
int_list[loc].append(slist[jl])
# vl.add_varlist(int_list,stem)
return real_list,int_list,char_list,bool_list
def load_heads(hflist):
"""
load variables from the list of header files in hflist
"""
real_list=[]
int_list=[]
char_list=[]
bool_list=[]
for j in range(26):
real_list.append([])
int_list.append([])
char_list.append([])
bool_list.append([])
#loop through the list of files
for hf in hflist:
real_list,int_list,char_list,bool_list=load_header(hf,
real_list,int_list,char_list,bool_list)
return real_list,int_list,char_list,bool_list
#parser = argparse.ArgumentParser(description=__doc__)
#parser.add_argument('--hfile_list', dest="fold", type=str, nargs=1, default=[""],
# help='the list of fortran 77 header files to read')
#args = parser.parse_args()
#f77f=args.fold[0]
#real_list,int_list,char_list,bool_list=load_heads(f77f)
#if len(real_list)>0:
# print('real:')
# for rl in real_list:
# print(rl)
#if len(char_list)>0:
# print('char')
# for rl in char_list:
# print(rl)
#if len(int_list)>0:
# print('int')
# for rl in int_list:
# print(rl)
#if len(bool_list)>0:
# print('bool')
# for rl in bool_list:
# print(rl)