Hi Ron. While it's true that formatted I/O in Fortran has a higher
processing cost than in some other languages, it's no worse than the
stream I/O native to languages like C and BASIC when they were brought
to the mainframe world.
Certainly when working with a Hercules environment, you probably don't
need to worry much about this, as the differences are very slight in
the overall picture. Even in a real mainframe, we normally used
Fortran for tasks that were compute intensive, with lots of math and
only a little output. Things like statistics or numerical integration
were done (and still are) in Fortran.
If you really want to dig into this issue, you can try running several
versions of your code with different I/O algorithms. Make sure you
have enough data so that the program doesn't just complete in a
fraction of a second. Then you can look at the step analytics that
print out in the job log after the JCL. Compare the different methods
and see what does best.
Your coding approach seems about as good as any to me. However, you
can try other choices. In the G and H compilers, you can use "grouped"
formats. These let you nest format specifications in parenthetical
groups that are repeated, to produce output that is formatted over
several lines or even pages with just one FORMAT statement. There are
restrictions on the depth of nesting, but I know you can get down to
at least two levels of parentheses, with various repeats on each
group.
If I remember correctly, the "cost" of formatted I/O is connected not
with the amount of data, but with the number of times you issue a
WRITE or READ. So grouping data and performing a single output for
multiple values is a good approach.
Another approach would be to use unformatted I/O, and write your
values out to a temporary file. Read that file back in with another
language that does more efficient I/O and do your printing at that
time. So Fortran does the calculations and writes the numbers to a
tape or temp file, which you pass to a second step written in COBOL or
PL/I that formats the report.
The description of grouped format statements is in the original IBM
OS/360 Fortran manuals, along with much detailed discussion of I/O
options and costs. Have a look here:
http://bitsavers.org/pdf/ibm/360/fortran/
I have some additional manuals from the era, but when I tried to
submit copies, they seemed to think it was "duplicate" data or
something. In general, start with the programmer's guides (PG) for
this sort of thing. If you're really after fine tuning, the H compiler
is capable of optimizing some elements for you. Note that neither G
nor H is anything like the current Fortran standards, though. Those
who use Fortran regularly on modern equipment are almost certainly
using compilers built to the Fortran-90 or Fortran-95 standards, which
are light years beyond the Fortran IV represented by the OS/360
software.
--Gary