Re: cannot allocate memory

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Tue May 10 2011 - 15:23:57 MDT

Hi Nee,
How to fix it depends on what you want to do with the data. Obviously
your data exceeds the 2GB of memory your system has, and thus you cannot
read in the entirety of the dataset. You have four options:

1) Read in a subset of timesteps:
    psl = f[:]->PSL(120:,:,:)
    But I doubt that you would want to do this.

2) Read in a subset of your domain:
    psl = f[:]->PSL(:,{0:},:)
    The above would read in only the Northern Hemisphere assuming the
    latitudes runs from south->north.

3) Read the data in in two separate steps, do what you need to do with
the data, and then merge things. For example, assuming the data starts
in January and you want to compute a Dec-Jan-Feb 3 month mean:

    psl_nh = f[:]->PSL(:,{0:},:)
    psl_nh_3mo = runave_Wrap(psl_nh(lat|:,lon|:,time|:),3,0)
    psl_nh_djf = psl_nh_3mo(:,:,0::12)
    delete(psl_nh)
    delete(psl_nh_3mo)

    psl_sh = f[:]->PSL(:,{:-0.5},:)
    psl_sh_3mo = runave_Wrap(psl_sh(lat|:,lon|:,time|:),3,0)
    psl_sh_djf = psl_sh_3mo(:,:,0::12)
    delete(psl_sh)
    delete(psl_sh_3mo)

    lat = f[0]->lat
    dimz = dimsizes(psl_sh)
    psl_fin = new((/dimz(0),dimz(1)*2,dimz(2)/), \
              typeof(psl_sh),psl_sh@_FillValue)
    psl_fin!0 = "time"
    psl_fin&time = psl_sh&time
    psl_fin!1 = "lat"
    psl_fin&lat = lat
    psl_fin!2 = "lon"
    psl_fin&lon = psl_sh&lon
    psl_fin(:,{:0.5},:) = (/ psl_sh_djf /)
    psl_fin(:,{0:},:) = (/ psl_nh_djf /)
    delete(psl_sh_djf)
    delete(psl_nh_djf)

    Of course, this all depends on how big your dataset is. If it's
greater than or close to 4GB, the above method wouldn't work. In that
case you could subset the dataset even further (instead of cutting it in
1/2 cut it in 1/4ths) before merging it, or you could:

4) Run your script on a machine with more memory.

Finally, you are running NCL version 5.1.0, which is over 2 years old.
It is highly recommended you upgrade your version of NCL.. A good time
to do that is when ncl version 6.0.0 is released in the next couple of
weeks.

If the above didn't help please respond to ncl-talk and let the group know.
Good luck,
Adam

On 05/09/2011 09:23 PM, Tq wrote:
> Hi,
>
> I¡¯m reading in 360 data files(30 years monthly sea level pressure) which
> vary in time to join them together,but it cannot read in all the
> files.The version of NCL I am running is Version:version5.1.0 .The type
> of system is CYGWIN_NT-5.1 PC2011031418ZRL 1.5.25(0.156/4/2) 2008-06-12
> 19:34 i686 Cygwin.My computer memory is 2GB .Could you please help me
> fix it?
>
> My NCL script:
>
> begin
>
> all_files= systemfunc("ls d:/nee/paper/psl/psl_9*.nc")
>
> f = addfiles(all_files,"r")
>
> ListSetType(f,"cat")
>
> psl = f[:]->PSL
>
> printVarSummary(psl)
>
> end
>
> I get the following error:
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_911_03.nc)
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_911_02.nc)
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_911_01.nc)
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_910_12.nc)
>
> .
>
> .
>
> .
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_901_03.nc)
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_901_02.nc)
>
> fatal:Cannot allocate memory
>
> fatal:Could not open (d:/nee/paper/psl/psl_901_01.nc)
>
> Variable: psl
>
> Type: float
>
> Total Size: 7766016 bytes
>
> 1941504 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes:[time | 237] x [lat | 64] x [lon | 128]
>
> Coordinates:
>
> time: [332270..332270]
>
> lat: [-87.86379883923263..87.86379883923263]
>
> lon: [0..357.1875]
>
> Number Of Attributes: 3
>
> units :Pa
>
> long_name :Sea level pressure
>
> cell_method : time: mean
>
> Thanks a lot!
>
> Nee
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
__________________________________________________
Adam Phillips 
asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
Climate and Global Dynamics Division         fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue May 10 15:24:07 2011

This archive was generated by hypermail 2.1.8 : Fri May 13 2011 - 10:21:56 MDT