<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I solved this by using an expected dimsize for time but keeping dimunlim=True, and now I can data incrementally up until time dimsize is reached. But I'm not sure if this the best
approach.
<div><br>
</div>
<div> ; create with unlimited time</div>
<div> nt=3000 ; expected size, but can add incrementally until that point</div>
<div>
<div style="font-size: 13.3333330154419px;"> outncdf = addfile(_outpath+varname+".nc" ,"c")</div>
<div style="font-size: 13.3333330154419px;"> dimNames = (/"time","south_north","west_east"/)</div>
<div style="font-size: 13.3333330154419px;"> dimSizes = (/ nt, ny, nx /)</div>
<div style="font-size: 13.3333330154419px;"> dimUnlim = (/ True, False, False /)</div>
<div style="font-size: 13.3333330154419px;"> filedimdef(outncdf,dimNames,dimSizes,dimUnlim)</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">
<div style="font-size: 13.3333330154419px;"> filevardef(outncdf, "DateTime", "integer", getvardims(datetime))</div>
<div style="font-size: 13.3333330154419px;"> filevarattdef(outncdf, "DateTime", datetime)</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;"> filevardef(outncdf, varname, "float", dimNames)</div>
<div style="font-size: 13.3333330154419px;"> filevarattdef(outncdf, varname, var)</div>
</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">
<div style="font-size: 13.3333330154419px;"> outncdf->DateTime=(/datetime/)</div>
<div style="font-size: 13.3333330154419px;"> outncdf->$varname$=(/var/)</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
</div>
<div style="font-size: 13.3333330154419px;"> ; first 10 timesteps above were added with create, now add 10 more with write</div>
<div style="font-size: 13.3333330154419px;">
<div style="font-size: 13.3333330154419px;"> outncdf = addfile(_outpath+varname+".nc" ,"w")</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;"> tcount=10</div>
<div style="font-size: 13.3333330154419px;"> ntstep=20</div>
<div style="font-size: 13.3333330154419px;"> outncdf->DateTime(time|tcount:(tcount+ntstep)-1)=(/datetime/)</div>
<div style="font-size: 13.3333330154419px;"> outncdf->$varname$(time|tcount:(tcount+ntstep)-1,south_north|:,west_east|:)=(/var/)</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF942061" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> ncl-talk-bounces@ucar.edu [ncl-talk-bounces@ucar.edu] on behalf of Matthew Fearon [Matthew.Fearon@dri.edu]<br>
<b>Sent:</b> Tuesday, August 25, 2015 11:51 PM<br>
<b>To:</b> ncl-talk@ucar.edu<br>
<b>Subject:</b> [ncl-talk] appending to an existing netcdf file with an unlimited time dimension<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Dear NCL users:
<div><br>
</div>
<div>I have been able to append to an existing netcdf file before easily with an unlimited time dimension. However, something has changed as my old scripts no longer work. I have tried so many combinations unsuccessfully. This seems more difficult than it needs
to be. So I create the netcdf file with (time, lat, lon) with time unlimited, add variables -- this works fine. However, if I want to append an additional time step or several at once -- no dice. Below is a snip of my code. Note the if condition is the initial
create, and else condition is the append which fails.</div>
<div><br>
</div>
<div>thanks for the help,</div>
<div>Matt</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>if (it.eq.0) then</div>
<div><br>
</div>
<div> outncdf = addfile(_outpath+varname+".nc" ,"c")</div>
<div> dimNames = (/"time","south_north","west_east"/)</div>
<div> dimSizes = (/ -1, ny, nx /)</div>
<div> dimUnlim = (/ True, False, False /)</div>
<div> filedimdef(outncdf,dimNames,dimSizes,dimUnlim)</div>
<div><br>
</div>
<div> filevardef(outncdf, "DateTime", "integer", getvardims(datetime))</div>
<div> filevarattdef(outncdf, "DateTime", datetime)</div>
<div><br>
</div>
<div> filevardef(outncdf, varname, "float", dimNames)</div>
<div> filevarattdef(outncdf, varname, var)</div>
<div><br>
</div>
<div> filevardef(outncdf, "lat", "float", getvardims(latm2d))</div>
<div> filevarattdef(outncdf, "lat", latm2d)</div>
<div><br>
</div>
<div> filevardef(outncdf, "lon", "float", getvardims(lonm2d))</div>
<div> filevarattdef(outncdf, "lon", lonm2d)</div>
<div><br>
</div>
<div> outncdf->DateTime=(/datetime/)</div>
<div> outncdf->$varname$=(/var/)</div>
<div> outncdf->lat=(/latm2d/)</div>
<div> outncdf->lon=(/lonm2d/)</div>
<div><br>
</div>
<div>else</div>
<div><br>
</div>
<div> outncdf = addfile(_outpath+varname+".nc" ,"w")</div>
<div><br>
</div>
<div> outncdf->time(tcount:) = datetime</div>
<div> ;outncdf->DateTime(time|tcount:)=(/datetime/)</div>
<div> ;outncdf->$varname$(time|tcount:,south_north|:,west_east|:)=(/var/)</div>
<div><br>
</div>
<div> outncdf->DateTime(tcount:)=(/datetime/)</div>
<div> outncdf->$varname$(tcount:,:,:)=(/var/)</div>
<div><br>
</div>
<div>end if</div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>