[ncl-talk] Writing data to the existing record dimension of a netCDF

Will Hobbs will.hobbs at utas.edu.au
Tue Nov 29 15:45:33 MST 2016


Hi all

I am working with some model output monthly files (one year for each file, with filename t.<year>.nc), which have a junk time array, and which I am trying to fix. I was hoping to create a new time array, add the values to each file’s time array, and update the variable attributes using NCO:

>Begin

yrst = 1979
yren=2014
vNam = “t”


;create new time array

ydum = new(12, integer)
mdum = ispan(1,12,1)
  ddum = conform_dims(12,15,-1)
 tdum = conform_dims(12,0,-1)

  opt          = 1
  opt at calendar = "standard"
  tunits        = "days after 1-1-1"


;loop through each year
  do yy = yrst, yren

    ;create time array
    ydum = yy
    ntime = cd_inv_calendar(ydum,mdum,ddum,tdum,tdum,tdum,tunits,opt)


    ;add time to file
    fil   =systemfunc("ls "+vNam+"."+yy+".nc")
    fi = addfile(fil,"w")

    fi->time = (/ntime/)

;update attributes
  CMD = “ncatted –a time,units,o,c,”+tunits+” “+fil
system(CMD)

end do


Unfortunately when I try and write the data to file (i.e.    fi->time = (/ntime/) ) I get a segmentation fault:

Segmentation fault: 11

I’ve checked the file permissions and it doesn’t seem to be that. I ‘speculate’ that netCDF won’t allow me to update the record dimension – is this the case? If so, presumably I will need rewrite each file from scratch with new time arrays.

Many thanks,

Will




University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161129/aca72026/attachment.html 


More information about the ncl-talk mailing list