@@ -436,12 +436,12 @@ def double_to_quad(lines,initial,newinit,prefix,procedure_name=None):
436
436
initial = sing_prefixes [i ]
437
437
newinit = dble_prefixes [i ]
438
438
whole = re .sub (prefix [:- 1 ]+ r'\_' + initial ,prefix + newinit ,whole )
439
- # whole = re.sub(r'\_'+initial,r'_'+newinit,whole)
440
-
441
- if initial == 's' :
442
- whole = re .sub (prefix [:- 1 ]+ r'\_delctg' ,prefix + r'selctg' ,whole )
443
- whole = re .sub (prefix [:- 1 ]+ r'\_delect' ,prefix + r'select' ,whole )
444
439
440
+ whole = re .sub (prefix [:- 1 ]+ r'\_delctg' ,prefix + r'selctg' ,whole )
441
+ whole = re .sub (prefix [:- 1 ]+ r'\_delect' ,prefix + r'select' ,whole )
442
+ whole = re .sub (prefix [:- 1 ]+ r'\_dlag2d' ,prefix + r'dlag2q' ,whole )
443
+ whole = re .sub (prefix [:- 1 ]+ r'\_zlag2z' ,prefix + r'zlag2w' ,whole )
444
+ whole = re .sub (prefix [:- 1 ]+ r'\_zlag2w' ,prefix + r'clag2z' ,whole )
445
445
446
446
whole = re .sub (r'32\-bit' ,r'64-bit' ,whole )
447
447
whole = re .sub (r'single precision' ,r'double precision' ,whole )
@@ -1147,6 +1147,7 @@ def write_function_body(fid,body,INDENT,MAX_LINE_LENGTH,adjust_comments):
1147
1147
fid .write ("\n " )
1148
1148
1149
1149
header = True
1150
+ previous = []
1150
1151
1151
1152
for i in range (len (body )):
1152
1153
line = body [i ]
@@ -1192,6 +1193,8 @@ def write_function_body(fid,body,INDENT,MAX_LINE_LENGTH,adjust_comments):
1192
1193
if not is_comment_line :
1193
1194
line = re .sub (r"([\"'])((?=(\\?))\3.)*?\1" , upper_repl , line )
1194
1195
1196
+ line = align_labelled_continue (line ,previous )
1197
+
1195
1198
if is_directive :
1196
1199
fid .write (line + "\n " )
1197
1200
elif bool (re .match (r'^\s*!\s*$' ,line )):
@@ -1200,6 +1203,9 @@ def write_function_body(fid,body,INDENT,MAX_LINE_LENGTH,adjust_comments):
1200
1203
else :
1201
1204
write_with_continuation (line ,fid ,INDENT ,MAX_LINE_LENGTH )
1202
1205
1206
+ # Save for the next one
1207
+ previous = line
1208
+
1203
1209
1204
1210
1205
1211
# Write with continuation
@@ -1472,20 +1478,35 @@ def to_quad_precision(self):
1472
1478
print ("function " + self .old_name + " cannot be converted to quadruple precision: it must be double" )
1473
1479
exit (1 )
1474
1480
1475
- q .old_name = newi + self .old_name [len (initial ):]
1476
1481
1477
1482
# Extract prefix
1478
1483
i = self .new_name .index (self .old_name )
1479
- prefix = self .new_name [:i ]
1484
+ prefix = self .new_name [:i ]
1485
+
1486
+
1487
+ # Patch for names that change more than just the initial
1488
+ if self .old_name == 'slag2d' :
1489
+ q .old_name = 'dlag2q'
1490
+ else :
1491
+ q .old_name = newi + self .old_name [len (initial ):]
1480
1492
q .new_name = prefix + q .old_name
1481
1493
1482
- # print("double->quad "+q.old_name+" "+q.new_name)
1494
+ print ("double->quad " + q .old_name + " " + q .new_name )
1483
1495
1484
1496
# Body, header
1485
1497
q .header = double_to_quad (q .header ,initial ,newi ,prefix ,[self .old_name ,q .old_name ])
1486
1498
q .body = double_to_quad (q .body ,initial ,newi ,prefix )
1487
1499
q .decl = double_to_quad (q .decl ,initial ,newi ,prefix )
1488
1500
1501
+ if (self .old_name == 'slag2d' ):
1502
+ print ("self old " + self .old_name )
1503
+ print ("q old" + q .old_name )
1504
+ print ("self new " + self .new_name )
1505
+ print ("q new" + q .new_name )
1506
+ print ("self line 1 " + self .body [0 ])
1507
+ print ("q line 1 " + q .body [0 ])
1508
+ #exit(1)
1509
+
1489
1510
# Parameters: we only rename type and value
1490
1511
q .ptype = double_to_quad (q .ptype ,initial ,newi ,prefix )
1491
1512
q .pvalue = double_to_quad (q .pvalue ,initial ,newi ,prefix )
@@ -1540,6 +1561,10 @@ def is_pure(self):
1540
1561
1541
1562
DEBUG = False # self.old_name=='sisnan'
1542
1563
1564
+ # Patch
1565
+ if self .old_name == 'dnrm2' or self .old_name == 'znrm2' or self .old_name == 'qznrm2' \
1566
+ or self .old_name == 'qnrm2' : return True
1567
+
1543
1568
io = 'stop' in self .body or \
1544
1569
'write' in self .body or \
1545
1570
self .save_stmt ;
@@ -2174,6 +2199,10 @@ def align_labelled_continue(line,previous=None):
2174
2199
2175
2200
nspaces = len (previous )- len (previous .lstrip ())
2176
2201
2202
+ print ("CONTINUE: # spaces = " + str (nspaces ))
2203
+ print ("CONTINUE: prev line = " + previous )
2204
+ print ("CONTINUE: = " + " " * nspaces + label + " continue" )
2205
+
2177
2206
return " " * nspaces + label + " continue"
2178
2207
2179
2208
# Given the list of all variables, extract those that are module constants
0 commit comments