DIMENSION
Statement
A
FORTRAN
Problem
44
the
exponent field.
The
start
of
an
exponent field
must
be
marked
by
an
E,
or
if
that
is omitted,
by
a +
or
-,
but
not
a blank. Thus, E2, E02,
+
2,
+ 02, E02,
and
E + 02
are
all permissible exponent fields,
and
must
always
be
right-justified.
Whichever
of these forms you use,
it
is
sug-
gested
that
you
be
consistent
in
using
the
same one.
Whenever
you
use subscripted variables
in
your
program, you
must
provide
the
processor
with
the
following information:
l.
Which
variables
(of
all
the
variables you
may
have
used
in
your
pro-
gram)
are
subscripted.
2.
Whether
your
subscripted variables
(arrays)
are
one- or two-dimensional.
3.
The
number
of elements
in
each dimension of
the
array.
The
DIMENSION
statement
provides information to
the
processor necessary
for
the
allocation of storage in
the
object
program
for
the
elements
of
arrays of
quantities.
One
DIMENSION
statement
may
be
used
to dimension any
number
of
arrays, as long as
the
entire
DIMENSION
statement
does
not
exceed
the
length of
a
statement
(72
characters).
Format
Examples:
"DIMENSION
v( d),
v(
d,d),
v(
d)" .
..
for one-
and
two- di-
mensional arrays.
where each
v
is
the
name
of a variable, followed
by
paren-
theses enclosing one or more constants, representing
the
number
of elements in
each
dimension of
the
array.
The
vs
must
be
separated
from each other
by
commas.
The
constants
must
be
unsigned
and
in
fixed
point
mode.
DIMENSION
HRS
(12)
DIMENSION
A(
10),
B(
10,5)
Every
variable which appears
in
the
program
in
subscripted form
must
appear
in
a
DIMENSION
statement,
and
the
DIMENSION
statement
must
precede
the
first
appearance
of
the
variable.
When
the
object program
is
processed,
the
number
of elements
in
an array
must
not
be
larger
than
the
number
specified
in
the
DIMENSION
statement.
In
the
first example shown,
the
variable,
HRS,
is
an
array
consisting of 12 elements,
and
the
processor will set aside twelve 10-position
fields of storage
(this
is, a floating
point
variable - 8 for mantissa
and
2 for char-
acteristic).
In
the
second example,
the
variable, B, represents a two-dimensional
array
that
will consist of 10 rows
with
5 columns
in
each row.
The
processor will
set aside fifty
(10 x
5)
10-position fields
in
which
to store
the
elements of
the
array
B.
You
may
include
both
fixed
point
and
floating point variables in
the
same
DIMENSION
statement.
The
DIMENSION
statement
does not create instructions in
your object program; its function is merely to supply information to the processor.
The
problem
contained in this section is
intended
as a guide for developing your
first
FORTRAN
problem.
Rather
than
try to show
the
power
of
FORTRAN,
a simple,
uncomplicated
problem
was chosen.
It
indicates
how
a problem is developed,
how
it
is
written
on
the
coding form,
and
how
it
is
documented
as
it
is processed
at
compile time
and
object time.