24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Names, Data Types and Constants<br />

The type associated with a name defines the type of the data it is to contain. For example, if A is of type<br />

integer, then the storage unit which A occupies is assumed to contain integer data. Note that the data type<br />

of an array element is the same as the data type associated with the array name.<br />

The data type of a function name specifies the type of the result returned by the function when it is<br />

referenced. A name that identifies a specific intrinsic function has type as specified in the chapter entitled<br />

"Functions and Subroutines" on page 243. A generic function name has no type associated with it; its type<br />

is determined by the type of its argument(s). The appearance of a generic function in a type statement is<br />

not sufficient to remove the generic properties of that name. For example, if SIN was declared to be of type<br />

real, it could still be called with an argument of type complex. The type of an external function reference is<br />

determined in the same way as for variables and arrays. The actual type of the external function is<br />

determined implicitly by its name or explicitly by its appearance in a FUNCTION or type statement. Note<br />

that an IMPLICIT statement can affect the type of the external function being defined.<br />

3.4 Constants<br />

A constant can be one of arithmetic, logical or character. Each constant has a data type and value<br />

associated with it and, once established in a program, cannot be changed. Arithmetic constants consist of<br />

those constants whose data type is one of integer, real, double precision, complex or double precision<br />

complex. Logical constants consist of those constants whose data type is logical and character constants<br />

consist of those constants whose data type is character. The string of characters representing a constant<br />

determines its value and data type. The blank character is insignificant for all but character constants.<br />

3.4.1 Integer Constants<br />

An integer constant is formed by a non-empty string of digits preceded by an optional sign.<br />

The following are examples of integer constants.<br />

1423<br />

+345<br />

-34565788<br />

3.4.2 Real Constants<br />

We first define a simple real constant as follows: an optional sign followed by an integer part followed by<br />

a decimal point followed by a fractional part. The integer and fractional parts are non-empty strings of<br />

digits. Either can be omitted but not both.<br />

A real constant has one of the following forms.<br />

1. A simple real constant.<br />

2. A simple real constant followed by an E followed by an optionally signed integer constant.<br />

3. An integer constant followed by an E followed by an optionally signed integer constant.<br />

The optionally signed integer constant that follows the E is called the exponent. The value of a real<br />

constant that contains an exponent is the value of the constant preceding the E multiplied by the power of<br />

ten determined by the exponent.<br />

The following are examples of real constants.<br />

Constants 153

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!