Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

large character strings in MS Fortran 3.31

14 views
Skip to first unread message

e p chandler

unread,
Dec 14, 2008, 11:41:40 PM12/14/08
to
Microsoft Fortran 3.31 has a limitation of 127 characters on character
variables. While working on porting the BMD package Terence Wright and
I found an interesting work-around.

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

Terence

unread,
Dec 15, 2008, 4:35:14 PM12/15/08
to

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.
.

user1

unread,
Dec 18, 2008, 9:14:13 AM12/18/08
to
Terence wrote:

[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.

Terence

unread,
Dec 19, 2008, 8:22:33 AM12/19/08
to

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...)

0 new messages