#1958: parfiles accept 1.0, 0.0, 1e3 for integer typed parameters ----------------------+----------------------------------------------------- Reporter: rhaas | Owner: Type: defect | Status: new Priority: optional | Milestone: Component: Cactus | Version: development version Keywords: | ----------------------+----------------------------------------------------- Currently I can put {{{ Cactus::cctk_itlast = 1.0e3 }}} into a parameter file and Cactus will accept this parfile ({{{cctk_itlast = 0.5}}} fails).
My feeling would that it is better only allow "[-+]?[0-9]+" for integers and not accept everything and then check afterwards if it could be converted to an integer without loss of accuracy.
This probably changed when the parfile gained the ability to evaluate expressions (both using piraha and before). Mostly I am concerned that accepting floating point numbers that have integer values can mask errors in parfile generating scripts (eg I have one that apparently sets Llama's n_angular to 24.0) and which will crop up when the input to the parfile generator changes a bit.
Maybe the simplest way to achieve this is, is to test like this: {{{ char valuestring[]; char *endp; long int intval = strtol(valuestring, &endptr, 10); if(*endptr && (strdod(valuestring, &endptr), !*endptr)) { CCTK_VERROR("Float given for int parameter"); } }}} which tests if the parameter cannot be converted to an integer but can be converted to a floating-point number. I believe there is already a similar test in the parfile code to check if valuestring is a constant or an expression.