[ Pobierz całość w formacie PDF ]

Regardless of the specified sta, scratch files, when closed, are always deleted.
Execution of a CLOSE statement specifying a unit that does not exist, or a unit
that has no file connected to it, has no effect.
106 FORTRAN 77 Reference Manual
4
Execution of a CLOSE statement specifying a unit zero (standard error) is not
allowed, but you can reopen it to some other file.
The unit or file disconnected by the execution of a CLOSE statement can be
connected again to the same, or a different, file or unit.
Examples
Example 1: Close and keep:
CLOSE ( 2, STATUS='KEEP')
Example 2: Close and delete:
CLOSE ( 2, STATUS='DELETE', IOSTAT=I )
Example 3: Close and delete a scratch file even though the status is KEEP:
OPEN ( 2, STATUS='SCRATCH')
&
CLOSE ( 2, STATUS='KEEP', IOSTAT=I )
Statements 107
4
4.11 COMMON
The COMMON statement defines a block of main memory storage so that
different program units can share the same data without using arguments.
Syntax
COMMON [/[ cb ]/] nlist [[,]/[ cb ] / nlist ] &
cb Common block name
nlist List of variable names, array names, and array declarators
Description
If the common block name is omitted, then blank common block is assumed.
Any common block name including blank common can appear more than once
in COMMON statements in the same program unit. The list nlist following each
successive appearance of the same common block name is treated as a
continuation of the list for that common block name.
The size of a common block is the sum of the sizes of all the entities in the
common block, plus space for alignment.
Within a program, all common blocks in different program units that have the
same name must be of the same size. However, blank common blocks within a
program are not required to be of the same size.
Restrictions
Formal argument names and function names cannot appear in a COMMON
statement.
An EQUIVALENCE statement must not cause the storage sequences of two
different common blocks in the same program unit to be associated. See
Example 2.
An EQUIVALENCE statement must not cause a common block to be extended
on the left-hand side. See Example 4.
108 FORTRAN 77 Reference Manual
4
Examples
Example 1: Unlabeled common and labeled common:
DIMENSION V(100)
COMMON V, M
COMMON / LIMITS / I, J
&
In the above example,V andM are in the unlabeled common block;I andJ are
defined in the named common block, LIMITS.
Example 2: You cannot associate storage of two different common blocks in the
same program unit:
COMMON /X/ A
COMMON /Y/ B
EQUIVALENCE ( A, B) ! ! Not allowed
Example 3: An EQUIVALENCE statement can extend a common block on the
right-hand side:
DIMENSION A(5)
COMMON /X/ B
EQUIVALENCE ( B, A)
Example 4: AnEQUIVALENCE statement must not cause a common block to be
extended on the left-hand side:
COMMON /X/ A
REAL B(2)
EQUIVALENCE ( A, B(2)) ! ! Not allowed
Statements 109
4
4.12 COMPLEX
The COMPLEX statement specifies the type of a symbolic constant, variable,
array, function, or dummy function to be complex, optionally specifies array
dimensions and size, and initializes with values.
Syntax
COMPLEX [*len[,]] v [* len [/c/]] [, v [* len [/c/]] &
v Name of a symbolic constant, variable, array, array declarator, function, or
dummy function
len Either 8, 16, or 32, the length in bytes of the symbolic constant, variable, array
element, or function (32 is SPARC only)
c List of constants for the immediately preceding name
Description
The declarations can be: COMPLEX, COMPLEX*8, COMPLEX*16, or
COMPLEX*32.
COMPLEX
For a declaration such as COMPLEX W, the variable W is usually two REAL*4
elements contiguous in memory, if no size options are set, interpreted as a
complex number. Details are in  Default Size, the next subsection.
COMPLEX*8
For a declaration such as COMPLEX*8 W, the variable W is always two REAL*4
elements contiguous in memory, interpreted as a complex number.
COMPLEX*16
For a declaration such as COMPLEX*16 W, W is always two REAL*8 elements
contiguous in memory, interpreted as a double-width complex number.
110 FORTRAN 77 Reference Manual
4
COMPLEX*32
(SPARC only) For a declaration such as COMPLEX*32 W, the variable W is
always two REAL*16 elements contiguous in memory, interpreted as a
quadruple-width complex number.
Default Size
If you specify the size as 8, 16, or 32,COMPLEX*8,COMPLEX*16,COMPLEX*32,
you get what you specify; if you do not specify the size, you get the default
size. (*32 is for SPARC only.)
The default size, for a declaration such as COMPLEX Z, depends on  r8:
" If the r8 option is on thef77 command line, then the compiler allocates 16
bytes, and does 16-byte arithmetic.
If  r8 is not on the command line, the compiler allocates 8 bytes.
Similarly, for a declaration such as DOUBLE COMPLEX Z, the default size
depends on the  r8 option.
" If  r8 or -dbl is on the f77 command line, then the compiler allocates 32
bytes, and does 32-byte arithmetic (SPARC only).
If  r8 or -dbl is not on the command line, the compiler allocates 16 bytes.
" If you put both  i2 and  r8 on the f77 command line, the results are
unpredictable.
Specifying the size is nonstandard.
There is a double-complex version of each complex built-in function. Generally,
the specific function names begin with Z or CD instead of C, except for the two
functions DIMAG and DREAL, which return a real value.
There are specific complex functions for quad precision (SPARC only). In
general, where there is a specific REAL a corresponding COMPLEX with a C
prefix, and a corresponding COMPLEX DOUBLE with a CD prefix, there is also a
quad-precision COMPLEX function with a CQ prefix. Examples are: SIN(),
CSIN(), CDSIN(), CQSIN().
Statements 111
4
Examples
Example 1: Complex scalars. Styles. Each of these statements is equivalent to
the others. (Don t use all three statements in the same program unit you
cannot declare anything more than once in the same program unit.)
COMPLEX U, V
COMPLEX*8 U, V
COMPLEX U*8, V*8 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wrobelek.opx.pl
  •