Re: problem with undefined yet defined variable

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri, 4 Sep 2009 14:01:13 -0600 (MDT)

Melissa and others,

Dave Brown fixed this problem. If you need the fix, please email me
separately with the following info:

    uname -a
    gcc --version (linux/macos/cygwin)

--Mary

On Wed, 26 Aug 2009, Melissa Bukovsky wrote:

> Hi,
>
> I'm getting the error message "fatal: Assign: aout is undefined" on the
> second call to a function I wrote. The first call works fine. The
> variable aout shouldn't be defined yet on the second call. I use isvar
> in the script and it says it is (and I've tried isdefined too), yet it
> makes it through that check and then the error occurs because aout
> really isn't defined yet. If I put a check right after the begin
> statement (commented out below) it makes it through the check on the
> second call to the function from the original script too, and the same
> error happens. I've never had this problem with multiple function calls
> before. Any help spotting what is wrong would be appreciated!
>
> Thanks,
> Melissa
> ncl version 5.1.1
>
> Here is the relevant part of the script (with some comments):
>
> undef("ind_2array_1D")
> function ind_2array_1D (array1,array2,CE)
> local d2,flag,i0,aout,tmp
>
> begin
> ; if(isvar("aout"))then
> ; delete(aout) ;this creates the same error on the
> second call too
> ; end if
>
> ;... non essential stuff here
>
> do i = 0,d2-1
> ;... non essential stuff here
>
> if(i.eq.0)then
> if(.not.all(ismissing(i0)))then ;if i0 is defined on the first
> loop, this isn't a problem (the function was working fine until I used a
> different data set where it is undefined on the first loop)
> aout = i0
> end if
> else
> if(isvar("aout"))then ;won't exist if missing so far
> tmp = aout ;*** this is where the error occurs if the
> above check isn't commented out
> delete(aout)
> aout = array_append_record(tmp,i0,0)
> delete(tmp)
> else
> if(.not.all(ismissing(i0)))then
> aout = i0
> end if
> end if
> end if
>
> delete(i0)
>
> end do
>
> return(aout)
>
> end
>
> _______________________________________________
> 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 Fri Sep 04 2009 - 14:01:13 MDT

This archive was generated by hypermail 2.2.0 : Tue Sep 08 2009 - 11:49:50 MDT