forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error in list-directed read

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1681

PostPosted: Wed May 04, 2022 3:43 pm    Post subject: Error in list-directed read Reply with quote

I wrote the following test program to understand some properties of list-directed input. The FTN95 compiler happily processed the program (as did some other compilers), but the output is lacking the 's' letter at the very end, which was displayed when other compilers were used.

Code:
program LDInput
implicit none
integer, parameter :: NStates = 4
character(13) State(NStates)
integer i
character(37) :: Line = 'Florida,Texas,Tennessee,Massachusetts'
! Fortran 2018 Standard, 12.4:
! Reading and writing records shall be accomplished only by
! sequential access formatted data transfer statements
read(Line,*)State  ! list-directed read
print 10,(i,state(i),i=1,NStates)
10 format(i2,2x,A13)
end program


The output:

Code:
 1  Florida
 2  Texas
 3  Tennessee
 4  Massachusett


Running the program in SDBG64 revealed that STATE(4) was 'Massachusett ' rather than 'Massachusetts' after the READ statement had been executed.


Last edited by mecej4 on Thu May 05, 2022 9:10 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7261
Location: Salford, UK

PostPosted: Thu May 05, 2022 7:37 am    Post subject: Reply with quote

mecej4

Thank you for the feedback.

It appears that Line needs to be character(38) for it to work.

I am not sure if this should be classified as a "bug" or if it is allowed because list-directed input is compiler dependent.

I will make a note that it needs investigating.


Last edited by PaulLaidler on Thu May 05, 2022 10:18 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1681

PostPosted: Thu May 05, 2022 10:12 am    Post subject: Reply with quote

Paul, a "processor", i.e., a compiler, is allowed more freedom of choice in the standard for list-directed output than list-directed input, it seems to me.

Section 10.8.1 of F95 says, in the part for the case when the next effective item of the input record is of type character:

"The end of the record does not cause a blank or any other character to become part of the character sequence."

The subsequent paragraph of the standard lays out the circumstances where the input character sequence, corresponding to an I/O list item of type character, need not be quoted. My example code satisfies all the five conditions for it to become permissible for quotes to be omitted in the input record.

Thanks.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7261
Location: Salford, UK

PostPosted: Thu May 05, 2022 10:24 am    Post subject: Reply with quote

mecej4

Thanks for the information. I have found the point at which the failure occurs.

At the moment I don't know if a simple fix (>= changed to >) will cause problems elsewhere.
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1681

PostPosted: Thu May 05, 2022 12:17 pm    Post subject: Reply with quote

Paul,

This can be a low priority issue. I found that FTN77 has the same behavior, so users have not been troubled by the bug for years!

FTN77 gave the warning:

WARNING - The use of list-directed formatting with an internal file is a Fortran 77 extension
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7261
Location: Salford, UK

PostPosted: Fri May 06, 2022 8:55 am    Post subject: Reply with quote

mecej4

The current IO code (written in C) was transcribed from Fortran 77 code that was used in the MS-DOS FTN77 and may have been written for the original ICL 1900 FTN77. So this behaviour could date back to the late 70's or early 80's. See https://www.silverfrost.com/default.aspx?id=53.
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1681

PostPosted: Fri May 06, 2022 2:11 pm    Post subject: Reply with quote

Oh my, that's quite a trip down memory lane!

I read that IBM sold some models of their 360 equipped with microcode for emulating ICL computers to customers who were facing delays in deliveries of ICL models that they wanted.

https://books.google.com/books?id=zMHIrgW7744C&pg=PA690#v=onepage&q&f=false

Given that, could the code in question still be running on some IBMs as well as ICLs somewhere? (I don't know if George and the Salford F77 compiler ran on the ICL 1900 series)
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 507
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri May 06, 2022 10:33 pm    Post subject: Reply with quote

I recently saw an ICL 1900 running in the plant control centre at a steelworks in South Wales. Not as old as some of the electrical equipment on that site which dates back to the 1950s.
Back to top
View user's profile Send private message Visit poster's website
Robert



Joined: 29 Nov 2006
Posts: 406
Location: Manchester

PostPosted: Sat May 07, 2022 10:55 am    Post subject: Reply with quote

It was actually running and controlling things?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group