Re: Using file as as argument to function

From: gibies george <gibies_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 23 2011 - 00:06:09 MST

Thank you Dennis,

I have modified the function definition as follows :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;Function definition
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
undef ("get_coordvar")
function get_coordvar(file1:list,coord:string,size:integer)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; if(.not.iscoord(data,dims(0)))
;;; data&$dims(0)$ = get_coordvar(file1,dims(0),dimsize(0))
;;; end if
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
local coordvarname, coordvar

begin
  print("Enter the file-variable representing "+coord+" : ")
  coordvarname = systemfunc("read var; echo $var")
    if (isfilevar(file1[0], coordvarname))
coordvar = file1[:]->$coordvarname$
size1 = dimsizes (coordvar)
if (size .ne. size1)
coordvar=ispan(0,size-1,1)
end if
    else
coordvar=ispan(0,size-1,1)
    end if
print(coordvar)
  return (coordvar)
end ;;; End of function definition get_coordvar() ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Now it is working fine.

Thank you very much.

On 22 February 2011 20:00, Dennis Shea <shea@ucar.edu> wrote:

> The function
>
> function get_coordvar(file1:file,coord:string,size:integer)
>
> has "file1" prototyped as type 'file'
>
> Your useage
> coordvar = file1[:]->$coordvarname$
> uses the '[:]' which is only available for variables of type 'list'
>
> Change tp
>
> coordvar = file1->$coordvarname$
>
>
> On 2/22/11 6:06 AM, gibies george wrote:
>
>> Can anybody tell me the reason for the following error message.
>>
>>
>> fatal:Argument type mismatch on argument (0) of (get_coordvar) can not
>> coerce
>>
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> ;;;;;;;;Function definition
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> undef ("get_coordvar")
>> function get_coordvar(file1:file,coord:string,size:integer)
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> local coordvarname, coordvar
>>
>> begin
>> print("Enter the file-variable representing "+coord+" : ")
>> coordvarname = systemfunc("read var; echo $var")
>> if (isfilevar(f, coordvarname))
>> coordvar = file1[:]->$coordvarname$
>> size1 = dimsizes (coordvar)
>> if (size .ne. size1)
>> coordvar=ispan(0,size-1,1)
>> end if
>> else
>> coordvar=ispan(0,size-1,1)
>> end if
>> return (coordvar)
>> end;;; End of function definition get_coordvar() ;;;
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>> if(.not.iscoord(data,"time"))
>> data&time = get_coordvar(file1,"time",dimsize(0))
>> end if
>>
>>
>> --
>> *Gibies George, CSIR-RF,
>> Climate and Global Modelling Division,
>> Indian Institute of Tropical Meteorology,
>> Dr. Homi Bhabha Road,
>> NCL (P. O.), Pashan,
>> Pune 411008, India.*
>>
>> *http://sites.google.com/site/gibiesge/*
>>
>> Think about the environment. Save paper; Save Trees. Please don't print
>> this e-mail unless it is necessary.
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>

-- 
*Gibies George,   CSIR-RF,
Climate and Global Modelling Division,
Indian Institute of Tropical Meteorology,
Dr. Homi Bhabha Road,
NCL (P. O.), Pashan,
Pune 411008, India.*
*http://sites.google.com/site/gibiesge/*
Think about the environment. Save paper; Save Trees. Please don't print this
e-mail unless it is necessary.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 23 00:06:16 2011

This archive was generated by hypermail 2.1.8 : Wed Feb 23 2011 - 16:47:57 MST