NCL tips and quirks - need your input

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 16 May 2007 16:08:29 -0600 (MDT)

Hi all,

We're going to start an NCL "tips and quirks" page (maybe we'll
separate them eventually), and I've got a one I will share here before
putting it on a website. If you have any you think should be
included, feel free to share them with the group, or email them to me
directly.

[Thanks to Bjorn Stevens and his colleagues for bringing this one to
our attention.]

Oddity with how NCL treats the negation/minus ('-') operator
------------------------------------------------------------

    The minus operator has the highest precedence, which means it will
    get applied in an expression first, and, in some cases, in a way
    you might not expect. For example, the expression:

       x = - 3^2

    will yield a value of 9, because it is equivalent to:

       x = (-3)^2

    This is unlike Fortran, in which:

       x = - 3**2

    gives you a value of -9.

    However, in NCL, if "-" appears between two numbers or variables,
    then it is treated as "minus" rather than "negation". Hence, the
    following:

       x = 0 - 3^2

     will give you a value of -9.

For more on this topic, please see:

http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclExpressions.shtml#TypesOfExpressions

--Mary
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed May 16 2007 - 16:08:29 MDT

This archive was generated by hypermail 2.2.0 : Thu May 17 2007 - 11:10:44 MDT