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. 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>'reinit'<br>'c'<br>'sdfopen <a href="http://uwnd.2002.nc/" target="_blank">uwnd.2002.nc</a>'<br>'sdfopen <a href="http://vwnd.2002.nc/" target="_blank">
vwnd.2002.nc</a>'<br><br>'set gxout fwrite'<br>'set fwrite u_anom_ncep.grd'<br>t1=100<br>while(t1<161)<br>'set t 't1<br>z1=1<br>while(z1<18)<br>'set z 'z1 <br>'set x 1 144' ; 'set y 1 73'
<br>'define ubar=ave(uwnd,time=10apr02,time=10jun02)'<br>'d uwnd-ubar'<br><br>z1=z1+1<br>endwhile<br>t1=t1+1<br>endwhile<br>'disable fwrite'<br><br>'set gxout fwrite'<br>'set fwrite v_anom_ncep.grd'
<br>t1=100<br>while(t1<161)<br>'set t 't1<br>z1=1<br>while(z1<18)<br>'set z 'z1 <br>'set x 1 144' ; 'set y 1 73' <br>'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'<br>'d
vwnd.2-vbar'<br>z1=z1+1<br>endwhile<br>t1=t1+1<br>endwhile<br>'disable fwrite'<br>---------------------------------------------------------------------------<br><br><div class="gmail_quote">On Nov 27, 2007 11:02 AM, Mary Jo Nath <
<a href="mailto:Mary-Jo.Nath@noaa.gov">Mary-Jo.Nath@noaa.gov</a>> 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 "u_v_anom_ncep.grd"
<br> if you continue to have difficulties. - MJ<br><div class="Ih2E3d"><br>'reinit'<br>'c'<br><br>'sdfopen <a href="http://uwnd.2002.nc" target="_blank">uwnd.2002.nc</a>'<br>'sdfopen <a href="http://vwnd.2002.nc" target="_blank">
vwnd.2002.nc</a>'<br><br>'set gxout fwrite'<br>'set fwrite u_v_anom_ncep.grd'<br><br>t1=100<br><br></div><div class="Ih2E3d">while(t1<161)<br><br>'set t 't1<br></div>* write U values at time "t1" for all Z levels
<br>z1=1<br><div class="Ih2E3d">while(z1<18)<br>'set z 'z1<br>'set x 1 144' ; 'set y 1 73'<br>'define ubar=ave(uwnd,time=10apr02,time=10jun02)'<br></div>'d uwnd-ubar'<br>z1=z1+1<br>
endwhile<br><br>* Then write V values at time "t1" for all Z levels<br>z1=1<br><div class="Ih2E3d">while(z1<18)<br>'set z 'z1<br>'set x 1 144' ; 'set y 1 73'<br></div><div class="Ih2E3d">
'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'<br></div><div class="Ih2E3d">'d vwnd.2-vbar'<br>z1=z1+1<br>endwhile<br><br>t1=t1+1<br>endwhile<br>'disable fwrite'<br><br><br><br></div><div><div>
</div><div class="Wj3C7c">John Guhin wrote:<br>> Hi,<br>> I am trying to write a 4D (time, height, lat,<br>> lon). This is the script I wrote, but only the first time step is written.<br>> Any help?<br>
><br>> 'reinit'<br>> 'c'<br>><br>> 'sdfopen <a href="http://uwnd.2002.nc" target="_blank">uwnd.2002.nc</a>'<br>> 'sdfopen <a href="http://vwnd.2002.nc" target="_blank">vwnd.2002.nc
</a>'<br>><br>> 'set gxout fwrite'<br>> 'set fwrite u_v_anom_ncep.grd'<br>><br>> t1=100<br>> z1=1<br>> while(t1<161)<br>> 'set t 't1<br>> while(z1<18)<br>> 'set z 'z1
<br>><br>> 'set x 1 144' ; 'set y 1 73'<br>><br>> 'define ubar=ave(uwnd,time=10apr02,time=10jun02)'<br>> 'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'<br>><br>> 'd uwnd-ubar'
<br>> 'd vwnd.2-vbar'<br>><br>> z1=z1+1<br>> endwhile<br>> t1=t1+1<br>> endwhile<br>> 'disable fwrite'<br>><br>><br>> How can I write the data for all time steps?<br>><br>
> thanks.<br>><br>><br>> John Guhin<br>> -<br>><br>><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>John Guhin