fwrite problem of 4D data

Mary Jo Nath Mary-Jo.Nath at NOAA.GOV
Tue Nov 27 11:02:21 EST 2007


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
> -
>
>



More information about the gradsusr mailing list