fatal:NhlMalloc Failed:[errno=12]

From: Anandhi Aavudai <AavudaiA_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 12 2009 - 09:42:00 MDT


I have a script which reads about 195 .nc files one at a time in a do loop. Then each file is regridded and a section is written into a ascii file using 2 other do loops. To my knowledge all the memory allocated for each file in reading, regridding & writing to ascii file is released by using delete statements. In am using ncl 5.1.1 in Cywin. my doubts are

1. when I track the time required in manipulating each of the 195 nc files, Why do I find the time required for each file manipulation is almost doubled as more & more files are read ?

2. on reading the previous posting in ncl-talk archives, I understand creating unique strings in a loop consumes a lot of memory. But I am deleteing the array/variables having the string at the end. Why is my program still consuming more memory?

3. in Matlab the current directory lets me know which are the variables/arrays are still defined after running a program. Is there something similar or ohter commands in NCL which will let me know which variable/arrays are taking up memory after completing a loop? this could help me know why time is doubled.

4. Finally the program stops with "fatal:NhlMalloc Failed:[errno=12]" . where is the memory taken up in the program?

5. How do I upload a couple of nc files?

Thanks in advance for the help.


;;;My program-------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
dir = "F:/IPCC_data_copy/sresa1b_atm_da/pr"
dblquote = integertochar(34)
fili = systemfunc("find " + dir + "/* -type f -name " + dblquote + "*.nc" + dblquote + " -print")
do nf=0,nfili-1 ; loop to read each file
          wcStrt= systemfunc("date") ; start of cal. time for this prog
          in = addfile (fili(nf), "r") ; reads a file
          time = in->time
          lat = in->lat
          lon = in->lon({0:360})

         newlat!0 = "lat"
         newlat@units = "degress_north"
         newlat@long_name = "latitude"
         newlat&lat = newlat
         newlon!0 = "lon"
         newlon@units = "degress_east"
         newlon@long_name = "longitude"
         newlon&lon = newlon
        ;======Output file name
        fout=new(3,"string") ; defing fout ass an array of strings
       fout(0)="G:/IPCC_data_copy/sresa1b_atm_da_all_regrid/pr" ; adding a folder name
       fout(1)=chartostring(fex(35:dimsizes(fex)-5)) ; extracting a portion of the file name from input file

       data=new(19*15*ntim,"string"); pre allocate
       Time=sprintf("%7.1f ",in&time) ; do once: always the same
       nStrt = 0
       nLast = ntim-1
      do nl=44,62 ; extracts lat 22.5N to 65N -- 19 latiude values
               do ml = 108,122 ; extracts 270 to 305 ---15 longitudes
                       LatLon = sprintf("%7.1f ",newlat(nl)) + sprintf("%6.1f" , newlon(ml)) + sprintf("%6.1f" , 360-newlon(ml))
                       data(nStrt:nLast) = Time + LatLon + sprintf("%25.2f",dout(:,nl,ml)*86400)
                       nStrt = nStrt + ntim
                       nLast = nLast + ntim
                end do
       end do
     wallClockElapseTime(wcStrt, "Ascii: "+fili(nf) ,0) ; end & print timelapsed since the clock start time loop
end do ; nf loop
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Mon Oct 12 09:42:07 2009

This archive was generated by hypermail 2.1.8 : Thu Oct 29 2009 - 10:19:30 MDT