- 积分
- 3590
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-9-29
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
请问现在我需要读取53个文件,然后在中国范围内每个点出一个txt,也就是10000多个txt,但是内存严重不足,运行一段时间就被守护进程kill了,有什么办法可以每次写入一次txt就关闭一次txt来释放内存吗?我没有找到关闭write_table的命令- ;*****************************************************
- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
- load "$WORKDIR/include/library.ncl"
- ;***************************************
- begin
- ; read data from grib file
- do j=0,240,3
- do point_lon1=74,154,1
- point_lon=tofloat(point_lon1)/2
- do point_lat1=7,107,1
- point_lat=tofloat(point_lat1)/2
- if j.lt.10 then
- worktime="00"+tostring(j)
- else if j .ge.10 .and. j .lt.100 then
- worktime="0"+tostring(j)
- else
- worktime=tostring(j)
- end if
- end if
- inputpath = getArgsPara(params,"src")+worktime+".grib2"
- outputpath=getArgsPara(params,"OUTPUTDIR")
- filePart=str_split(outputpath,"/")
- fileName=filePart(dimsizes(filePart)-1)
- checkOrCreateDir(outputpath)
- header = (/"经度:"+point_lon+","+"纬度:"+point_lat,"起报时间:"+fileName+"08", \
- "时效 风速 "/)
- hlist=[/header/]
- if(toint(worktime).eq.0)then
- write_table(outputpath+"/wind_"+point_lon+"_"+point_lat+".txt","w",hlist,"%s")
- end if
- U = vars->UGRD_P0_L103_GLL0(0,:,:)
- V = vars->VGRD_P0_L103_GLL0(0,:,:)
- lon = vars->lon_0
- lat = vars->lat_0
- longrid=(max(lon)-min(lon))/(dimsizes(lon)-1)
- latgrid=(max(lat)-min(lat))/(dimsizes(lat)-1)
- x_num=toint((point_lon-min(lon))/longrid)
- y_num=toint((max(lat)-point_lat)/latgrid)
- ;==============================for wind=============================================
-
- wind=sqrt(U^2+V^2)
- delete (U)
- delete (V)
- delete (lon)
- delete (lat)
- delete (vars)
- delete (inputpath)
- alist=[/worktime,wind(y_num,x_num)/]
- write_table(outputpath+"/wind_"+point_lon+"_"+point_lat+".txt","a",alist,"%3.3s%15.4f")
- ;destroy(write_table)
- ; cmd00="su"
- ; system(cmd00)
- ; cmd000="123456"
- ; system(cmd000)
- ; cmd0="/proc/sys/vm/drop_caches"
- ; system(cmd0)
- end do
- end do
- end do
- end
复制代码
|
|