Re: center_finite_diff_n for relative vorticity

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sun Dec 19 2010 - 14:44:04 MST

You did not define the variables correctly.

You created the following arrays

> dvdx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
> dudx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)

Then you used

> dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)
                 :
> dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 1)

Where did you preallocate space for dudy??
The error messages told you exactly what the problem is:

> fatal:Undefined identifier: (dudy) is undefined, can't continue
> fatal:Execute: Error occurred at or near line 30 in file tester.ncl
>
> fatal:Variable (dudy) is undefined
> fatal:Execute: Error occurred at or near line 33 in file tester.ncl
>
> fatal:Variable (vor) is undefined

vor is undefined because the dudy is undefined

==

I think waht you want is:

dudy = new ( (/nlat,mlon/), typeof(v), v@_FillValue)

On 12/19/10 12:55 PM, Bold Khan wrote:
> Dear ncl users,
> Could I have some help? I am still learning ncl.
> I am getting confused with using the center_finite_diff_n command to
> calculate relative vorticity (RV) with non-cyclic data.
> I want to calculate (RV) using center_finite_diff_n, instead of just
> resorting to using the uv2vr_cfd command that is available, because I
> want to calculate RV and then shear vorticity separately.
> I am following example 6 at
> http://www.ncl.ucar.edu/Document/Functions/Built-in/center_finite_diff_n.shtml.
>
> 1) Do dv/dx and dvdy need to be in the same loop or can they be
> separate as I have done?
> 2) Since we want to try and avoid do loops in ncl, is there a way not
> to use loops for this calculation
> Any amount of advice, would be greatly appreciated.
> Sincerely,
> Bold
>
>
> [ 02:42:16 ]> ncl tester.ncl
> Copyright (C) 1995-2010 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.2.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> fatal:Undefined identifier: (dudy) is undefined, can't continue
> fatal:Execute: Error occurred at or near line 30 in file tester.ncl
>
> fatal:Variable (dudy) is undefined
> fatal:Execute: Error occurred at or near line 33 in file tester.ncl
>
> fatal:Variable (vor) is undefined
> fatal:Execute: Error occurred at or near line 35 in file tester.ncl
>
> [ 02:48:25 ]>
>
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;;; some contants
> pi = 4.0*atan(1.0)
> radian = pi/180.0
> radius = 6370949.0
> FILEIN = "era_uv.nc"
> ;=========================variables
> a = addfile(FILEIN,"r")
> U=a->U
> u=U(0,{700},:,:)
> V=a->V
> v=V(0,{700},:,:)
>
> lat = a->lat
> lon = a->lon
> nlat = dimsizes(lat)
> mlon = dimsizes(lon)
> dlon = (max(lon)-min(lon))/(mlon-1)
> dlat = (max(lat)-min(lat))/(nlat-1)
> ; Arrays
> dvdx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
> dudx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
> ; loops
> do nl=0,nlat-1
> dX = radius*cos(radian*lat(nl))*dlon
> dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)
> end do
> do ml=0,mlon-1
> dY = radius*radian*dlat
> dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 1)
> end do
> vor = dvdx - dudy
>
> printMinMax(vor,True)
> _______________________________________________
> 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 Sun Dec 19 14:44:10 2010

This archive was generated by hypermail 2.1.8 : Wed Dec 22 2010 - 16:10:23 MST