Re: What is wrong with this "ind" loop for a 2D array?

From: Brian Medeiros <brianpm_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 26 2012 - 16:02:23 MDT

Shawn,

I would bet that fog never equals 1, so the ind function returns "missing"

Maybe try
if .not. all(ismissing(ii)) then
  FOG = fog( ind(.not.ismissing(ii)), ind(.not.ismissing(jj)) ) ;; no reason to use ii and jj if they are the same.
else
  FOG = -9999 ;; or appropriate missing value
end if

.brian

On Sep 26, 2012, at 3:54 PM, Wen.J.Qu <wen.j.qu@gmail.com> wrote:

> Hi, dear NCL users,
>
> Would you please give me some hint of what is wrong with the "ind" loop for a 2D array as shown below?
>
> Thanks a lot.
>
> Shawn
>
>
> ################################################################
>
> When I run it, it shows:
> fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading fog
> fatal:Execute: Error occurred at or near line "FOG = fog(ii,jj)" in the file
>
> ################################################################
>
> ;--fog is a nrows*ncols 2D array.
> ;--Get indices where fog value is 1, that is fog happens.
> ii = new(nrows,integer)
> jj = new(ncols,integer)
> do i=0,nrows-1
> do j=0,ncols-1
> ii(i) = ind(fog(i,j).eq.1)
> jj(j) = ind(fog(i,j).eq.1)
> end do
> end do
>
> FOG = fog(ii,jj)
> ;Debug print
> print(FOG)
> #################################################################
>
>
> Wen.J.Qu
> 2012-09-26
> _______________________________________________
> 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 Thu Sep 27 00:02:21 2012

This archive was generated by hypermail 2.1.8 : Tue Oct 02 2012 - 13:38:41 MDT