Re: average from netcdf files

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri Nov 18 2011 - 13:11:14 MST

The error message is telling you what is wrong. You have created 'var' as a scalar and then you are trying to assign an array to it.

Try putting this in front of your code:

fname = path + name(0)
in = addfile(fname,"r")
sizes = getfilevardimsizes(in,"AOC")
var = new(sizes(1:),typeof(getfilevartypes(in,"AOC")))
var = 0
etc.

On Nov 18, 2011, at 12:07 PM, Xiaoyan Ma wrote:

> Hi
>
> I want to do annual mean from monthly netcdf files. I did the following
>
> var = 0.
> do n = 0, 11
> fname = path + name(n)
> in = addfile(fname,"r")
> var0 = in->AOC(0,:,:)
> var = var + var0
> end do
> var = var/12
>
> the error info is "fatal:Number of dimensions on right hand side do not match number of dimension in left hand side" in line 23 (i.e. var = var + var0).
>
> how to resolve the problem? thanks,
>
> Xiaoyan
>
>
> _______________________________________________
> 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 Fri Nov 18 13:11:22 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 22 2011 - 14:17:52 MST