FPT and WinFPT Reference Manual - Command-line Commands

### DEFINE KIND

FPT version:

These commands were first implemented in FPT 3.3-h.

Syntax:

 % DEFINE LOGICAL KIND [:] [,] SIZE [:] % DEFINE INTEGER KIND [:] [,] SIZE [:] [,] RANGE [:] % DEFINE REAL KIND [:] [,] SIZE [:] [,] PRECISION [:] [,] EXPONENT [RANGE] [:] % DEFINE COMPLEX KIND [:] [,] SIZE [:] [,] PRECISION [:] [,] EXPONENT [RANGE] [:]

Function:

These commands define the set of numeric kinds available on the target system (Note that the target system is not necessarily the system on which FPT is running).

In each case, the first argument is the kind value and the second is the data size - the number of bytes of storage which an object of the specified kind occupies.

The range of an integer kind is the number of decimal digits which can be represented accurately. For example, a twos complement INTEGER*2 variable can represent values from -32768 to +32767. This corresponds to a kind range of 4. An INTEGER*2 cannot represent all 5 digit decimal numbers.

The precision of a real or complex kind is the number of decimal digits which can always be represented precisely. The exponent range of a real or complex number is the largest exponent, or minus the smallest exponent, supported by the kind, whichever is the smaller. For example, an IEEE single precision floating point number has possible exponent values which support numbers from 10**-37 to 10**37, and therefore an exponent range of 37.

FPT uses these specifications:

• To determine the storage allocation in COMMON blocks, structures, derived types and equivalenced objects when variables are declared by kind instead of by data size.

• To return appropriate values for intrinsic functions such as SELECTED_INT_KIND, SELECTED_REAL_KIND and KIND. These functions are evaluated by FPT wherever possible, so as to allow correct memory allocation.

If the kind defined already exists, the old values are overwritten.

Kinds may be removed from the list of available kinds by the command DELETE KIND.

Where to use these commands:

 Operating system command line Yes Configuration file, config.fsp Yes Specification (FSP) files, *.fsp Yes Interactively, to FPT> prompt: No Interactive command files No Embedded in the Fortran code Yes

Default:

The following kinds are defined by default.

```LOGICAL KIND=1,  SIZE=1
LOGICAL KIND=2,  SIZE=2
LOGICAL KIND=4,  SIZE=4
LOGICAL KIND=8,  SIZE=8

INTEGER KIND=1,  SIZE=1
INTEGER KIND=2,  SIZE=2
INTEGER KIND=4,  SIZE=4
INTEGER KIND=8,  SIZE=8

REAL KIND=4,     SIZE=4
REAL KIND=8,     SIZE=8
REAL KIND=16,    SIZE=16

COMPLEX KIND=4,  SIZE=8
COMPLEX KIND=8,  SIZE=16
COMPLEX KIND=16, SIZE=32
```

The range, precision and exponent range values of the pre-defined kinds are not defined. It is the responsibility of the user to set them up if they will be required.