 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  : logical,
opt     : 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  contains the meridional gradient and element  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: =meridional;  zonal.

```

T_grad_lat  = gradLatLon    ; 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: =meridional;  zonal. Here, the SST have missing values over land.

```

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