On 09/09/2014 02:22 PM, Ian Hinder wrote:
On 9 Sep 2014, at 20:08, Roland Haas <[email protected]> wrote:
Hello all,
If I set
CoordBase::dx = 40/48
I get an error that dx should not be set to 0. I assume that Cactus
is doing an integer division because the operands of the division have no
fractional part. I think it should instead do a real division because
the parameter is real-valued. Is this desirable and/or possible?
I can work around the above problem by using
CoordBase::dx = 40.0/48
There was a bit of a discussion on this related to the new parfile
parser (piraha) here:
http://cactuscode.org/pipermail/users/2013-March/003352.html
There were ended up making things such that the type of the target
parameter does not play a role until the very end. I think the
pre-piraha parfile parser then had code that would evaluate 40/48 using
floating point arithmetic and CCTK_ERROR if the result of 40/48. was not
an integer to 15 digits or so. So that may be a middle ground. It would
mean that CoordBase::dx = 40/48 sets dx to 0.8333 but Driver::ncells =
40/48 aborts with an error. For the later one can use int(40/48) to get
truncation at the end.
I'd be happy having the target parameter type decide on what the parser
expects to find (so that eg string parameter values are never
interpreted as expressions and eg "a::name = 08/15" is allowed). :-)
I think it is confusing to set a real-valued parameter to 40/48 and have a
message which says zero is not valid. At the very least the error message
should be changed. Probably the error message should include the final value
of the parameter that is being used in the range check. Something equivalent
to (but with better wording):
"The parameter CoordBase::dx, entered as 40/48, evaluated to 0, which is not in the
range ..."
I understand that the intention is to be as close to C as possible, and maybe
we should do that for consistency. Note that not all Cactus users are C
programmers, and 40/48 == 0 is probably a common pitfall for newcomers to the
language.
The error message would be easy to fix and should be helpful.
Cheers,
Steve
_______________________________________________
Users mailing list
[email protected]
http://cactuscode.org/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://cactuscode.org/mailman/listinfo/users