Thanks for the quick reply. Your method worked, except I am not sure how the control file will look!<br>So I split the output in two files, one for U and the other for V.&nbsp; The following is just minor modification to your script, may be helpful to others who are following. But, I am still not sure why my original script did not work.
<br>---------------------------------------------------<br>&#39;reinit&#39;<br>&#39;c&#39;<br>&#39;sdfopen <a href="http://uwnd.2002.nc/" target="_blank">uwnd.2002.nc</a>&#39;<br>&#39;sdfopen <a href="http://vwnd.2002.nc/" target="_blank">
vwnd.2002.nc</a>&#39;<br><br>&#39;set gxout fwrite&#39;<br>&#39;set fwrite u_anom_ncep.grd&#39;<br>t1=100<br>while(t1&lt;161)<br>&#39;set t &#39;t1<br>z1=1<br>while(z1&lt;18)<br>&#39;set z &#39;z1 <br>&#39;set x 1 144&#39; ; &#39;set y 1 73&#39;
<br>&#39;define ubar=ave(uwnd,time=10apr02,time=10jun02)&#39;<br>&#39;d uwnd-ubar&#39;<br><br>z1=z1+1<br>endwhile<br>t1=t1+1<br>endwhile<br>&#39;disable fwrite&#39;<br><br>&#39;set gxout fwrite&#39;<br>&#39;set fwrite v_anom_ncep.grd&#39;
<br>t1=100<br>while(t1&lt;161)<br>&#39;set t &#39;t1<br>z1=1<br>while(z1&lt;18)<br>&#39;set z &#39;z1 <br>&#39;set x 1 144&#39; ; &#39;set y 1 73&#39; <br>&#39;define vbar=ave(vwnd.2,time=10apr02,time=10jun02)&#39;<br>&#39;d
vwnd.2-vbar&#39;<br>z1=z1+1<br>endwhile<br>t1=t1+1<br>endwhile<br>&#39;disable fwrite&#39;<br>---------------------------------------------------------------------------<br><br><div class="gmail_quote">On Nov 27, 2007 11:02 AM, Mary Jo Nath &lt;
<a href="mailto:Mary-Jo.Nath@noaa.gov">Mary-Jo.Nath@noaa.gov</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Try the following. (This assumes that the U and V files have the same time coordinates.) You might also want to post the associated CTL file for &quot;u_v_anom_ncep.grd&quot;
<br>&nbsp;if you continue to have difficulties. - MJ<br><div class="Ih2E3d"><br>&#39;reinit&#39;<br>&#39;c&#39;<br><br>&#39;sdfopen <a href="http://uwnd.2002.nc" target="_blank">uwnd.2002.nc</a>&#39;<br>&#39;sdfopen <a href="http://vwnd.2002.nc" target="_blank">
vwnd.2002.nc</a>&#39;<br><br>&#39;set gxout fwrite&#39;<br>&#39;set fwrite u_v_anom_ncep.grd&#39;<br><br>t1=100<br><br></div><div class="Ih2E3d">while(t1&lt;161)<br><br>&#39;set t &#39;t1<br></div>* write U values at time &quot;t1&quot; &nbsp;for all Z levels
<br>z1=1<br><div class="Ih2E3d">while(z1&lt;18)<br>&#39;set z &#39;z1<br>&#39;set x 1 144&#39; ; &#39;set y 1 73&#39;<br>&#39;define ubar=ave(uwnd,time=10apr02,time=10jun02)&#39;<br></div>&#39;d uwnd-ubar&#39;<br>z1=z1+1<br>
endwhile<br><br>* Then write V values at time &quot;t1&quot; for all Z levels<br>z1=1<br><div class="Ih2E3d">while(z1&lt;18)<br>&#39;set z &#39;z1<br>&#39;set x 1 144&#39; ; &#39;set y 1 73&#39;<br></div><div class="Ih2E3d">
&#39;define vbar=ave(vwnd.2,time=10apr02,time=10jun02)&#39;<br></div><div class="Ih2E3d">&#39;d vwnd.2-vbar&#39;<br>z1=z1+1<br>endwhile<br><br>t1=t1+1<br>endwhile<br>&#39;disable fwrite&#39;<br><br><br><br></div><div><div>
</div><div class="Wj3C7c">John Guhin wrote:<br>&gt; Hi,<br>&gt; &nbsp; &nbsp; &nbsp; I am trying to write a 4D &nbsp;(time, height, lat,<br>&gt; &nbsp;lon). This is the script I wrote, but only the first time step is written.<br>&gt; Any help?<br>
&gt;<br>&gt; &#39;reinit&#39;<br>&gt; &#39;c&#39;<br>&gt;<br>&gt; &#39;sdfopen <a href="http://uwnd.2002.nc" target="_blank">uwnd.2002.nc</a>&#39;<br>&gt; &#39;sdfopen <a href="http://vwnd.2002.nc" target="_blank">vwnd.2002.nc
</a>&#39;<br>&gt;<br>&gt; &#39;set gxout fwrite&#39;<br>&gt; &#39;set fwrite u_v_anom_ncep.grd&#39;<br>&gt;<br>&gt; t1=100<br>&gt; z1=1<br>&gt; while(t1&lt;161)<br>&gt; &#39;set t &#39;t1<br>&gt; while(z1&lt;18)<br>&gt; &#39;set z &#39;z1
<br>&gt;<br>&gt; &#39;set x 1 144&#39; ; &#39;set y 1 73&#39;<br>&gt;<br>&gt; &#39;define ubar=ave(uwnd,time=10apr02,time=10jun02)&#39;<br>&gt; &#39;define vbar=ave(vwnd.2,time=10apr02,time=10jun02)&#39;<br>&gt;<br>&gt; &#39;d uwnd-ubar&#39;
<br>&gt; &#39;d vwnd.2-vbar&#39;<br>&gt;<br>&gt; z1=z1+1<br>&gt; endwhile<br>&gt; t1=t1+1<br>&gt; endwhile<br>&gt; &#39;disable fwrite&#39;<br>&gt;<br>&gt;<br>&gt; &nbsp;How can I write the data for all time steps?<br>&gt;<br>
&gt; &nbsp;thanks.<br>&gt;<br>&gt;<br>&gt; &nbsp;John Guhin<br>&gt; -<br>&gt;<br>&gt;<br></div></div></blockquote></div><br><br clear="all"><br>-- <br>John Guhin