Hello,
I am trying to compute 30 year seasonal averages for some variables using
monthly average files but I am getting an unusual error and I don't know how
to fix it. The error that is giving me is the following
ncl: posixio.c:412: px_get: Assertion `extent != 0' failed.
Abort
This is just with one of the monthly files, it works if I do it with all
other files excluding the one with the problems. What does it mean? Here is
my script.
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 "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
; this script takes the monthly averaged CAM data
; and computes seasonal averages
; 3/25/08 - updated for the T85 members
; this particular version computes a composite - or mean
; from the ensemble members
begin
nf = 4
path = new(nf,string)
; add your own paths
path(0) = "~cvillanu/Future/2070-2099_p_z/"
;******************************************************
; get some initial information from one of the grb files
;******************************************************
;Set Path
; path to a file
; add your path here
main1="~cvillanu/Past/"
; add your file here
;file1="030bES_T85.cam2.h0.1990-01.nc"
file1="1990Apr.nc"
;Pointers
f = addfile(main1+file1, "r")
;Read Variables
; mainly to extract some metadata, to get dimensions
lon = f->lon
lat = f->lat
lev = f->lev
tt = f->uavg
;dum = f->uavg
; read ps, the hybrid coordinate arrays, and geopotential height (see
simple.ncl) to compute P
nlat = dimsizes(lat)
nlon = dimsizes(lon)
nlev = dimsizes(lev)
;dimdum = dimsizes(dum)
;nlev = dimdum(2)
monstrng =
(/"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"/)
;Set Path
t_mam = new((/nlev,nlat,nlon/), float)
t_jja = new((/nlev,nlat,nlon/), float)
q_mam = new((/nlev,nlat,nlon/), float)
q_jja = new((/nlev,nlat,nlon/), float)
u_mam = new((/nlev,nlat,nlon/), float)
u_jja = new((/nlev,nlat,nlon/), float)
v_mam = new((/nlev,nlat,nlon/), float)
v_jja = new((/nlev,nlat,nlon/), float)
p_mam = new((/nlev,nlat,nlon/), float)
p_jja = new((/nlev,nlat,nlon/), float)
z_mam = new((/nlev,nlat,nlon/), float)
z_jja = new((/nlev,nlat,nlon/), float)
t_mam = 0.
t_jja = 0.
q_mam = 0.
q_jja = 0.
u_mam = 0.
u_jja = 0.
v_mam = 0.
v_jja = 0.
p_mam = 0.
p_jja = 0.
z_mam = 0.
z_jja = 0.
mamcnt = 0
jjacnt = 0
;
; loop through files and extract the monnthly data
;ybeg = 1978
;yend = 1998
ybeg = 2077
yend = 2078
do ny = ybeg,yend
do nm = 2, 7 ;March-August
file3 = ny+monstrng(nm)+".nc"
;Pointer
f3 = addfile(path(0)+file3, "r")
; check for missing data (essentially, a missing file)
if(any(.not.ismissing(f3))) then
print (file3)
; read your variables here: T, Q, U, V, Z, P
; these are dimensions: nlev, nlat, nlon
t = f3->tavg
q = f3->qavg
u = f3->uavg
v = f3->vavg
p = f3->pavg
z = f3->zavg
sev = f3->sev
if (nm.ge.2.and.nm.le.4) then
t_mam = t_mam + t
q_mam = q_mam + q
u_mam = u_mam + u
v_mam = v_mam + v
p_mam = p_mam + p
z_mam = z_mam + z
mamcnt = mamcnt +1
end if
; add the same variables here...
if (nm.ge.5.and.nm.le.7) then
;mcape_jja = mcape_jja + mcape
t_jja = t_jja + t
q_jja = q_jja + q
u_jja = u_jja + u
v_jja = v_jja + v
p_jja = p_jja + p
z_jja = z_jja + z
jjacnt = jjacnt +1
end if
end if
end do
end do
; final averages
; do final averages on other variables
t_mam =t_mam/mamcnt
t_jja =t_jja/jjacnt
q_mam =q_mam/mamcnt
q_jja =q_jja/jjacnt
u_mam =u_mam/mamcnt
u_jja =u_jja/jjacnt
v_mam =v_mam/mamcnt
v_jja =v_jja/jjacnt
p_mam =p_mam/mamcnt
p_jja =p_jja/jjacnt
z_mam =z_mam/mamcnt
z_jja =z_jja/jjacnt
delete (f3)
; dump out data
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
; now, dump out the monthly averages to a
; netcdf file
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ncfile = "jjafields.nc"
ncdf = addfile(ncfile ,"c") ; open output netCDF file
;===================================================================
; create global attributes of the file
;===================================================================
fAtt = True ; assign file attributes
fAtt_at_title = "Summer Averages"
fAtt_at_domxmin = lon(0)
fAtt_at_domxmax = lon(nlon-1)
fAtt_at_domymin = lat(0)
fAtt_at_domymax = lat(nlat-1)
fileattdef( ncdf, fAtt ) ; define file attributes
dimNames = (/"lat","lon"/)
dimSizes = (/nlat,nlon/)
dimUnlim = (/False,False/)
filedimdef(ncdf,dimNames,dimSizes,dimUnlim)
ncdf->u_jja = u_jja ; lat, lon
ncdf->v_jja = v_jja ; lat, lon
ncdf->p_jja = p_jja ; lat, lon
ncdf->z_jja = z_jja ; lat, lon
ncdf->t_jja = t_jja ; lat, lon
ncdf->q_jja = q_jja ; lat, lon
ncdf->lon = lon
ncdf->lat = lat
ncfile2 = "mamfields.nc"
ncdf2 = addfile(ncfile2 ,"c") ; open output netCDF file
;===================================================================
; create global attributes of the file
;===================================================================
fAtt = True ; assign file attributes
fAtt_at_title = "Spring Averages"
fAtt_at_domxmin = lon(0)
fAtt_at_domxmax = lon(nlon-1)
fAtt_at_domymin = lat(0)
fAtt_at_domymax = lat(nlat-1)
fileattdef( ncdf2, fAtt ) ; define file attributes
dimNames = (/"lat","lon"/)
dimSizes = (/nlat,nlon/)
dimUnlim = (/False,False/)
filedimdef(ncdf2,dimNames,dimSizes,dimUnlim)
ncdf2->u_mam = u_mam ; lat, lon
ncdf2->v_mam = v_mam ; lat, lon
ncdf2->p_mam = p_mam ; lat, lon
ncdf2->z_mam = z_mam ; lat, lon
ncdf2->t_mam = t_mam ; lat, lon
ncdf2->q_mam = q_mam ; lat, lon
ncdf2->lon = lon
ncdf2->lat = lat
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 09 2009 - 11:00:07 MDT
This archive was generated by hypermail 2.2.0 : Thu Jun 11 2009 - 14:54:53 MDT