[ncl-talk] write variable in do loop

Ancy Thomas ancyt.thomas at gmail.com
Thu Sep 10 06:02:18 MDT 2015


Hello Madam !

Done the changes as you suggested :

 do it = 0,ntimes-1               ; TIME LOOP
  td = wrf_user_getvar(a,"td",it)
  p  = wrf_user_getvar(a,"pressure",it)

  do level = 0,nlevels-1                 ; LOOP OVER LEVELS
  pressure = plevs(level)

  td_plane(level,:,:) = wrf_user_intrp3d(td,p,"h",pressure,0.,False)

 end do ; end of level loop
 end do ; end of time loop
 end do ; end of files loop
 end

Still I am getting the same error:
fatal:Undefined identifier: (td_plane) is undefined, can't continue
^Mfatal:["Execute.c":8128]:Execute: Error occurred at or near line 49 in
file wrf_td.ncl


Thanks,
regards,
Ancy


On Thu, Sep 10, 2015 at 5:10 PM, Alessandra Giannini <
alesall at iri.columbia.edu> wrote:

>
> Hi there,
>
> [it's a madam speaking, actually!]
> You should always reply to ncl-talk, not just to the person who responds…
>
> It would help if you explained what is not working…
> At any rate, what is the structure of the variable you call here:
>
> >   td = wrf_user_getvar(a,"td",it)
>
>
> if it has all the levels you need, just write it out.
>
> It may be that these two lines that define your variables need to sit
> outside/before the loops:
>
> >   td = wrf_user_getvar(a,"td",it)
> >   p  = wrf_user_getvar(a,"pressure",it)
>
>
> Otherwise you redefine them each time.
> Please think through what you want to accomplish, and the correct order of
> the steps to get there.
>
>
>
>
>
>
>
>
> --
> 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 6:54 AM, Ancy Thomas <ancyt.thomas at gmail.com> wrote:
>
> > Hello Sir,
> >
> > Thanks for the response.
> >
> > Yes, I want to write the data variable for each level in a loop. The
> program is given below: How should I modify .
> >
> > ************************************************
> > begin
> > datadir = systemfunc("tail -1 fil")
> > FILES = systemfunc ("ls -1 " + datadir + "wrfout_d02* " )
> > numFILES = dimsizes(FILES)
> > ;;***************Pressure levels **********
> >  plevs = (/ 925., 850., 700., 600., 500., 300., 200./)   ; pressure
> levels to plot
> >  nlevels         = dimsizes(plevs)     ; number of pressure levels
> >
> > do ifil = 0,numFILES-1
> >    a = addfile(FILES(ifil)+".nc","r")
> >
> > ; What times and how many time steps are in the data set
> > times  = wrf_user_list_times(a)  ; get times in the file
> >   ntimes = dimsizes(times)       ; number of times in the file
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> >
> > ;Read in constant variables
> >       xlat  = wrf_user_getvar(a, "XLAT",0)
> >       xlon  = wrf_user_getvar(a, "XLONG",0)
> >       hght   = wrf_user_getvar(a, "HGT",0)
> >
> > ; writing data into netcdf format
> >     system("rm -f wrfout.nc")
> >     fw = addfile("wrfout.nc", "c")
> >
> > ; writing the dimensions time, level, lat, lon
> >   fw->xlat = xlat
> >   fw->xlon = xlon
> >
> > ;;*************************
> >   do it = 0,ntimes-1               ; TIME LOOP
> >
> >   do level = 0,nlevels-1                 ; LOOP OVER LEVELS
> >
> >   pressure = plevs(level)
> >
> >   td = wrf_user_getvar(a,"td",it)
> >   p  = wrf_user_getvar(a,"pressure",it)
> >
> >   td_plane(level,:,:) = wrf_user_intrp3d(td,p,"h",pressure,0.,False)
> >
> >  end do ; end of level loop
> >  end do ; end of time loop
> >  end do ; end of files loop
> >  end
> >
> >
> > Thanks,
> > Best regards,
> > Ancy
> >
> >
> >
> > On Thu, Sep 10, 2015 at 4:04 PM, Alessandra Giannini <
> alesall at iri.columbia.edu> wrote:
> >
> > 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
> >
> >
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150910/2fb003f0/attachment.html 


More information about the ncl-talk mailing list