[ncl-talk] Minor problem when parsing an expression with double constants

Gus Correa gus at ldeo.columbia.edu
Wed May 3 12:54:18 MDT 2017


Hi Mary

As far as I can tell it works for the other type literal suffixes.
[I hope I checked them all ... not sure ...]
The problem may be only with double (d or D).

Best,
Gus

On 05/03/2017 02:10 PM, Mary Haley wrote:
> Hi Gus,
>
> You are right, this doesn't work! I'm surprised somebody didn't run into
> this before.
>
> I've created a ticket for this (NCL-2604) and hopefully we can get a fix
> in for 6.4.1.
>
> --Mary
>
>
>
>
> On Wed, May 3, 2017 at 10:58 AM, Gus Correa <gus at ldeo.columbia.edu
> <mailto:gus at ldeo.columbia.edu>> wrote:
>
>     Dear NCL Pros
>
>     I have noticed a minor problem when using constants of double
>     type in an arithmetic expression.
>     When I separate the tokens with spaces,
>     NCL parses the expression properly, and gives the correct result.
>     When I write the expresion tightly, without spaces, I get
>     a syntax error.
>
>     Am I doing something wrong, or does the parser really expect
>     spaces between the tokens?
>
>     Of course I can continue to write the expressions with spaces,
>     but the problem may propagate to, say, automatically
>     generated NCL code, etc.
>
>     I enclose a simple example below.
>     As you can see, I am using NCL 6.4.0,
>     pre-compiled with gcc on CentOS, and downloaded from ESG.
>
>     Thank you,
>     Gus Correa
>
>     *** syntax error in arithmetic expression with constant doubles ***
>
>     [gus at master ~]$ ncl
>       Copyright (C) 1995-2017 - All Rights Reserved
>       University Corporation for Atmospheric Research
>       NCAR Command Language Version 6.4.0
>       The use of this software is governed by a License Agreement.
>       See http://www.ncl.ucar.edu/ for more details.
>     ncl 0> a=3.2d + 4.5d
>     ncl 1> print("a="+sprintf("%g",a))
>     (0)     a=7.7
>     ncl 2> delete(a)
>     ncl 3> a=3.2d+4.5d
>     fatal:syntax error: line 3 before or near .5d
>     a=3.2d+4.5d
>     ----------^
>
>     ncl 4> b=3.2d+4.5d
>     fatal:syntax error: line 4 before or near .5d
>     b=3.2d+4.5d
>     ----------^
>
>     ncl 5> b=3.2d +4.5d
>     ncl 6> print("b="+sprintf("%g",b))
>     (0)     b=7.7
>
>
>     [Note that the "d" (for double) needs a space after it, and before the
>     next token. Maybe that is the behavior one should expect,
>     but I was surprised.]
>
>     **********************************************************************
>     _______________________________________________
>     ncl-talk mailing list
>     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>     List instructions, subscriber options, unsubscribe:
>     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>



More information about the ncl-talk mailing list