LANDIS-II-Foundation/Core-Model-v6

LANDIS Core needs decimal separator check

Closed this issue · 1 comments

Reported by AMGdeBruijn, Jun 17, 2014
What steps will reproduce the problem?

  1. Try run LANDIS on a European computer that uses ',' as a decimal seperator

What is the expected output? What do you see instead?

Expected:
Model error: The decimal separator of your system is ',' expecting '.'

Instead:
Error with the input value for Vegetative Reprod Prob:
0.5 is not between 0 and 1.0

Please use labels and text to provide additional information.

Suggested fix: add following code somewhere in the initialization of the core:


string decimal_seperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
if (decimal_seperator != ".")
{
throw new System.Exception("The decimal separator of your system is " + decimal_seperator + " , expecting '.'");
}
Nov 7, 2014 Delete comment Project Member #1 lbross@pdx.edu
The suggested fix would prevent the model from initializing on computers that don't use '.' for a decimal separator. Might a warning message be more appropriate?
Cc: rmscheller lbross@pdx.edu
Nov 7, 2014 Delete comment #2 AMGdeBruijn
It is a futile difference, you cannot run a simulation on a computer with an alternative separator anyhow.

Such warning would still be followed by the same error; "0.5 is not between 0 and 1.0" (or whatever non-int the model first encounters.)

Nov 13, 2014 Project Member #3 lbross@pdx.edu
I tested a simple BaseHarvest simulation after setting my computer to use French number formatting. The simulation will run if you edit the configuration files to use the same number format that the computer is running.

Thus, I wonder if it would be helpful to add a warning message in the initialization like,"WARNING: Your computer is using a decimal separator other than '.'. Most LANDIS-II configuration files are formatted using '.' for the decimal separator. You need to either change the number format of your computer or edit the configuration files for LANDIS-II to run successfully."

This is wordy, but explains the problem better than the validation exceptions that are currently thrown.

Nov 20, 2014 Project Member #4 lbross@pdx.edu
Rob concurred that a warning should be added in the initialization of the core. This will not prevent European users from using LANDIS-II and it is a more straightforward error than the input validation error pointed out by Arjan. This change will be included in the Landis 6.1 release.

Implemented in 6.1