diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 8c665cde3697aa21608b2a38b87206304ed2dab3..83cfaab2116cc81b1d558e012902d08671591714 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -2232,10 +2232,13 @@ class CodeGenerator(StructuredCodeGenerator): inst.component_id)),))) def emit_inst_Raise(self, inst): + # FIXME: Reenable emitting full error message + # TBD: Quoting of quotes, extra-long lines + if inst.error_message: + self.emit("! " + inst.error_message) + self.emit("write (dagrt_stderr,*) " - "'{condition}: {message}'".format( - condition=inst.error_condition.__name__, - message=inst.error_message)) + "'{condition}'".format(condition=inst.error_condition.__name__)) self.emit("stop") def emit_inst_FailStep(self, inst): diff --git a/dagrt/language.py b/dagrt/language.py index 484ad1776610d6eea1a7eef16b3e5dcff44f08a7..e2cede5a7f1a21cba245e0ef361a12f54e2616ff 100644 --- a/dagrt/language.py +++ b/dagrt/language.py @@ -891,17 +891,24 @@ class CodeBuilder(object): @contextmanager def if_(self, *condition_arg): """Create a new block that is conditionally executed.""" + from dagrt.expression import parse + if len(condition_arg) == 1: condition = condition_arg[0] - from dagrt.expression import parse - if isinstance(condition, str): condition = parse(condition) elif len(condition_arg) == 3: + lhs, cond, rhs = condition_arg + + if isinstance(lhs, str): + lhs = parse(lhs) + if isinstance(rhs, str): + rhs = parse(lhs) + from pymbolic.primitives import Comparison - condition = Comparison(*condition_arg) + condition = Comparison(lhs, cond, rhs) else: raise ValueError("Unrecognized condition expression") @@ -1153,9 +1160,9 @@ class CodeBuilder(object): self.fence() self._add_inst_to_context(ExitStep()) - def raise_(self, error): + def raise_(self, error_condition, error_message=None): self.fence() - self._add_inst_to_context(Raise(error)) + self._add_inst_to_context(Raise(error_condition, error_message)) def state_transition(self, next_state): self.fence()