next up previous 252
Next: Arguments
Up: VAX/VMS
Previous: General

Data Types

There is a simple correspondence between VAX FORTRAN and VAX C numeric variable types. The standard types are given in the upper part of the table below and non-standard extensions in the lower part. These should generally be avoided for reasons of portability. However, they are provided since HDS has corresponding data types.


Table: Corresponding data types for VAX/VMS
type VAX FORTRAN VAX C
INTEGER INTEGER int
REAL REAL float
DOUBLE DOUBLE PRECISION double
LOGICAL LOGICAL int
  CHARACTER*1 char
CHARACTER CHARACTER*n char[n]
BYTE BYTE char
WORD INTEGER*2 short int
UBYTE   unsigned char
UWORD   unsigned short int
POINTER INTEGER unsigned int

Although VAX C defines unsigned data types of unsigned char (range 0 to 255), unsigned short (range 0 to 32767) and unsigned int (range 0 to 232-1), there are no corresponding unsigned data types in FORTRAN. There is also a C type called long int; however in VAX C, this is the same as an int.

The C language does not specify whether variables of type char should be stored as signed or unsigned values. On VMS, they are stored as signed values in the range -128 to 127.

Similarly there is no C data type that corresponds to the FORTRAN data type of COMPLEX. However, since VAX FORTRAN passes all numeric variable by reference, a COMPLEX variable could be passed to a VAX C subprogram where it might be handled as a structure consisting of two variables of type float.

A VAX FORTRAN LOGICAL value can be passed to a VAX C int, but care must be taken over the interpretation of the value since VAX FORTRAN only considers the lower bit of the longword to be significant (0 is false, 1 is true) whereas VAX C treats any numerical value other than 0 as true. When VAX FORTRAN sets a logical value to true, it sets all the bits. This corresponds to a numerical value of minus one.



next up previous 252
Next: Arguments
Up: VAX/VMS
Previous: General

CNF and F77 Mixed Language Programming -- FORTRAN and C
Starlink User Note 209
P.M. Allan
A.J. Chipperfield
R.F. Warren-Smith
19 January 2000
E-mail:ussc@star.rl.ac.uk