From 64517e8b0da9f7083fed286849f0b25a67ae320a Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sun, 1 Apr 2012 19:03:56 -0400
Subject: [PATCH] F2CL: Emit 0.234 instead of .234.

---
 contrib/fortran-to-opencl/translate.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/contrib/fortran-to-opencl/translate.py b/contrib/fortran-to-opencl/translate.py
index a9dd33fd..c1c72c69 100644
--- a/contrib/fortran-to-opencl/translate.py
+++ b/contrib/fortran-to-opencl/translate.py
@@ -127,7 +127,16 @@ class FortranExpressionParser(ExpressionParserBase):
             else:
                 dtype = np.float32
 
-            return TypedLiteral(value.replace("d", "e"), dtype)
+            value = value.replace("d", "e")
+            if value.startswith("."):
+                prev_value = value
+                value = "0"+value
+                print value, prev_value
+            elif value.startswith("-."):
+                prev_value = value
+                value = "-0"+value[1:]
+                print value, prev_value
+            return TypedLiteral(value, dtype)
 
         elif next_tag is _identifier:
             name = pstate.next_str_and_advance()
@@ -1121,9 +1130,6 @@ class F2CLTranslator(FTreeWalkerBase):
             from pymbolic import var
             rhs = var("fromreal")(rhs)
 
-        if lhs_name == "cd":
-            print lhs_dtype, rhs_dtype, rhs
-
         return cgen.Assign(self.gen_expr(lhs), self.gen_expr(rhs))
 
     def map_Allocate(self, node):
-- 
GitLab