NCL Website header
NCL Home > Documentation > Functions > Meteorology


Compute the meridional and zonal gradients of a variable on a global or limited area rectilinear grid.

Available in version 6.4.0 and later.


load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

	function grad_latlon_cfd (
		z          : numeric,  ; float, double, integer only
		lat    [*] : numeric,  
		lon    [*] : numeric,  
		cyclic [1] : logical,  
		opt    [1] : logical   

	return_val [dimsizes(z)] :  float or double



Variable of 2-to-4 dimensions. The two rightmost dimensions must ve (...,lat,lon). Some examples: (lat,lon), (time,lat,lon), (lev,lat,lon), (time,lev,lat,lon).


A one-dimensional array containing the latitudes in degrees north. These need not be equally spaced. For example they can be gaussian latitudes.


A one-dimensional array containing the longitudes in degrees east. These must be in increasing order and must be equally spaced.


True: z treated as cyclic in lon and the end values and all the returned values will be calculated via centered differences. False: q NOT treated as cyclic in lon and the end values will use a one-sided difference scheme for the end points. z should not include a cyclic point.


Currently not used. Set to False.

Return value

A variable of type list. It contains two arrays. Element [0] contains the meridional gradient and element [1] contains the zonal gradient. These elements will be the same size and shape as z. The output will be double if z is of type double. If present, meta data will be returned.


See Also

gradsg, gradsf, center_finite_diff_n, advect_variable


A 'worked' example which compares the results between gradients using "spherical harmonics and centered finite differences is available here.

Example 1

Given a scalar array T on a global rectilinear grid, compute the latitudinal and longitudinal derivatives. The returned variable contains two components: [0]=meridional; [1] zonal.

  gradLatLon = grad_latlon_cfd (T, T&lat T&lon, True, False)
  T_grad_lat  = gradLatLon[0]    ; for clarity; explicitly extract variables from returned 'list' 
  T_grad_lon  = gradLatLon[1]

  T_grad_lon@long_name = "longitudinal gradient (derivative)"
  T_grad_lat@long_name = "latitudinal gradient (derivative)"
  T_grad_lat@units     = "K/m"
  T_grad_lon@units     = "K/m"