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.

## Prototype

```load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  ; This library is automatically loaded
; from NCL V6.2.0 onward.
; No need for user to explicitly load.

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

return_val [dimsizes(z)] :  float or double
```

## Arguments

z

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). Missing values are allowed.

lat

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

lon

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

cyclic

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.

opt

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.

## Examples

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.

```

T_grad_lat  = gradLatLon[0]    ; for clarity; explicitly extract variables from returned 'list'

; replace the generic attributes with more specific attributes

```

Example 2

Given a scalar array SST on a global rectilinear grid, compute the latitudinal and longitudinal derivatives. The returned variable contains two components: [0]=meridional; [1] zonal. Here, the SST have missing values over land.

```

SS_grad_lat  = gradLatLon[0]    ; for clarity; explicitly extract variables from returned 'list'