📄 ftypes.gml
字号:
.chap *refid=ftypes Names, Data Types and Constants
.*
.if &e'&dohelp eq 1 .do begin
.np
The following sections describe naming rules, data types supported
by &product, and formats for constants.
.do end
.*
.section Symbolic Names
.*
.np
.ix 'symbolic names'
.us Symbolic names
are names that represent variables, arrays, functions, etc.
Names are formed using any of the upper-case letters A-Z and the
digits 0-9, the first of which must be a letter.
Symbolic names are limited to 6 characters in length.
The following are examples of symbolic names.
.millust begin
AMOUNT
AGE
CUST73
.millust end
.np
.xt begin
.ix 'symbolic names' 'dollar sign ($) in'
.ix 'symbolic names' 'underscore (_) in'
.ix 'symbolic names' 'lower case letters in'
.ix 'dollar sign ($)' 'in symbolic names'
.ix 'underscore (_)' 'in symbolic names'
.ix 'lower case letters' 'in symbolic names'
&product extends the allowable characters that can make up a symbolic
name to include the lower-case letters a-z, the dollar sign ($) and the
underscore (_).
Note that the dollar sign and the underscore are treated as letters
and are therefore allowed as the first letter of a symbolic name.
Furthermore, &product allows symbolic names of up to 32 characters.
The following are examples of permissible symbolic names.
.millust begin
Evaluate
$Cheque
ComputeAverage
_device
IO$ERROR
student_total
.millust end
.np
&product makes no distinction between upper and lower case letters.
The following symbolic names are identical.
.millust begin
Account
ACCount
ACCOUNT
.millust end
.xt end
.np
Spaces are allowed in symbolic names and are ignored.
The following symbolic names are identical.
.millust begin
C R E DIT
CRE D I T
.millust end
.np
FORTRAN 77 allows certain keywords such as WRITE to be used as symbolic
names.
.ix 'keywords'
In &product, all
.us keywords
satisfy the requirements of a symbolic name.
A keyword is a sequence of letters that is interpreted in a special
way by &product..
Whether a string of characters is interpreted as a keyword or as a
symbolic name depends on the context in which it is used.
In the following example, the first statement is an assignment
statement assigning the value 2 to the symbolic name
.id DO10I.
The second statement is the beginning of a DO-loop.
.exam begin
DO10I=1
DO10I=1,10
.exam end
.sr nunit = '4 bytes'
.sr cunit = '1 byte'
.*
.section Data Types
.*
.np
There are 6 basic data types in FORTRAN 77; logical, integer, real,
double precision, complex and character.
.xt on
&product provides an additional data type, namely double precision
complex (
.ct
.kw DOUBLE COMPLEX
or
.kw COMPLEX*16
.ct ).
&product also supports the creation of more complex user-defined data
types
using the
.kw STRUCTURE
statement.
.xt off
.np
Each data type can be classified as numeric, logical or character.
Each datum occupies a sequence of storage units.
Numeric data and logical data occupy numeric storage units whereas
character data occupy character storage units.
In &product, a numeric storage unit occupies &nunit and a
character storage unit occupies &cunit..
.np
The following table summarizes all data types supported by &product..
.ix 'data type' summary
.if &e'&dohelp eq 0 .do begin
.cp 22
.* .box on 1 18 26 36
.sr c0=&INDlvl+1
.sr c1=&INDlvl+18
.sr c2=&INDlvl+26
.sr c3=&INDlvl+36
.box on &c0 &c1 &c2 &c3
\ Data Type \ Size \ Standard\
\ \(in bytes) \ FORTRAN\
.box
\ LOGICAL \ 4 \ yes
\ LOGICAL*1 \ 1 \ extension
\ LOGICAL*4 \ 4 \ extension
\ INTEGER \ 4 \ yes
\ INTEGER*1 \ 1 \ extension
\ INTEGER*2 \ 2 \ extension
\ INTEGER*4 \ 4 \ extension
\ REAL \ 4 \ yes
\ REAL*4 \ 4 \ extension
\ REAL*8 \ 8 \ extension
\ DOUBLE PRECISION \ 8 \ yes
\ COMPLEX \ 8 \ yes
\ COMPLEX*8 \ 8 \ extension
\ DOUBLE COMPLEX \ 16 \ extension
\ COMPLEX*16 \ 16 \ extension
\ CHARACTER \ 1 \ yes
\ CHARACTER*n \ n \ yes
.box off
.do end
.el .do begin
.millust begin
+--------------------+-----------+-------------+
| Data Type | Size | Standard |
| |(in bytes) | FORTRAN |
+--------------------+-----------+-------------+
| LOGICAL | 4 | yes |
| LOGICAL*1 | 1 | extension |
| LOGICAL*4 | 4 | extension |
| INTEGER | 4 | yes |
| INTEGER*1 | 1 | extension |
| INTEGER*2 | 2 | extension |
| INTEGER*4 | 4 | extension |
| REAL | 4 | yes |
| REAL*4 | 4 | extension |
| REAL*8 | 8 | extension |
| DOUBLE PRECISION | 8 | yes |
| COMPLEX | 8 | yes |
| COMPLEX*8 | 8 | extension |
| DOUBLE COMPLEX | 16 | extension |
| COMPLEX*16 | 16 | extension |
| CHARACTER | 1 | yes |
| CHARACTER*n | n | yes |
+--------------------+-----------+-------------+
.millust end
.do end
.np
Detailed information on the size and range of values supported by
each of these data types is provided in the User's Guide.
.*
.section Data Type of a Name
.*
.np
A name must only have one data type.
Its type is specified by the appearance of that name in a type
statement.
If a name does not appear in any type statement then an implied type
is assigned to it by the "first letter rule".
A name not appearing in any type statement and beginning with any of
the letters I, J, K, L, M or N is assigned the type integer.
A name not appearing in any type statement and beginning with any other
letter is assigned the type real.
The implied type of a letter can be changed by an
.kw IMPLICIT
statement.
.np
The type associated with a name defines the
type of the data it is to contain.
For example, if A is of type integer, then the storage unit which
A occupies is assumed to contain integer data.
Note that the data type of an array element is the same as the data type
associated with the array name.
.np
The data type of a function name specifies the type of the
result returned by the function when it is referenced.
A name that identifies a specific intrinsic function has type as
specified in the chapter entitled :HDREF refid='fsubp'..
.ix function generic
.ix 'generic function'
A
.us generic function
name has no type associated with it; its type is
determined by the type of its argument(s).
The appearance of a generic function in a type statement is not
sufficient to remove the generic properties of that name.
For example, if SIN
was declared to be of type real, it could still
be called with an argument of type complex.
The type of an external function reference is determined in the same
way as for variables and arrays.
The actual type of the external function is determined implicitly by
its name or explicitly by its appearance in a
.kw FUNCTION
or type statement.
Note that an
.kw IMPLICIT
statement can affect the type of the external function being defined.
.*
.section Constants
.*
.np
.ix constant
A
.us constant
can be one of arithmetic, logical or character.
Each constant has a data type and value associated with it and,
once established in a program, cannot be changed.
Arithmetic constants consist of those constants whose data type is one
of integer, real, double precision, complex or double precision complex.
Logical constants consist of those constants whose data type is logical
and character constants consist of those constants whose data type
is character.
The string of characters representing a constant determines its value
and data type.
The blank character is insignificant for all but character constants.
.beglevel
.*
.section Integer Constants
.*
.np
.ix constant integer
.ix 'integer constant'
An
.us integer constant
is formed by a non-empty string of digits
preceded by an optional sign.
.np
The following are examples of integer constants.
.millust begin
1423
+345
-34565788
.millust end
.*
.section Real Constants
.*
.np
.ix 'simple real constant'
We first define a
.us simple real constant
as follows: an optional sign followed by an integer part
followed by a decimal point followed by a fractional part.
The integer and fractional parts are non-empty strings of digits.
Either can be omitted but not both.
.np
.ix constant real
.ix 'real constant'
A
.us real constant
has one of the following forms.
.autopoint
.point
A simple real constant.
.point
A simple real constant followed by an
.mono E
followed by an optionally signed
integer constant.
.point
An integer constant followed by an
.mono E
followed by an optionally signed integer constant.
.endpoint
.np
.ix exponent
The optionally signed integer constant that follows the
.mono E
is called the
.us exponent.
The value of a real constant that contains an exponent is
the value of the constant preceding the
.mono E
multiplied by the power of ten
determined by the exponent.
.np
The following are examples of real constants.
.millust begin
123.764
.4352344
1423.34E12
+345.E-4
-.4565788E3
2E6
1234.
.millust end
.*
.section Double Precision Constant
.*
.np
.ix constant 'double precision'
.ix 'double precision constant'
A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -