[ncl-talk] In condtnl_expr missing .and. false results depend on the order

Qi Tang tang30 at llnl.gov
Thu Oct 1 17:54:34 MDT 2015


Hi,

It seems that in the condtnl_expr, the value of missing .and. false give 
the value of the first term:

missing .and. false -> missing
false .and. missing -> false

Is this a bug? The results to both expressions above should be missing. 
Otherwise, it makes it really easy to make mistakes when using the where 
function when there can be missing in the condtnl_expr.

A short example below demonstrates this problem. I am using v6.2.1 on 
Redhat 6.7.

Qi

==========
   x = new(5,float,-99.)
   y = new(5,float,-99.)
   x(0) = 1.
   x(2) = 3.
   x(4) = 4.
   y(0) = 1.
   y(1) = 3.2
   print(x)
   print(y)

   a = x
   b = y
   c = y

   a = where(x.lt.2. .and. y.lt.2., a at _FillValue, a)
   b = where(x.lt.2. .and. y.lt.2., b at _FillValue, b)
   c = where(y.lt.2. .and. x.lt.2., c at _FillValue, c)
   print(a)
   print(b)
   print(c)
========

The arrays a, b, c should be identical, but they are not. The output is:

Variable: x
Type: float
Total Size: 20 bytes
             5 values
Number of Dimensions: 1
Dimensions and sizes:    [5]
Coordinates:
Number Of Attributes: 1
   _FillValue :    -99
(0)     1
(1)    -99
(2)     3
(3)    -99
(4)     4

Variable: y
Type: float
Total Size: 20 bytes
             5 values
Number of Dimensions: 1
Dimensions and sizes:    [5]
Coordinates:
Number Of Attributes: 1
   _FillValue :    -99
(0)     1
(1)    3.2
(2)    -99
(3)    -99
(4)    -99

Variable: a
Type: float
Total Size: 20 bytes
             5 values
Number of Dimensions: 1
Dimensions and sizes:    [5]
Coordinates:
Number Of Attributes: 1
   _FillValue :    -99
(0)    -99
(1)    -99
(2)     3
(3)    -99
(4)     4

Variable: b
Type: float
Total Size: 20 bytes
             5 values
Number of Dimensions: 1
Dimensions and sizes:    [5]
Coordinates:
Number Of Attributes: 1
   _FillValue :    -99
(0)    -99
(1)    -99
(2)    -99
(3)    -99
(4)    -99

Variable: c
Type: float
Total Size: 20 bytes
             5 values
Number of Dimensions: 1
Dimensions and sizes:    [5]
Coordinates:
Number Of Attributes: 1
   _FillValue :    -99
(0)    -99
(1)    3.2
(2)    -99
(3)    -99
(4)    -99




More information about the ncl-talk mailing list