NCL Home > Documentation > Functions > Array query

dimsizes

Returns the dimension sizes of the input variable.

Prototype

	function dimsizes (
		data       
	)

	return_val [*] :  integer

Arguments

data

Any type of data array of any dimensionality.

Return value

An integer array of the same length as the number of dimensions of data.

Description

The dimsizes function returns an integer array of dimension sizes for the parameter data. Each index in the array corresponds to the dimension number of the same value.

Examples

Example 1

  x = (/ (/1,2,3/), (/4,5,6/) /)
  print(dimsizes(x))          ; should be (/2,3/)

Example 2

You can use dimsizes to return the rank (that is, the number of dimensions) of a variable:

  x = new((/20,10,30,10,10/),float)
  rank = dimsizes(dimsizes(x))       ; rank should be 5

Example 3

Assume x is a 4D array dimensioned ntim x klev x nlat x mlon. You can use dimsizes to assign the dimension sizes to individual variables:

  dsizes_x = dimsizes(x)
  ntim     = dsizes_x(0)
  klev     = dsizes_x(1)
  nlat     = dsizes_x(2)
  mlon     = dsizes_x(3)