- 积分
- 6653
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-4-28
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 lzc90 于 2015-8-22 18:42 编辑
因项目开发需要,必须在Windows系统下,使用CFSv2预报资料(.grb2格式)。因IDL8.3版本读取grb2数据有错,故采用cygwin调用NCL的方式,利用NCL将GRB2格式转换为NC格式,再利用IDL处理NC文件。但是在读取数据量较大文件海表下5m温度文件ocnsst.grb2([lon,lat,tine]维数大小:[720,360,1196],170余M)出现错误如下:
- ncl ocnsst.ncl
- Processing file: ocnsst.grb2...
- Copyright (C) 1995-2011 - All Rights Reserved
- University Corporation for Atmospheric Research
- NCAR Command Language Version 6.0.0
- The use of this software is governed by a License Agreement.
- See http://www.ncl.ucar.edu/ for more details.
- <font color="Magenta"><b>fatal:NclMalloc Failed:[errno=12]
- Segmentation fault (core dumped)
- </b></font>
复制代码 如果在不替代现有海温资料.grb2的前提下,可以如何解决?暂思考无果,烦劳各位提出宝贵意见和建议。
我的文本ocnsst.ncl代码附于文末(可能导致该错误的语句(读入数组过大),为第 24 行 和 第60 行。)。
- <P>
- <P>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
- function rdVar4D (f:file, vName:string, time:integer, lat:float,lon:float)
- ; read GRIB 4D variable and assign new dimension names
- begin
-
- var=new((/dimsizes(time),dimsizes(lat),dimsizes(lon)/),float)
-
- var_TMP = f->$vName$; read variable
-
- var_TMP!0 = "time" ; assign 'conventional' dimension names
-
- var_TMP!1 = "lat"
- var_TMP!2 = "lon"
-
- var!0 = "time" ; assign 'conventional' dimension names
- var!1 = "lat"
-
- var!2 = "lon"
-
- var=var_TMP(:(dimsizes(time)-1),59:220,89:560)
- return(var)
- end
- begin
- ;***********************************************
- ; read in data from GRIB file
- ;***********************************************
-
- gribdir = "./"
-
- gribfil = "ocnsst.grb2"
-
- grib_in = addfile(gribdir+gribfil, "r")
- _ft=grib_in->forecast_time0
-
- _lat=grib_in->lat_0
- _lon=grib_in->lon_0
- time=_ft(:239)
- time!0 = "time"
-
- lat=_lat(59:220) ;_lat[59]=60.25,_lat[220]=-20.25 Origin: _lat range=[89.75,-89.75] Delta=0.5 N=360
- lat!0 = "lat"
-
- lon=_lon(89:560) ;_lon[89]=44.75,_lon[560]=280.25 Origin: _lon range=[0.25,359.75] Delta=0.5 N=720
- lon!0 = "lon"
-
-
- ocnsst= rdVar4D (grib_in, "POT_P0_L160_GLL0" ,time,lat,lon)</STRONG> ;240个6小时,代表预报未来60天</P>
- <P>;***********************************************
- ; create parameters and output file
- ;***********************************************
-
- ntim = dimsizes(time)
-
- nlat = dimsizes(lat)
-
- mlon = dimsizes(lon)
- system("'rm' -f ocnsst_ncl.nc") ; remove pre-exit file (if any)
-
- ncdf = addfile("ocnsst_ncl.nc","c") ; create output file
- ;***************************************************
- ; define file options [Version a033]
- ;***********************************************
- setfileoption(ncdf, "prefill", False)
-
- setfileoption(ncdf, "suppressclose", True)
- setfileoption(ncdf, "definemode", True)
- ;***********************************************
- ; assign file attributes
- ;***********************************************
-
- fAtt = True
-
- fAtt@title = "GRIB-to-netCDF: Efficient Approach"
-
- fAtt@source_file = "./ocnsst.grb2"
- fAtt@Conventions = "None"
-
- fAtt@creation_date = systemfunc("date")
-
- fileattdef( ncdf, fAtt )
-
- ;***********************************************
- ; predefine coordinate information
-
- ;***********************************************
- dimNames = (/"time", "lat", "lon"/)
-
- dimSizes = (/ntim , nlat, mlon/)
-
- dimUnlim = (/ True , False, False/)
-
- filedimdef(ncdf, dimNames , dimSizes, dimUnlim )
-
- filevardef(ncdf, "time" , typeof(time), getvardims(time) )
- filevarattdef(ncdf, "time", time)
- filevardef(ncdf, "lat", typeof(lat), getvardims(lat) )
- filevarattdef(ncdf, "lat", lat)
-
- filevardef(ncdf, "lon", typeof(lon), getvardims(lon) )
-
- filevarattdef(ncdf, "lon", lon)
-
- ;***********************************************
- ; predefine variable sizes
- ;***********************************************
- filevardef(ncdf,"ocnsst",typeof(ocnsst),getvardims(ocnsst) )
- filevarattdef(ncdf,"ocnsst",ocnsst)
- ;***********************************************
- ; terminate define mode: not necessary but for clarity
- ;***********************************************
-
- setfileoption(ncdf, "definemode", False)
- ;***********************************************
- ; write data values to predefined locations
- ; (/ .../) operator transfer values only
- ;***********************************************
- ncdf->time = (/ time /)
-
- ncdf->lat = (/ lat /)
-
- ncdf->lon = (/ lon /)
-
- ncdf->ocnsst = (/ ocnsst /)
- end </P></P>
复制代码
|
-
cygwin调NCL读取ocnsst.grb2
|