From 7840f15af87fc2b070da6f49fd2ee5c0f247e78f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 20 Feb 2012 16:56:41 -0500 Subject: Use ThrowError instead of Throw --- Tools/CodeGen/CalculationFunction.m | 4 ++-- Tools/CodeGen/CodeGenCactus.m | 2 +- Tools/CodeGen/Differencing.m | 16 ++++++++-------- Tools/CodeGen/Jacobian.m | 4 ++-- Tools/CodeGen/TensorTools.m | 2 +- Tools/CodeGen/Thorn.m | 6 +++--- Tools/CodeGen/xTensorKranc.m | 11 ++--------- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index e7018bb..395bbb2 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -811,7 +811,7 @@ DefFn[ If[OptionValue[ProhibitAssignmentToGridFunctionsRead] && gfsInBoth =!= {}, - Throw["The calculation " <> ToString@lookup[cleancalc, Name] <> + ThrowError["The calculation " <> ToString@lookup[cleancalc, Name] <> " has the grid functions " <> ToString[gfsInBoth] <> " on both the left hand side and the right hand side. This is" <> " not allowed with the option" <> @@ -831,7 +831,7 @@ DefFn[ gfsDifferentiatedAndOnLHS = Intersection[gfsDifferentiated, gfsInLHS]; If[gfsDifferentiatedAndOnLHS =!= {}, - Throw["The calculation " <> ToString@lookup[cleancalc, Name] <> + ThrowError["The calculation " <> ToString@lookup[cleancalc, Name] <> " has both assignments to, and derivatives of, the grid functions " <> ToString[gfsDifferentiatedAndOnLHS] <> ". This is not allowed, as it gives results which are dependent" <> diff --git a/Tools/CodeGen/CodeGenCactus.m b/Tools/CodeGen/CodeGenCactus.m index ef7b317..f52d301 100644 --- a/Tools/CodeGen/CodeGenCactus.m +++ b/Tools/CodeGen/CodeGenCactus.m @@ -86,7 +86,7 @@ DefFn[ DefFn[ DataType[] := If[dataType === Symbol["datatype"], - Throw["DataType: Have not set a data type"], + ThrowError["DataType: Have not set a data type"], dataType]]; DefFn[ diff --git a/Tools/CodeGen/Differencing.m b/Tools/CodeGen/Differencing.m index ee7733e..637acc8 100644 --- a/Tools/CodeGen/Differencing.m +++ b/Tools/CodeGen/Differencing.m @@ -200,7 +200,7 @@ DefFn[ paramsInOps = Union@Flatten@Map[Cases[derivOps, #, Infinity] &, intParamNames]; If[Length[paramsInOps] > 1, - Throw["Cannot have more than one integer parameter in the list of partial derivative definitions"]]; + ThrowError["Cannot have more than one integer parameter in the list of partial derivative definitions"]]; If[paramsInOps === {}, Map[DerivativeOperatorVerify, derivOps]; @@ -261,7 +261,7 @@ DefFn[ CheckStencil[derivOps_, eqs_, name_, zeroDims_, intParams_] := Module[{psUsed, p}, psUsed = parametersUsedInOps[derivOps, intParams]; - If[Length[psUsed] > 1, Throw["Too many parameters in partial derivatives"]]; + If[Length[psUsed] > 1, ThrowError["Too many parameters in partial derivatives"]]; If[psUsed === {}, CheckStencil[derivOps,eqs,name,zeroDims], p = psUsed[[1]]; @@ -285,7 +285,7 @@ DefFn[ StencilSize[derivOps_, eqs_, name_, zeroDims_, intParams_] := Module[{psUsed, p}, psUsed = parametersUsedInOps[derivOps, intParams]; - If[Length[psUsed] > 1, Throw["Too many parameters in partial derivatives"]]; + If[Length[psUsed] > 1, ThrowError["Too many parameters in partial derivatives"]]; If[psUsed === {}, StencilSize[derivOps,eqs,name,zeroDims], p = psUsed[[1]]; @@ -514,7 +514,7 @@ DefFn[ result = Replace[result, _Symbol -> 1, {-1}]; If[!And@@Map[NumericQ, result], - Throw["Stencil width is not numeric in "<>ToString[componentDerivOp]]]; + ThrowError["Stencil width is not numeric in "<>ToString[componentDerivOp]]]; result]]; (* Farm out each term of a difference operator *) @@ -585,13 +585,13 @@ DefFn[ If[MatchQ[ips, List[ (_ ? NumberQ) ...]], Return[{name[indPatterns] -> expr/.zeroDimRules}]]; - Throw["DerivativeOperatorToComponents: Expecting indices which are symbolic patterns or numbers"]; + ThrowError["DerivativeOperatorToComponents: Expecting indices which are symbolic patterns or numbers"]; ]]; DerivativeOperatorVerify[derivOp_] := If[!MatchQ[derivOp, pd_[_Pattern ...] -> expr_?DerivativeOperatorRHSVerify] && !MatchQ[derivOp, pd_[_ ? NumberQ ...] -> expr_?DerivativeOperatorRHSVerify], - Throw["Derivative operator definition failed verification: ", ToString[derivOp]]]; + ThrowError["Derivative operator definition failed verification: ", ToString[derivOp]]]; DerivativeOperatorRHSVerify[expr_] := Module[{allAtoms, symbols}, @@ -730,10 +730,10 @@ expandDerivOpOverParameter[op_, intParam_] := expandDerivOpOverParameters[op_, intParams_] := Module[{usedParams}, - If[Head[op] =!= Rule, Throw["Invalid partial derivative",op]]; + If[Head[op] =!= Rule, ThrowError["Invalid partial derivative",op]]; usedParams = Select[intParams, Cases[op, getParamName[#], Infinity] =!= {} &]; If[Length[usedParams] > 1, - Throw["Partial derivatives can only depend on a single parameter"]]; + ThrowError["Partial derivatives can only depend on a single parameter"]]; If[usedParams === {}, {op}, expandDerivOpOverParameter[op, usedParams[[1]]]]]; diff --git a/Tools/CodeGen/Jacobian.m b/Tools/CodeGen/Jacobian.m index bd72845..e0fd979 100644 --- a/Tools/CodeGen/Jacobian.m +++ b/Tools/CodeGen/Jacobian.m @@ -79,7 +79,7 @@ insertDerivInEqs[deriv_, defs_, eqs_, shorthands_, zeroDims_] := lhss = Map[First, eqs]; positions = Map[Position[lhss, #, {1}, 1] &, shortsUsed]; MapThread[If[Length[#2] === 0, - Throw["Shorthand " <> ToString[#1] <> " used in derivative " <> ToString[deriv] <> + ThrowError["Shorthand " <> ToString[#1] <> " used in derivative " <> ToString[deriv] <> " but not defined in calculation"]] &, {shortsUsed, positions}]; positions2 = Map[#[[1,1]] &, positions]; position = If[Length[positions2] === 0, 1, Max[positions2]+1]; @@ -160,7 +160,7 @@ JacobianCheckGroups[groups_] := Module[{int}, int = Intersection[allGroupVariables[groups], allGroupVariables[JacobianGroups[]]]; If[int =!= {}, - Throw["Error: Some group variables conflict with reserved Jacobian variable names: " <> ToString[int]]]]; + ThrowError["Error: Some group variables conflict with reserved Jacobian variable names: " <> ToString[int]]]]; (* These gridfunctions are only given local variable copies if the use_jacobian variable is true *) JacobianConditionalGridFunctions[] := diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m index 48a848a..0e81fa6 100644 --- a/Tools/CodeGen/TensorTools.m +++ b/Tools/CodeGen/TensorTools.m @@ -562,7 +562,7 @@ makeSum[x_?nontensorialQ] := x; makeSum[x_] := - Throw["Expression " <> ToString[x] <> + ThrowError["Expression " <> ToString[x] <> " is not recognized, and tensor indices will not be expanded"]; sumComponentsOfDummyIndex[x_, i_] := diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index c44a062..2cd9122 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -425,7 +425,7 @@ scheduleFunction[spec_] := ConditionalOnParameter[parameter, value, u], If[condition != {}, - Throw["Unrecognized conditional structure", condition], + ThrowError["Unrecognized conditional structure", condition], u]]], u]; @@ -447,7 +447,7 @@ scheduleFunction[spec_] := ConditionalOnParameter[parameter, value, x], If[condition != {}, - Throw["Unrecognized conditional structure", condition], + ThrowError["Unrecognized conditional structure", condition], x]], x]], v, conditions], @@ -499,7 +499,7 @@ CreateSetterSource[calcs_, debug_, include_, Module[{calc = First[calcs],bodyFunction}, If[!MatchQ[include, _List], - Throw["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]]; + ThrowError["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]]; SetDataType[If[OptionValue[UseVectors],"CCTK_REAL_VEC", "CCTK_REAL"]]; diff --git a/Tools/CodeGen/xTensorKranc.m b/Tools/CodeGen/xTensorKranc.m index f92072f..84e6894 100644 --- a/Tools/CodeGen/xTensorKranc.m +++ b/Tools/CodeGen/xTensorKranc.m @@ -120,17 +120,10 @@ CreateGroupFromTensor[t_Symbol?xTensorQ[inds__]] := Module[{tCharString, nInds, Return[group] ]; -ReflectionSymmetries[x___]:= Throw["ReflectionSymmetries error: "<>ToString[x]]; -CreateGroupFromTensor[x___]:= Throw["CreateGroupFromTensor error: "<>ToString[x]]; +ReflectionSymmetries[x___]:= ThrowError["ReflectionSymmetries error: "<>ToString[x]]; +CreateGroupFromTensor[x___]:= ThrowError["CreateGroupFromTensor error: "<>ToString[x]]; CheckTensors[expr_] := Validate[expr]; End[]; EndPackage[]; - - - - - - - -- cgit v1.2.3