NDDL parsing found to be locale dependent

27 views
Skip to first unread message

ZP

unread,
Jun 29, 2014, 11:32:36 AM6/29/14
to europa...@googlegroups.com
Hi,

I was trying to run a simple model from java (main class and model attached) and the float values were always being mangled by the parser (see the output in stdout.txt attached): floats were being truncated to their integer part but still considered by the europa engine as floats.
My locale was found to be:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=pt_PT.UTF-8;LC_TIME=pt_PT.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=pt_PT.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=pt_PT.UTF-8;LC_NAME=pt_PT.UTF-8;LC_ADDRESS=pt_PT.UTF-8;LC_TELEPHONE=pt_PT.UTF-8;LC_MEASUREMENT=pt_PT.UTF-8;LC_IDENTIFICATION=pt_PT.UTF-8

After I changed it globally to be en_US.UTF-8, the output of the program changed to be what was expected (floats parsed correctly). I tried using Java's "Locale.setDefault(Locale.US);" before creating the europa engine but this also did not seem to work.

I think it is an issue that the parsing of the language is locale dependent and hopefully will be taken care of for upcoming versions.

Best regards,
José Pinto
stdout.txt
Main.java
auv_model.nddl

Michael J Iatauro

unread,
Jun 30, 2014, 3:20:48 PM6/30/14
to europa...@googlegroups.com
Good catch, Jose! As you say, this is a result of the way that Europa converts the text
of a float to a double, which actually doesn't have its interaction with locale specified,
so not only the locale, but the platform could change the behavior.*

I imagine the Locale.setDefault(Locale.US) didn't change things because it sets the locale
for the JVM, but not for the whole process, so the C++ side of Europa doesn't see any
change. There may be some way in Java to set it process-wide; I don't know. You've
already worked around it by setting the environment variable.

~MJI

*For curious parties: pt_PT.UTF-8 is the Portuguese(Portugal) locale, which uses '.' as a
grouping separator and ',' as a radix separator. atof is rejecting everything after the
'.' since it's expecting a radix rather than a grouping separator. However, the spec
doesn't require or forbid atof to be locale-aware, so some implementations might parse
this just fine under pt_PT.UTF-8, but Jose's clearly doesn't.
> -- You received this message because you are subscribed to the Google Groups
> "europa-users" group. To unsubscribe from this group and stop receiving emails from it,
> send an email to europa-users...@googlegroups.com
> <mailto:europa-users...@googlegroups.com>. To post to this group, send email
> to europa...@googlegroups.com <mailto:europa...@googlegroups.com>. Visit this
> group at http://groups.google.com/group/europa-users. For more options, visit
> https://groups.google.com/d/optout.


--
------------------
Michael J. Iatauro
Software Engineer
QTS, Inc.

NASA Ames Research Center
Office: 650-604-0662
Mail stop: 269-2
P.O. Box 1
Moffett Field, CA 94035-0001
Reply all
Reply to author
Forward
0 new messages