; remove old versions of "unlimited.nc" system("rm -rf unlimited.nc") ; create "unlimited.nc" f = addfile("unlimited.nc","c") ; define dimensions, coordinate variables, and a dependent variable "x" filedimdef(f,(/"time","lat","lon"/),(/-1,5,5/),(/True,False,False/)) filevardef(f,"time","float","time") filevardef(f,"lat","float","lat") filevardef(f,"lon","float","lon") filevardef(f,"x","float",(/"time","lat","lon"/)) ; assign dimension values f->lat = (/0,15,30,45,60/) f->lon = (/0,15,30,45,60/) ; time has 0 elements so far, but you can still assign attributes f->time@units = "hours since 2006-05-08 12:00" print(f) x = new((/3,5,5/),"float") x = 30.0 ; assign first 3 elements of time f->x = x ; make sure the coordinate variable gets assigned as well f->time = (/0,6,12/) ; dump file contents system("ncdump unlimited.nc") ; reread file in write mode ; now appending to an existing file f = addfile("unlimited.nc","w") ; assign 4th element of time f->x(3,:,:) = 31.0 f->time(3) = 18 printFileVarSummary(f,"x") ; assign 6th element; note 5th element set to fill value f->x(5,:,:) = 32.0 ; but the 5th coordinate value is defined f->time(4:5) = (/ 24, 30 /) printFileVarSummary(f,"x") ; assign 7th and 8th element of time f->x(6:7,:,:) = 33.0 f->time(6:7) = (/ 36, 42 /) printFileVarSummary(f,"x") ; dump file contents system("ncdump unlimited.nc")