fwrite problem of 4D data

Heiner Körnich heiner at MISU.SU.SE
Tue Nov 27 12:06:29 EST 2007


Hi John,

my first reply did not work. But I think you forgot the z1=1 in front of
the z-loop. After the first loop z was 19, so all other loops were
skipped.

regards,
Heiner
On Tue, 2007-11-27 at 11:54 -0500, John Guhin wrote:
> Thanks for the quick reply. Your method worked, except I am not sure
> how the control file will look!
> 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.
> ---------------------------------------------------
> 'reinit'
> 'c'
> 'sdfopen uwnd.2002.nc'
> 'sdfopen vwnd.2002.nc'
>
> 'set gxout fwrite'
> 'set fwrite u_anom_ncep.grd'
> t1=100
> while(t1<161)
> 'set t 't1
> z1=1
> while(z1<18)
> 'set z 'z1
> 'set x 1 144' ; 'set y 1 73'
> 'define ubar=ave(uwnd,time=10apr02,time=10jun02)'
> 'd uwnd-ubar'
>
> z1=z1+1
> endwhile
> t1=t1+1
> endwhile
> 'disable fwrite'
>
> 'set gxout fwrite'
> 'set fwrite v_anom_ncep.grd'
> t1=100
> while(t1<161)
> 'set t 't1
> z1=1
> while(z1<18)
> 'set z 'z1
> 'set x 1 144' ; 'set y 1 73'
> 'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'
> 'd vwnd.2-vbar'
> z1=z1+1
> endwhile
> t1=t1+1
> endwhile
> 'disable fwrite'
> ---------------------------------------------------------------------------
>
> On Nov 27, 2007 11:02 AM, Mary Jo Nath < Mary-Jo.Nath at noaa.gov> wrote:
>         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"
>          if you continue to have difficulties. - MJ
>
>         'reinit'
>         'c'
>
>         'sdfopen uwnd.2002.nc'
>         'sdfopen vwnd.2002.nc'
>
>         'set gxout fwrite'
>         'set fwrite u_v_anom_ncep.grd'
>
>         t1=100
>
>
>         while(t1<161)
>
>         'set t 't1
>
>         * write U values at time "t1"  for all Z levels
>         z1=1
>         while(z1<18)
>         'set z 'z1
>         'set x 1 144' ; 'set y 1 73'
>         'define ubar=ave(uwnd,time=10apr02,time=10jun02)'
>
>         'd uwnd-ubar'
>         z1=z1+1
>         endwhile
>
>         * Then write V values at time "t1" for all Z levels
>         z1=1
>         while(z1<18)
>         'set z 'z1
>         'set x 1 144' ; 'set y 1 73'
>
>         'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'
>
>         'd vwnd.2-vbar'
>         z1=z1+1
>         endwhile
>
>         t1=t1+1
>         endwhile
>         'disable fwrite'
>
>
>
>
>
>         John Guhin wrote:
>         > Hi,
>         >       I am trying to write a 4D  (time, height, lat,
>         >  lon). This is the script I wrote, but only the first time
>         step is written.
>         > Any help?
>         >
>         > 'reinit'
>         > 'c'
>         >
>         > 'sdfopen uwnd.2002.nc'
>         > 'sdfopen vwnd.2002.nc'
>         >
>         > 'set gxout fwrite'
>         > 'set fwrite u_v_anom_ncep.grd'
>         >
>         > t1=100
>         > z1=1
>         > while(t1<161)
>         > 'set t 't1
>         > while(z1<18)
>         > 'set z 'z1
>         >
>         > 'set x 1 144' ; 'set y 1 73'
>         >
>         > 'define ubar=ave(uwnd,time=10apr02,time=10jun02)'
>         > 'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'
>         >
>         > 'd uwnd-ubar'
>         > 'd vwnd.2-vbar'
>         >
>         > z1=z1+1
>         > endwhile
>         > t1=t1+1
>         > endwhile
>         > 'disable fwrite'
>         >
>         >
>         >  How can I write the data for all time steps?
>         >
>         >  thanks.
>         >
>         >
>         >  John Guhin
>         > -
>         >
>         >
>
>
>
>
> --
> John Guhin
--
Heiner Körnich
Dept. of Meteorology            Tel:  +46 8 164333
Stockholms University, SE-106 91 Stockholm, Sweden
Email: heiner at misu.su.se   www.misu.su.se/~heiner/



More information about the gradsusr mailing list