Re: conditional statements errors

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 20 2010 - 06:45:10 MDT

The error message tells you exactly what is wrong.

"Conditional statements (if and do while) require
  SCALAR logical values"

TT is an array ... not a scalar

Use the 'where' construct

http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

   TT = where(TT.lt.49, 0.0, TT)

On 7/20/10 6:38 AM, Sahidul wrote:
> Dear NCL help,
>
> I am trying to calculate TT index which is showing following errors: In
> the below, my script is also shown.
>
> fatal:Conditional statements (if and do while) require SCALAR logical
> values, see all and any functions
> fatal:Execute: Error occurred at or near line [ where line is: if (TT
> .lt. 49) ]
>
> ;;;========================================
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
>
> datadir = "/WRF/output/2010062200/"
> FILES = systemfunc ("ls -1 " + datadir + "wrfout_d02* " )
> numFILES = dimsizes(FILES)
>
> res = True
> res@MainTitle = "TT index Variation"
>
> opts = res
> opts@cnFillOn = True
> pltres = True
> mpres = True
> mpres@mpNationalLineThicknessF = 1.5
> mpres@mpNationalLineColor = "black"
> mpres@mpGeophysicalLineColor = "black"
> mpres@mpGeophysicalLineThicknessF = 1.5
>
> do ifil = 0,numFILES-1
> a = addfile(FILES(ifil)+".nc","r")
>
> times = wrf_user_list_times(a) ; get times in the file
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> day = systemfunc("echo "+times +"|cut -c9-10")
> yr = systemfunc("echo "+times +"|cut -c1-4")
> mon = systemfunc("date '+%b'|tr [a-z] [A-Z]")
> hr = systemfunc("echo "+times +"|cut -c12-13")
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; First get the variables we will need
> tc = wrf_user_getvar(a,"tc",0)
> td = wrf_user_getvar(a,"td",0)
> p = wrf_user_getvar(a,"pressure",0) ; 3D U at mass points
> ;;;=======================================
> tc_850 = wrf_user_intrp3d(tc,p,"h",850.,0.,False)
> td_850 = wrf_user_intrp3d(td,p,"h",850.,0.,False)
> tc_500 = wrf_user_intrp3d(tc,p,"h",500.,0.,False)
>
> ;;;Calculation TT index and condition
>
> TT = tc_850 + td_850 - 2*tc_500
>
> if(TT .lt. 49.) then
> TT = 0.
> else
> TT = TT
> end if
>
> wks = gsn_open_wks("ps","tt_surface_"+day+mon+yr+"_"+hr+"Z")
> contour_tt = wrf_contour(a,wks,TT,opts)
> plot = wrf_map_overlays(a,wks,(/contour_tt/),pltres,mpres)
>
> end do
> end
> ;;;=========================================
>
> Kindly help me to solve this.
>
> Thanking you,
>
> Sahidul
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 20 06:45:15 2010

This archive was generated by hypermail 2.1.8 : Wed Jul 28 2010 - 10:42:06 MDT