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

possible implied-do bug?

0 views
Skip to first unread message

Stephen Kenkel

unread,
Jun 24, 1986, 12:23:51 PM6/24/86
to
The following program compiles under VMS fortran, but not
f77:

dimension l(10),m(10),n(10)
write (*, * ) i,((l(k), m(k), n (k)), k=1,10)
end

This version works:

dimension l(10),m(10),n(10)
write (*, * ) i,(l(k), m(k), n (k), k=1,10)
end

The extra parenthesis around the items in the implied do list
appears to be causing trouble. Is this a bug, or is the compiler
in compliance with the standard?

Thanks.

Andrew Koenig

unread,
Jun 25, 1986, 8:46:40 AM6/25/86
to

The compiler is in compliance with the standard.

The list of expressions in an implied DO must not be parenthesized.
Otherwise there would be an ambiguity:

write (*,*) ((3.0,4.0), k = 1, n)

Does this print ten alternating repetitions of 3.0 and 4.0,
or is (3.0,4.0) a complex constant?

Steve Dever

unread,
Jun 25, 1986, 4:05:09 PM6/25/86
to
In article <14...@alvin.mcnc.UUCP> ken...@mcnc.UUCP (Stephen Kenkel) writes:
>The following program compiles under VMS fortran, but not
>f77:
>
> dimension l(10),m(10),n(10)
> write (*, * ) i,((l(k), m(k), n (k)), k=1,10)
> end
>

The ANSI FORTRAN standard (section 12.8.2.3) states that an implied DO list
has the form:

(dlist, i = e1, e2 [, e3])

where dlist is an input/output list.
The standard does not allow an extra set of parentheses around
an I/O list in a READ or WRITE statement so the compiler is correct in not
accepting them. This was allowed in the FORTRAN-66 standard but was removed
to eliminate the syntactic conflict with complex constants in a list-directed
output list.

Steve Dever (sun!steved)

st...@jplgodo.uucp

unread,
Jun 26, 1986, 1:27:13 PM6/26/86
to

It looks like f77 is complying with the standard and VMS Fortran has relaxed
the requirements. Quoting from the ANSI standard:

12.8.2.3 Implied-DO List. An implied-DO list if of the form:

( dlist, i = e1, e2 [,e3] )

where: i, e1, e2, and e3 are as specified for the DO statement (11.10)

dlist is an input/output list

.......

12.8.2 Input/Ouput List. .....

An input/output list is a list (2.10) of input/output list items and
implied-DO lists (12.8.2.3). An input/output list item is either an
input list item or an output list item.

.....

12.8.2.2 Output list items. An output list item must be one of the
following:

(1) A variable name
(2) An array element name
(3) A character substring name
(4) An array name
(5) Any other expression except a character expression
involving concatenation of an operand whose length
specification is an asterisk in parentheses unless the
operand is the symbolic name of a constant.

Note that a constant, an expression involving operators or function
references, or an expression enclosed in parentheses may appear as
an output list item but must not appear as an input list item.

2.10 List

A list is a nonempty sequence (2.1) of syntactic entities seperated
by commas. The entities in the list are called list items.


Essentially, the stuff after the ( in an implied-DO list before the indexing
information must be a valid I/O list. The only time parentheses are allowed
in an I/O list is surrounding an expression or surrounding an implied-DO list.
A sequence of things seperated by commas is certainly not a valid Fortran
expression. Since there is no loop index information given, it is not a
valid implied-DO list either. Therefore it is not a valid I/O list item.

Editorial remark:
It has been my experience that VMS Fortran is *very* liberal in what it
will accept as valid Fortran. If you care at all about being portable, get
a copy of the ANSI standard and throw away your vendor's manuals. The other
recommendation I would make is to always use the /STANDARD qualifier when
you compile on a VAX. This should flag most of the non-standard extensions
you are using. I don't know how picky this is on a VAX since all of my
developement work is done on a Ridge but it should help.

--

...smeagol\ Steve Schlaifer
......wlbr->!jplgodo!steve Advance Projects Group, Jet Propulsion Labs
....logico/ 4800 Oak Grove Drive, M/S 156/204
Pasadena, California, 91109
+1 818 354 3171

Cathy

unread,
Jun 30, 1986, 6:48:32 PM6/30/86
to
In article <14...@alvin.mcnc.UUCP> ken...@mcnc.UUCP writes:
>The following program compiles under VMS fortran, but not
>f77:
>
> dimension l(10),m(10),n(10)
> write (*, * ) i,((l(k), m(k), n (k)), k=1,10)
> end
>
>This version works:
>
...

>
>The extra parenthesis around the items in the implied do list
>appears to be causing trouble. Is this a bug, or is the compiler
>in compliance with the standard?
>

The compiler seems to agree with the standard. The syntax is:

io_implied_do_list
: "(" io_list "," id "=" exp "," exp [ "," exp ] ")"
;
io_list
: io_entity ( "," io_entity )*
;

io_entity
: array_variable
| io_implied_do_list
;

The extra bracket would imply an internal io_implied_do_list.

Best wishes,
Cathy

--

- Marxist unite!
- Leaders unite!
- Bad-spellers of the of the world untie!

UUCP: ...!seismo!mcvax!ukc!dcl-cs!cathy
DARPA: cathy%lancs.comp@ucl-cs | Post: University of Lancaster,
JANET: ca...@uk.ac.lancs.comp | Department of Computing,
Phone: +44 524 65201 ext ???? | Bailrigg, Lancaster, LA1 4YR, UK.

0 new messages