<br>Thanks Heiner. Now it works. <br><br><div class="gmail_quote">On Nov 27, 2007 12:06 PM, Heiner Körnich <<a href="mailto:heiner@misu.su.se">heiner@misu.su.se</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;">
Hi John,<br><br>my first reply did not work. But I think you forgot the z1=1 in front of<br>the z-loop. After the first loop z was 19, so all other loops were<br>skipped.<br><br>regards,<br>Heiner<br><div><div></div><div class="Wj3C7c">
On Tue, 2007-11-27 at 11:54 -0500, John Guhin wrote:<br>> Thanks for the quick reply. Your method worked, except I am not sure<br>> how the control file will look!<br>> So I split the output in two files, one for U and the other for V.
<br>> The following is just minor modification to your script, may be<br>> helpful to others who are following. But, I am still not sure why my<br>> 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>> 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>> Try the following. (This assumes that the U and V files have<br>> the same time coordinates.) You might also want to post the<br>> associated CTL file for "u_v_anom_ncep.grd"
<br>> if you continue to have difficulties. - MJ<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>><br>><br>> while(t1<161)<br>><br>> 'set t 't1<br>><br>> * write U values at time "t1" for all Z levels<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>><br>> '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>> while(z1<18)<br>> 'set z 'z1<br>> 'set x 1 144' ; 'set y 1 73'
<br>><br>> 'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'<br>><br>> 'd vwnd.2-vbar'<br>> z1=z1+1<br>> endwhile<br>><br>> t1=t1+1<br>> endwhile
<br>> 'disable fwrite'<br>><br>><br>><br>><br>><br>> 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
<br>> 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>><br>><br>><br>><br>> --<br>> John Guhin
<br></div></div><font color="#888888">--<br>Heiner Körnich<br>Dept. of Meteorology Tel: +46 8 164333<br>Stockholms University, SE-106 91 Stockholm, Sweden<br>Email: <a href="mailto:heiner@misu.su.se">heiner@misu.su.se
</a> <a href="http://www.misu.su.se/%7Eheiner/" target="_blank">www.misu.su.se/~heiner/</a><br></font></blockquote></div><br><br clear="all"><br>-- <br>John Guhin