problem with undefined yet defined variable

From: Melissa Bukovsky <bukovsky_at_nyahnyahspammersnyahnyah>
Date: Wed, 26 Aug 2009 12:08:20 -0600

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
Received on Wed Aug 26 2009 - 12:08:20 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 02 2009 - 12:24:39 MDT