[J3] Is there a simple way to read this?

Malcolm Cohen malcolm at nag-j.co.jp
Thu Apr 10 01:56:25 UTC 2025


Hi Van,

 

A blank is *not* a value separator unless there is no non-blank value separator.

 

Value separation is thus effectively:

 

Zero or more leading blanks followed by a value separator character followed by zero or more trailing blanks.

 

Only in the case where the first nonblank when looking for an item is not a slash (which terminates everything) or a comma (or semicolon with DECIMAL=’COMMA’) is one of the blanks (which might be an EOL) chosen to be the “value separator”.

 

Otherwise one would have the bizarre situation where “1bbb2” [b=blank] would be like “1,,,2”. You know it’s not like that.

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Van Snyder via J3
Sent: Thursday, April 10, 2025 8:19 AM
To: j3 at mailman.j3-fortran.org
Cc: Van Snyder <van.snyder at sbcglobal.net>
Subject: Re: [J3] Is there a simple way to read this?

 

On Thu, 2025-04-10 at 07:46 +0900, Malcolm Cohen via J3 wrote:

End-of-record is a blank for the purposes of list-directed input, which reads additional records as required.

 

If end-of-record is a blank, it's a value separator, and if there are enough value separators to account for all the inputs, an end-of-file condition ought not to be raised.

 

So in my example

 

01:55,-42,922,697,200,160,235,-1,2273,5766,2199,712,6742,0

02:00,,,,,,,,,,,,,

02:05,,,,,,,,,,,,,

02:10,,,,,,,,,,,,,

02:15,,,,,,,,,,,,,

02:20,,,,,,,,,,,,,

02:25,,,,,,,,,,,,,

02:30,,,,,,,,,,,,,

02:35,,,,,,,,,,,,,

02:40,,,,,,,,,,,,,

02:45,,,,,,,,,,,,,

02:50,,,,,,,,,,,,,

02:55,,,,,,,,,,,,,

03:00,-42,920,696,200,160,234,-1,2273,5762,2189,667,6671,0

 

(yes, there are thirteen commas on every line)

 

with lines being read using

 

integer :: input(15)

 

read ( *, '(a)', end=999 ) line

input = 0

read ( line(1:2), *, end=666 ) input(1)

read ( line(4:5), *, end=666 ) input(2)

read ( line(7:), *, end=666 ) input(3:)

 

there should not have been a branch to 666 because there is a character (the blank created by the end-of-record) after the last value separator.

 

Is there a bug if EOF occurs, or do I still not understand this?

 

Treating end-of-file as a “/” would make it hard if not impossible to detect end-of-file in list-directed input. That would be an incompatible change in every compiler. This is not an issue that warrants such an imcompatibility.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250410/eb4bc640/attachment-0001.htm>


More information about the J3 mailing list