The original program reads a user defined "run-time" format from 5
consecutive 72 column cards into an array called FMT. It pre-dates
character variables.
MSF 3.31 does not allow an array to be used as a format string.
1 CHARACTER*72 FMT(5)
2
3 OPEN(10,FILE='FMT.TXT')
4 READ(10,'(A)') FMT
5
6 WRITE(*,FMT)
***** Error 836 -- array reference not allowed
7 END
However, this works for the WRITE statement
WRITE(*, FMT(1)(1:360) )
even though the access is "out-of-bounds".
Later I discovered that an alternate form compiled and ran:
WRITE(*, FMT(1:360) )
Note that this is NOT an array slice. It's an alias for a single very
long character string.
At first I was excited. Perhaps I had found the first reported bug in
this compiler? Now I'm not certain.
-- e
Elliot's discovery, sent to me, made life easier in the re-writing of
the BMD programs.
Being Fortran IV for the IBM7090 and someimes for the IBM360, these
programs not only don't open any files explicitly, they were later
converted for PDP-20 and used 18A4 formats to read one punched card
format control into real storage units as a remote format statement.
And of course they take the necessary trouble to avoid rewinding a
card reader.
All I've really had to take out is BCD code processing of alternative
data sources.
.
[snip]
>
> Elliot's discovery, sent to me, made life easier in the re-writing of
> the BMD programs.
>
Which form did you decide to use, and how portable do you want to make it ?
Three choices -
WRITE(*,FMT)
WRITE(*, FMT(1)(1:360) )
WRITE(*, FMT(1:360) )
I tossed all three forms at the various compilers I have on Win XP.
MS-Fortran 3.31 does not like the first form, but accepts the second two.
g77 warns on the second form, but produces a working executable. It will not
accept the third form
gfortran gives error on second form, and generates a warning and then ICE's on
third form.
g95 generates warning on third form, but produces an executabe that seems to
work using all three forms.
PGI Fortran (pgf95) ICE's on third form, but accepts first two.
I chose to use version (2), where FMT(1) is the first string of an
array of strings.
(1) is usually bad; because it's against the wording of several
manuals that it must be a character string and not an array of
characters
(3) is not morally justifiable (you shouldn't be able to get away with
it...)