Re: Missing value problem

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 20 2012 - 11:09:07 MDT

Hi Cecille,

The issue is that one of your values is missing, and you can't execute "if" statements on missing data directly.

You can see this by running NCL interactively and typing these commands:

x = new(1,float)
print(ismissing(x))
 if(x.le.1) then
  print("x is < 1")
end if

The "print(ismissing(x))") command will print:

(0) True

and then the "if" statement will produce:

fatal:The result of the conditional expression yields a missing value. NCL can not determine branch, see ismissing function
fatal:["Execute.c":7554]:Execute: Error occurred at or near line 4

To fix the issue, you should use an "if" statement like this:

   if (.not.ismissing(dep(i,k,m,n)).and.dep(i,k,m,n) .ne. 0.) then

As a side: you want to avoid "do" loops in NCL where possible. They can be time-consuming.
Try to use the array syntax and the handy "where" and "dim_xxx_n" functions to get rid of do loops.

For example, instead of:

  do i=0, num_times-1
    do k=0, num_vert-1
      do n=0, num_horiz-1
        do m=0, num_horiz-1
          sumpre(i,k) = sumpre(i,k) + pre(i,k,m,n)

You can do something like:

  sumpre = dim_sum_n(pre,(/2,3/))

This will sum up all the values for the 2 rightmost dimensions for each of the 2 leftmost dimensions.

And, if I have my logic correct, you can replace:

> 256 if (cond(i,k,m,n) .ne. 0.) then
> 257 co(i,k) = co(i,k) + 1.
> 258 end if

with something like (with no do loops):

  co = co + dim_num_n(cond.ne.0,(/2,3/))

You should check that carefully, though, because I don't know what the rest of your script looks like, and this code may not be appropriate.

--Mary

On Jun 19, 2012, at 4:36 PM, Cecille Villanueva-Birriel wrote:

>
> Hello NCL-talk
>
> I am trying to do domain average calculations for WRF variables, but when running the script I get the following error.
>
> fatal:The result of the conditional expression yields a missing value. NCL can not determine branch, see ismissing function
> fatal:Execute: Error occurred at or near line 267 in file Rates_avg_cecille.ncl
>
> I don't know exactly why is giving me this error. The part of the script that it refers is the following.
>
> 239 do i=0, num_times-1
> 240 do k=0, num_vert-1
> 241 do n=0, num_horiz-1
> 242 do m=0, num_horiz-1
> 243 sumpre(i,k) = sumpre(i,k) + pre(i,k,m,n)
> 244 sumcond(i,k) = sumcond(i,k) + cond(i,k,m,n)
> 245 sumevap(i,k) = sumevap(i,k) + evap(i,k,m,n)
> 246 sumsub(i,k) = sumsub(i,k) + sub(i,k,m,n)
> 247 sumdep(i,k) = sumdep(i,k) + dep(i,k,m,n)
> 248 sumaut(i,k) = sumaut(i,k) + aut(i,k,m,n)
> 249 sumacc(i,k) = sumacc(i,k) + acc(i,k,m,n)
> 250 summelt(i,k) = summelt(i,k) + melt(i,k,m,n)
> 251 sumrr(i,k) = sumrr(i,k) + rr(i,k,m,n)
> 252
> 253 if (pre(i,k,m,n) .ne. 0.) then
> 254 pr(i,k) = pr(i,k) + 1.
> 255 end if
> 256 if (cond(i,k,m,n) .ne. 0.) then
> 257 co(i,k) = co(i,k) + 1.
> 258 end if
> 259 if (evap(i,k,m,n) .ne. 0.) then
> 260 ev(i,k) = ev(i,k) + 1.
> 261 end if
> 262 if (sub(i,k,m,n) .ne. 0.) then
> 263 su(i,k) = su(i,k) + 1.
> 264 end if
> 265 if (dep(i,k,m,n) .ne. 0.) then
> 266 de(i,k) = de(i,k) + 1.
> 267 end if
> 268 if (aut(i,k,m,n) .ne. 0.) then
> 269 au(i,k) = au(i,k) + 1.
> 270 end if
> 271 if (acc(i,k,m,n) .ne. 0.) then
> 272 ac(i,k) = ac(i,k) + 1.
> 273 end if
> 274 if (melt(i,k,m,n) .ne. 0.) then
> 275 me(i,k) = me(i,k) + 1.
> 276 end if
> 277 if (rr(i,k,m,n) .ne. 0.) then
> 278 ra(i,k) = me(i,k) + 1.
> 279 end if
> 280 end do
> 281 end do
>
> Has anybody had this error and solved it?
>
> Thanks,
> Cecille
>
>
>
>
>> ********************************************************
>> Cecille M. Villanueva Birriel
>> Ph.D. Candidate
>> Cloud Microphysics Research Group
>> Purdue University
>> Department of Earth and Atmospheric Sciences
>> 550 Stadium Mall Drive, West Lafayette, IN 47907-2051
>> email: cvillanu@purdue.edu
>> ********************************************************
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 20 11:09:19 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT