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

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 26 2012 - 17:00:58 MDT

Reading the documentation helps.
For example 'ind' Example 4
which uses 'ndtooned' and 'onedtooned'

allows a in to be indirectly used on a 2D array.

On 9/26/12 4:57 PM, Wen.J.Qu wrote:
> Thanks, Dennis
> I <mailto:ncl-talk@ucar.edu> learn something through making mistakes :)
> I will try other way to do that.
> Thank you so much.
> Shawn
> ------------------------------------------------------------------------
> Wen.J.Qu
> 2012-09-26
> ------------------------------------------------------------------------
> *发件人:* Dennis Shea
> *发送时间:* 2012-09-26 17:50:54
> *收件人:* Wen.J.Qu@gmail.com
> *抄送:* Brian Medeiros; ncl-talk
> *主题:* Re: [ncl-talk] What is wrong with this "ind" loop for a 2D array?
> 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-talk
Received on Thu Sep 27 01:01:06 2012

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