NCL Home > Documentation > Functions > Spherical harmonic routines

# uv2dvf

Computes the divergence using spherical harmonics given the u and v wind components on a fixed grid.

## Prototype

```	procedure uv2dvf (
u   : numeric,
v   : numeric,
dv  : float or double
)
```

## Arguments

u
v

Wind components (input, arrays with two or more dimensions, rightmost two dimensions must be nlat x nlon)

• input values must be in ascending latitude order
• input array must be on a global grid

dv

Divergence (output, same dimensions as u and v, values will be in ascending latitude order)

## Description

Given wind components u and v, uv2dvf computes the divergence and returns it in the array dv. uv2dvf operates on a fixed grid.

This procedure does not allow for missing data (defined by the _FillValue attribute) to be present. If any missing values are encountered in a particular 2D input grid, then all of the values in the corresponding output grid will be set to the default missing value appropriate to the type of the output.

Note, if the input arrays are not global or contain missing data, then it is recommended that uv2dv_cfd be used.

Note: For the arrays whose rightmost two dimensions are nlat x nlon, the rest of the dimensions (if any) are collectively referred to as N. If the input/output arrays are just two dimensions, then N can either be considered equal to 1 or nothing at all.

Arrays which have dimensions N x nlat x nlon should not include the cyclic (wraparound) points when invoking the procedures and functions which use spherical harmonics (Spherepack).

If the input arrays u and v are on a gaussian grid, uv2dvg should be used. Also, note that uv2dvf is the procedural version of uv2dvF.

## Examples

Example 1

Calculate the divergence from the wind components u,v, and then calculate the divergent wind components. u and v are on a fixed grid.

```begin
nlat  = 90                                       ; dimensions
mlon  = 180
mlon1 = mlon+1
fbfile = "uv300.hs"
; Generic Workstation setup
nrec  = fbinnumrec(fbfile)           ; total number of records in the file
ntim  = nrec/2                       ; number of time steps in dataset

uvmsg = 1e+36

dv    = new ( (/nlat,mlon /), float, uvmsg )  ; divergence
ud    = new ( (/nlat,mlon /), float, uvmsg )
vd    = new ( (/nlat,mlon /), float, uvmsg )

do i = 0,nrec-1,2
month = 1                         ; January
if (i .ge. 2) then
month = 7                     ; July
end if

u    = work(:,0:mlon-1)
v    = work(:,0:mlon-1)

uv2dvf   (u,v,dv)                 ; u,v ==> divergence
dv2uvf   (dv,  ud,vd)             ; dv  ==> divergent  wind components
end do
end
```

## Errors

If jer or ker is equal to:

1 : error in the specification of nlat
2 : error in the specification of nlon
4 : error in the specification of N (jer only)
{"ft_lang_label":"__label__en","ft_lang_prob":0.67915606,"math_prob":0.9752065,"size":2677,"snap":"2021-43-2021-49","text_gpt3_token_len":744,"char_repetition_ratio":0.11597456,"word_repetition_ratio":0.046908315,"special_character_ratio":0.2626074,"punctuation_ratio":0.15313654,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97582,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-24T13:49:48Z\",\"WARC-Record-ID\":\"<urn:uuid:f08e02f4-69d1-4f40-9e01-0abb86a3c7f2>\",\"Content-Length\":\"18773\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:439ef0eb-c706-4283-b804-eadf1067a4e6>\",\"WARC-Concurrent-To\":\"<urn:uuid:0e0cf2a2-7fed-408a-9e96-acab8e45e496>\",\"WARC-IP-Address\":\"128.117.225.48\",\"WARC-Target-URI\":\"https://ncl.ucar.edu/Document/Functions/Built-in/uv2dvf.shtml\",\"WARC-Payload-Digest\":\"sha1:26AR3IWNYWQLJA7JKWKRGYXE5ZV7KGYW\",\"WARC-Block-Digest\":\"sha1:VVWQXE4WQ6VESTL2ZCBKHPZOJHDP7BVG\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585997.77_warc_CC-MAIN-20211024111905-20211024141905-00167.warc.gz\"}"}