Intel fortran-80 Laptop User Manual


 
FORTRAN-SO
Programming Guidelines
The next pass
is
a
more
formal description
of
level two, introducing
FORTRAN
statements for English sentences.
Level Three
C INITIALIZE VARIABLES NEEDED FOR TOTALS
DATA TOTEMP, TOTHRS, TOTPAY / 3*0.0/
C OPEN INPUT/OUTPUT FILES,
READ EMPLOYEE RECORD
OPEN
(input
file)
OPEN
(output
file)
10
READ (unit,
20)
EMP, HRS, GRPAY, NETPAY
20
FORMAT
(flist)
C PRINT TOTALS IF NO MORE RECORDS
I
F (no
more
records) TH
EN
WRITE (unit,
40)
TOTEM
P,
TOTH
RS,
TOTPA Y
40
FORMAT (flist)
CLOSE
(input
file)
CLOSE
(output
file)
C OTHERWISE PRINT
EMPLOYEE DATA
AND
UPDATE TOTALS
ELSE
WRITE
(unit, 60) EMP, HRS, GRPAY, NETPAY
60 FORMAT (flist)
TOTEMP
= TOTEMP + 1
TOTH
RS
= TOTH
RS
+ H
RS
TOTPAY = TOTPAY
+GRPAY
C READ NEXT EMPLOYEE RECORD
GOTO
10
ENDIF
END
A
number
of
details remain to be specified,
but
each
of
these levels
is
in some sense
complete
and
can be debugged to the extent
that
it
is
complete. Thus
we
can confirm
the
accuracy
of
the
program's
logic, then
110
interfaces
and
basic calculations,
and
only
at
the
end
concern ourselves with such details as
format
specification.
7.1.4 Final Coding
At
the level
of
detailed code, a
number
of
steps can be
taken
to
simplify writing
and
debugging the
program,
or
to
simplify the task
of
another
programmer
updating the
program
later.
Take
advantage
of
the built-in debugging aids available in the particular
programming
language.
For
example,
PAUSE,
STOP,
and
WRITE
statements
can
be interspersed
throughout
initial
FORTRAN
code to trace
program
execution paths. These
can
be removed in the final version
of
the
program.
Avoid tricky programming.
Code
conservatively!
Concentrate
initially
on
making the
program
work. Beautiful
printouts
can be
produced as a last step.
Concentrate
especially
on
getting the statement syntax correct the first time.
Syntax details
can
be particularly annoying
to
FORTRAN
programmers,
but
initial
effort
in this
area
can save a lot
of
grief in the long
run.
Again, use
comment
lines frequently. Use meaningful labels for variables. Use
blanks
to
improve
program
listing readability.
7-3