Re: Using file as as argument to function

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 22 2011 - 07:30:05 MST

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
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 22 07:30:11 2011

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