On 9/26/12 4:35 PM, Wen.J.Qu wrote:
> Thanks, Brian
> I tried it, but it still does not work. Same error shows
> fatal:Subscript out of range, error in subscript #1
> fatal:An error occurred reading fog
> I am wondering if the "ind" function only can be used with 1D array.
--- function ind ( larray [*] : logical ) The [*] mean a 1D array --- > Thanks a lot. > Shawn > ------------------------------------------------------------------------ > Wen.J.Qu > 2012-09-26 > ------------------------------------------------------------------------ > *发件人:* Brian Medeiros > *发送时间:* 2012-09-26 17:02:11 > *收件人:* Wen.J.Qu@gmail.com > *抄送:* ncl-talk > *主题:* Re: [ncl-talk] What is wrong with this "ind" loop for a 2D array? > 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 > <mailto: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 > _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Thu Sep 27 00:51:01 2012
This archive was generated by hypermail 2.1.8 : Tue Oct 02 2012 - 13:38:41 MDT