Hi,
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.
regards
Anandhi
;;;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"
begin
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
orig=in->pr
time = in->time
lat = in->lat
lon = in->lon({0:360})
;====Regridding----
newlat=fspan(-90.,90,73);
newlon=fspan(0.,360,145);
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
dout=linint2_Wrap(lon,lat,orig,True,newlon,newlat,0)
;======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
fex=stringtochar(fili(nf));
fout(1)=chartostring(fex(35:dimsizes(fex)-5)) ; extracting a portion of the file name from input file
fout(2)="_NHe_out.txt"
fNameO=str_concat(fout)
print(fNameO)
nnelat=dimsizes(newlat)
nnelon=dimsizes(newlon)
ntim=dimsizes(time)
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
asciiwrite(fNameO,data)
wallClockElapseTime(wcStrt, "Ascii: "+fili(nf) ,0) ; end & print timelapsed since the clock start time loop
delete(in)
delete(dout)
delete(lat)
delete(lon)
delete(newlat)
delete(newlon)
delete(nnelat)
delete(nnelon)
delete(ntim)
delete(fNameO)
delete(data)
delete(fout)
delete(orig)
delete(time)
delete(Time)
delete(wcStrt)
end do ; nf loop
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
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