4. Embedded QUEL for Fortran : Fortran Variables and Data Types : Variable and Type Declarations : The Integer Data Type
 
Share this page                  
The Integer Data Type
The Fortran compiler allows the default size of integer variables to be either two or four bytes in length, depending on whether the -i2 compiler flag (UNIX), the noi4 qualifier (VMS), or the /integer_size:16 compiler option (Windows) is set.
EQUEL/Fortran also supports this feature by means of the -i2 preprocessor flag. This flag tells the preprocessor to treat the default size of integer variables as two instead of the normal default size of four bytes. For more information on type mapping between Ingres and Fortran data, see Precompiling, Compiling, and Linking an EQUEL Program) .
You can explicitly override the default size when declaring the Fortran variable to the preprocessor. To do so, you must specify a size indicator (*2 or *4) following the integer keyword, as these examples illustrate:
integer*4          bigint 
integer*2          smalli
The preprocessor then treats these variables as a four-byte integer and a two-byte integer, regardless of the default setting.
UNIX: The preprocessor treats the logical data type as an integer data type. A logical variable has a default size of 4 bytes. To override this default size, use a size indicator of 2 or 4. For example:
logical*2 log2
logical*4 log4
logical*1 log1  
VMS: The preprocessor treats byte and logical data types as integer data types. A logical variable has a default size of either two or four bytes, according to whether the -i2 flag has been set. You can override this default size by a size indicator of 1, 2 or 4. For example:
## logical log1*1, log2*2, log4*4  
Windows: The preprocessor treats byte and logical data types as an integer data type. A logical variable has a default size of 4 bytes. To override this default size, use a size indicator of 2 or 4. For example:
## logical*2 log2
## logical*4 log4
## logical*1 log1  
The byte data type has a size of one byte. You cannot override this size.
You can use an integer or byte variable with any numeric-valued object to assign or receive numeric data. For example, you can use such a variable to set a field in a form or to select a column from a database table. This variable can also specify simple numeric objects, such as table field row numbers. You can use a logical variable to assign or receive integer data, although your program must restrict its value to 1 and 0, which map respectively to the Fortran logical values .TRUE. and .FALSE..