[ncl-talk] Wondering why I am getting this dimensions error
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Wed Nov 27 10:40:23 MST 2019
"sum_q = 1." defines this variable as scalar. Then the where statement
attempts to write a 2-D array onto a scalar. The assignment statement is
not allowed to change dimensions.
One way to fix this would be to use the reassignment operator ":=", which
IS allowed to change dimensions on assignment.
Another way to fix this would be to define sum_q as a 2-D array before the
start of the loop. I suspect that is what you really intended.
On Wed, Nov 27, 2019 at 10:22 AM Barry Lynn via ncl-talk <ncl-talk at ucar.edu>
wrote:
> Hi:
>
> I have some simple code.
>
> do k = 0,dims3d(0)-1
>
> qs(k,:,:) = where(qs(k,:,:).lt.0.1,q_null(k,:,:),qs(k,:,:))
>
> sum_q = 1.
>
> sum_q = where(qs(k,:,:).ge.0.1,sum_q+1,sum_q)
>
> qs_1(k) = sum(qs(k,:,:))/sum_q+qs_1(k)
>
> end do
>
>
> Why can't I do the "where" sum?
>
>
> fatal:Number of dimensions on right hand side do not match number of
> dimension in left hand side
>
> --
> Barry H. Lynn, Ph.D
> Senior Associate Scientist, Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191127/a4d35002/attachment.html>
More information about the ncl-talk
mailing list