[ncl-talk] write variable in do loop

Alessandra Giannini alesall at iri.columbia.edu
Thu Sep 10 04:34:58 MDT 2015


Hi there, 

I am not familiar with the "wrf" commands you use, but you are asking it to overwrite levels with this line:

> fw->u_plane = u_plane 


Do you need to write the levels out separately, meaning do you need a do-loop to begin with?
If you have all the data in a variable, it may be preferable to select the time and levels you want to write out with coordinate selection, and write out all in one go.

warm regards





-- 
Alessandra Giannini
IRI for Climate and Society - The Earth Institute at Columbia University
P.O. Box 1000, Palisades NY 10964-8000
phone/fax: +1 845 680-4473/4864 - email: alesall at iri.columbia.edu

On Sep 10, 2015, at 12:26 AM, Ancy Thomas <ancyt.thomas at gmail.com> wrote:

> Could anyone please help for this query.
> 
> 
> 
> On Wed, Sep 9, 2015 at 6:04 PM, Ancy Thomas <ancyt.thomas at gmail.com> wrote:
> Hello all,
> Greetings!
> 
> I want to write a variable in do loop. But it is writing the data only for the last level(200hpa), ie; data is getting over written for each level. How to save the u_plane data as array?
> 
>  
> ;;***************Pressure levels **********
>  plevs = (/ 925., 850., 700., 600., 500., 300., 200./)   ; pressure levels to plot
>  nlevels         = dimsizes(plevs)     ; number of pressure levels
> 
> ; writing data into netcdf format
>     system("rm -f wrfout.nc")
>     fw = addfile("wrfout.nc", "c")
> 
> 
> ; writing the dimensions time, level, lat, lon
> 
> ;  fw->xlev = xlev
>   fw->xlat = xlat
>   fw->xlon = xlon
> 
>  do it = 0,ntimes-1               ; TIME LOOP
> 
>  do level = 0,nlevels-1                 ; LOOP OVER LEVELS
> u    = wrf_user_getvar(a,"U",it)
> 
> u_plane    = wrf_user_intrp3d(u,p,"h",pressure,0.,False)
> 
> fw->u_plane = u_plane 
> 
> end do ; level loop
> end do ; time loop
> 
> Kindly help to resolve the issue.
> 
> Thank you,
> With regards,
> -- 
> Ancy Thomas,
> Computational Earth Science Group / HPC application Group
> CDAC
> Pune
> 
> 
> 
> 
> -- 
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk



More information about the ncl-talk mailing list