In NCL, basic data types are all of the standard types found in nearly all programming languages. Types classified as numeric types support all of the algebraic functions available in NCL (see Expressions). The following is a list of the basic numeric types currently supported; they are listed by their keywords, default size for most systems, and valid numerical ranges:
CAUTION: Currently, arithmetic overflow and underflow are not reported as errors to the user. Assigment of out-of-range values may cause errors.
double 64bits +/- ( 2.22507e-308 ) to (8.98846e+307) float 32bits +/- ( 1.175494e-38 ) to (1.701411e+38) long 32bits +/- ( 2.147483e+09 ) integer 32bits +/- ( 2.147483e+09 ) short 16bits +/- ( 32767 ) byte 8bits ( 0 ) - ( 255 )
The graphic type is a reference to an instance of an HLU object. The file type is a reference to a disk file. The logical type is generated from relational expressions. Logical values are either True or False. Graphic values are returned by the create statement, and file values are returned by the addfile intrinsic function.
string N/A character 8bits graphic N/A file N/A logical N/A
There are many times that types must be converted from one basic data type to another. In many cases, this coercion occurs automatically. For example, when a float value is multiplied by an integer value, the integer value must be converted to a float value before the multiplication can occur. The following table lists the conversion possibilities for all of the basic types. If a coercion to a common type doesn't exist for both sides of an expression, then a type mismatch error is generated.
Type Coercible to
character string
short character string integer long logical float double
integer string long logical float double
long logical string float double
float logical string double
double logical string
A special set of functions exists for forcing the coercion in the reverse direction. For example, the function doubletoint can be used to convert a double precision number into an integer. This operation will cause the decimal portion to be truncated, and information will be lost. See NCL functions and procedures for other similar functions.
a = new((/5,6,7/),float)
The following is an example of how to assign a specific missing value.
a = new((/5,6,7/),float,-1e12)
File data types are created differently. Files are only created by the intrinsic function addfile. Arrays of the graphic type can be created with new, but none of the elements of the array will actually reference an existing HLU object. Each element will contain a missing value.
In addition to new, there are ways of entering data manually. Currently, there are four types of literal values. Floating point numbers must be entered with a decimal point. The following show creation of data using literal floating point values:
a = 2. a = 1.2 a = (/ 1., 2., 3. /)
Integer values are specified without the decimal point:
a = 2 a = (/ 1, 2, 3 /)String values are specified as characters enclosed in double quotes ("):
a = "NCAR Graphics"
NOTE: There is currently no way to specify characters literally.
All other types must be forcibly coerced. See above.
NG4 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?