MORE INFORMATION
Intrinsic Functions
The following table lists the FORTRAN intrinsic functions that perform
data type conversions.
Function Description
-------------------------------------------------------------------
CHAR Converts an integer argument to a character (ASCII
equivalent)
CMPLX Converts an integer, real or complex argument to a
COMPLEX*8
DBLE Converts an integer, real or complex argument to a
DOUBLE PRECISION
DCMPLX Converts an integer, real or complex argument to a
COMPLEX*16
DFLOAT Converts an integer, real or complex argument to a
DOUBLE PRECISION
DREAL Converts a COMPLEX*16 argument to a REAL*8
FLOAT Converts an integer argument to a REAL*4
HFIX Converts an integer, real or complex argument to an
INTEGER*2
ICHAR Converts a character argument to an integer (ASCII
value)
IDINT Converts a DOUBLE PRECISION or REAL*8 argument to an
integer
IFIX Converts a REAL*4 argument to an integer
INT Converts an integer, real or complex argument to an
integer
INT1 Converts an integer, real or complex argument to an
INTEGER*1
INT2 Converts an integer, real or complex argument to an
INTEGER*2
INT4 Converts an integer, real or complex argument to an
INTEGER*4
INTC Converts an integer, real or complex argument to a C
language integer
JFIX Converts an integer, real or complex arguments to an
INTEGER*4
REAL Converts an integer, real or complex arguments to a
REAL*4
SNGL Converts a REAL*8 arguments to a REAL*4
For more information about the data conversion intrinsic functions,
see pages 240-241 of the Microsoft FORTRAN "Reference" manual for
versions 5.0 and 5.1
$STORAGE Metacommand
The $STORAGE:n metacommand allocates "n" bytes of memory for all
INTEGER and LOGICAL variables. For example, when an application
specifies the $STORAGE:2 metacommand and declares an INTEGER variable
B, the compiler allocates two bytes for B instead of four. The
$STORAGE metacommand does not affect memory allocation when a
declaration includes an explicit length specification, such as an
INTEGER*2 or INTEGER*4.
For more information about the $STORAGE metacommand, see pages 34 and
308 of the Reference manual for versions 5.0 and 5.1
IMPLICIT Statement
If an application does not explicitly define a data type for a name,
the compiler uses the first letter of the variable or function name to
determine its type. By default, names that begin with the letters I,
J, K, L, M, or N are of type INTEGER. Names that begin with one of the
other letters or with a dollar sign ($) are of type REAL. An
application can use the IMPLICIT statement to override the default
type assignment.
For more information on the IMPLICIT statement, see pages 8 and 181-
182 of the Reference manual for versions 5.0 and 5.1.
Internal READ and WRITE Statements
Reading from an internal file converts ASCII values to numeric,
logical, or character values while writing to an internal file
converts the internal values to ASCII text. For more information on
the internal READ and WRITE statements, see pages 77-78 of the
Reference manual for versions 5.0 and 5.1
The following code example converts a character variable to an
integer.
Sample Code
C Compile options needed: None
CHARACTER*5 NUM
INTEGER TEST
NUM = '12345'
READ(NUM, '(I5)') TEST
WRITE (*, *) TEST
END