Re: How to open files and read variables in a loop?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 19 Sep 2007 07:07:19 -0600

Hi Liang,

The simple answer is that if "precipitation" is a different size on
each file, then the local variable that you store it in will need to be
deleted before the next time through the loop. Add "delete(pric)" right
before the "end do". NCL doesn't like assigning arrays of different
sizes to each other.

If you want to read "precipitation" off each file and store it to one
variable, then instead of using "addfile" in a loop, you might want to
look into using "addfiles". See:

     http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml

for some documentation and examples.

--Mary

On Sep 19, 2007, at 1:07 AM, Liang Guo wrote:

> Dear All,
>  
> I try to open files and read variables in a loop as follow:
> "
>  do n = 0,11,1
>  fin    = addfile (resu(n)+"control.nc", "r")
>  pric  = fin->precipitation
>  ... ... (omiting)
>  end do
> "
>  
> However, it seems no work, ths mistake information is:
> "
> fatal:Assignment type mismatch, right hand side can't be coerced to
> type of left hand side
> fatal:Execute: Error occurred at or near line 41 in file draw_GT.ncl
> "
>  
> How can I do? Thanks!
>  
> Best,
>  
> Liang
> 2007/09/19_______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 19 2007 - 07:07:19 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 24 2007 - 11:44:39 MDT