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

Substring in DATA implied-do

3 views
Skip to first unread message

John Harper

unread,
Feb 13, 2007, 5:46:47 PM2/13/07
to
I think both the f95 and f2003 standards forbid a program beginning thus:

CHARACTER string*1025
INTEGER i
DATA (string(i:i),i=1,1025)/1025*'?'/

but allow one to begin thus:

TYPE longstr
CHARACTER string*1025
END TYPE longstr
TYPE(longstr)::example
INTEGER i
DATA (example%string(i:i),i=1,1025)/1025*'?'/

because f95 section 5.2.10 R536 and f2003 section 5.2.5 R528 both say

data-i-do-object is array-element
or scalar-structure-component
or data-implied-do

Three f95 compilers (NAG, Sun, g95) agree with me, but was there a good
reason for J3 to allow a substring in a data-implied-do only if it's a
structure component?

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john....@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045

Dick Hendrickson

unread,
Feb 13, 2007, 7:15:19 PM2/13/07
to
John Harper wrote:
> I think both the f95 and f2003 standards forbid a program beginning thus:
>
> CHARACTER string*1025
> INTEGER i
> DATA (string(i:i),i=1,1025)/1025*'?'/
>
> but allow one to begin thus:
>
> TYPE longstr
> CHARACTER string*1025
> END TYPE longstr
> TYPE(longstr)::example
> INTEGER i
> DATA (example%string(i:i),i=1,1025)/1025*'?'/
>
> because f95 section 5.2.10 R536 and f2003 section 5.2.5 R528 both say
>
> data-i-do-object is array-element
> or scalar-structure-component
> or data-implied-do
>
> Three f95 compilers (NAG, Sun, g95) agree with me, but was there a good
> reason for J3 to allow a substring in a data-implied-do only if it's a
> structure component?
>
Interesting that the compilers agree with you. The F2003 standard has
a constraint
"C560 (R528) The scalar-structure-component shall contain at least one
part-ref that contains a subscript-list."

I'd have to look more, but I'd think that makes your last example
wrong, since there's no subscript list. When you tried this, did
you have all of the non-standard warnings enabled?

Dick Hendrickson

glen herrmannsfeldt

unread,
Feb 13, 2007, 7:44:49 PM2/13/07
to
Dick Hendrickson wrote:

> John Harper wrote:

(snip)

>> TYPE longstr
>> CHARACTER string*1025
>> END TYPE longstr
>> TYPE(longstr)::example
>> INTEGER i
>> DATA (example%string(i:i),i=1,1025)/1025*'?'/
>>
>> because f95 section 5.2.10 R536 and f2003 section 5.2.5 R528 both say
>>
>> data-i-do-object is array-element
>> or scalar-structure-component
>> or data-implied-do
>>
>> Three f95 compilers (NAG, Sun, g95) agree with me, but was there a good
>> reason for J3 to allow a substring in a data-implied-do only if it's a
>> structure component?
>
> Interesting that the compilers agree with you. The F2003 standard has
> a constraint
> "C560 (R528) The scalar-structure-component shall contain at least one
> part-ref that contains a subscript-list."

(snip)

So:

CHARACTER*1025 string(1)
INTEGER i
DATA (string(1)(i:i),i=1,1025)/1025*'?'/

should also work?

How about

CHARACTER*1025 string=repeat('?',1025)

-- glen

John Harper

unread,
Feb 13, 2007, 11:00:11 PM2/13/07
to
In article <rwsAh.37363$2m6....@bgtnsc05-news.ops.worldnet.att.net>,

Dick Hendrickson <dick.hen...@att.net> wrote:
>John Harper wrote:
>> I think both the f95 and f2003 standards forbid a program beginning thus:
>>
>> CHARACTER string*1025
>> INTEGER i
>> DATA (string(i:i),i=1,1025)/1025*'?'/
>>
>> but allow one to begin thus:
>>
>> TYPE longstr
>> CHARACTER string*1025
>> END TYPE longstr
>> TYPE(longstr)::example
>> INTEGER i
>> DATA (example%string(i:i),i=1,1025)/1025*'?'/
>>
...

>> Three f95 compilers (NAG, Sun, g95) agree with me
...

>>
>Interesting that the compilers agree with you. The F2003 standard has
>a constraint
>"C560 (R528) The scalar-structure-component shall contain at least one
>part-ref that contains a subscript-list."
>
>I'd have to look more, but I'd think that makes your last example
>wrong, since there's no subscript list.

That constraint isn't in f95, so the second example would seem to be
good f95 but bad f2003.


>When you tried this,
>did you have all of the non-standard warnings enabled?

I compiled each twice. Once with no options set and once with these:
with g95: -std=f95 -v -freal=nan -finteger=-1234567890 -fbounds-check
with Sun: -ansi -V -C -w4 -ftrap=%all,no%inexact,no%underflow -g
with NAG: -nan -gline -C=all -f77 -version
Same results both ways. All those f95 compilers have implemented some
f2003 features, but C560 can't be among them.

Richard Maine

unread,
Feb 13, 2007, 11:52:56 PM2/13/07
to
John Harper <har...@mcs.vuw.ac.nz> wrote:

> >Interesting that the compilers agree with you. The F2003 standard has
> >a constraint
> >"C560 (R528) The scalar-structure-component shall contain at least one
> >part-ref that contains a subscript-list."
> >
> >I'd have to look more, but I'd think that makes your last example
> >wrong, since there's no subscript list.
>
> That constraint isn't in f95, so the second example would seem to be
> good f95 but bad f2003.

That would be surprising and presumably unintentional if true, since it
isn't listed as an incompatibility. Have you checked the f95 corrigenda?

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain

Lane Straatman

unread,
Feb 14, 2007, 12:39:15 AM2/14/07
to

"Dick Hendrickson" <dick.hen...@att.net> wrote in message
news:rwsAh.37363$2m6....@bgtnsc05-news.ops.worldnet.att.net...
This looks like something lifted directly from the standard. What do the
C560 and the R528 refer to? LS


Richard Maine

unread,
Feb 14, 2007, 1:55:44 AM2/14/07
to
Lane Straatman <inv...@invalid.net> wrote:

> "Dick Hendrickson" <dick.hen...@att.net> wrote in message
> news:rwsAh.37363$2m6....@bgtnsc05-news.ops.worldnet.att.net...

> > The F2003 standard has a constraint


> > "C560 (R528) The scalar-structure-component shall contain at least one
> > part-ref that contains a subscript-list."

> This looks like something lifted directly from the standard.

Yes.

> What do the C560 and the R528 refer to?

C560 is the constraint number for this constraint. (It is the 60th
constraint in clause 5). The R528 is the syntax rule to which teh
constraint applies (The 28th rule of clause 5). The numbers make citing
them far simpler.

Of course, if you aren't looking at a copy of the standard, none of that
would make any sense. But then since it is a question about a fine point
of the exact wording of the standard, the whole thing wont make any
sense anyway unless you are looking at a copy of the standard.

Dick Hendrickson

unread,
Feb 14, 2007, 10:58:50 AM2/14/07
to

Yes it is, it's just in a somewhat different spot and the rule
number it applies to is different, so it's harder to find.
It's the 4th constraint from the top on page 62.

Dick Hendrickson

John Harper

unread,
Feb 14, 2007, 3:23:14 PM2/14/07
to
In article <_kGAh.959$5j1...@bgtnsc04-news.ops.worldnet.att.net>,

Dick Hendrickson <dick.hen...@att.net> wrote:
>John Harper wrote:
>> In article <rwsAh.37363$2m6....@bgtnsc05-news.ops.worldnet.att.net>,
>> Dick Hendrickson <dick.hen...@att.net> wrote:
>>> John Harper wrote:
>>>
>>>> TYPE longstr
>>>> CHARACTER string*1025
>>>> END TYPE longstr
>>>> TYPE(longstr)::example
>>>> INTEGER i
>>>> DATA (example%string(i:i),i=1,1025)/1025*'?'/

[and claimed that the above was good f95]


>>>> Three f95 compilers (NAG, Sun, g95) agree with me
>> ...
>>> Interesting that the compilers agree with you. The F2003 standard has
>>> a constraint
>>> "C560 (R528) The scalar-structure-component shall contain at least one
>>> part-ref that contains a subscript-list."
>>

>> That constraint isn't in f95, so the second example would seem to be
>> good f95 but bad f2003.
>>
>
>Yes it is, it's just in a somewhat different spot and the rule
>number it applies to is different, so it's harder to find.
>It's the 4th constraint from the top on page 62.

Apologies, and thank you! I had indeed failed to find what's there.
The program is both bad f95 and bad f2003. As the 3 compilers all
appear to violate an f95 constraint, I shall send bug reports.

0 new messages