problem with undefined yet defined variable

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


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!

ncl version 5.1.1

Here is the relevant part of the script (with some comments):

function ind_2array_1D (array1,array2,CE)
local d2,flag,i0,aout,tmp

; 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(.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
      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
        aout = array_append_record(tmp,i0,0)
          aout = i0
        end if
      end if
    end if


  end do



ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
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