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 

List directed input of logical data with repeat factor fails

 
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: 1885

PostPosted: Sat Oct 15, 2016 1:32 pm    Post subject: List directed input of logical data with repeat factor fails Reply with quote

As the following test program illustrates, list-directed input of data works correctly with integer and real data, but fails with logical data when the input data contains items with the r*v (value v, repeat count r) format.
Code:
program ListRead
implicit none
integer i,ijk(5)
logical :: ljk(5)
real :: rjk(5)
character(len=9) :: iolog = 't 2*f 2*t', ioint = '2 2*3 2*5'
character(len=15) :: ioreal = '2.0 2*3.0 2*5.0'
!
read(ioint,*)ijk
write(*,'(1x,I4,2x,I3)')(i,ijk(i),i=1,5)
read(ioreal,*)rjk
write(*,'(1x,I4,2x,F6.1)')(i,rjk(i),i=1,5)
read(iolog,*)ljk
write(*,'(1x,I4,2x,L1)')(i,ljk(i),i=1,5)
end program

The runtime error is "Error 52. Invalid character in field. LISTREAD - in file lio.f90 at line 13 [+02d3]"
The same problem occurs when data is read from a file using list-directed input when the input contains, for example, the following record:

t 2*f 2*t


Last edited by mecej4 on Sat Oct 22, 2016 2:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Oct 15, 2016 1:45 pm    Post subject: Reply with quote

Thank you for the feedback. I have logged this for investigation.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Tue Jan 31, 2017 11:30 am    Post subject: Reply with quote

This has now been fixed for the next release.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Feb 02, 2017 11:10 am    Post subject: Reply with quote

For some quite obvious reasons, we should expect errors in Fortran 77 features to be less common than those in features introduced later.

As FTN95 was introduced in 'the late 1990s', this must mean that no-one has experienced this problem in two decades - or that it is a regression.

Moreover, if FTN95 was developed over the top of FTN77, but this error was not introduced then, it must have been there even longer!

I wonder if anyone is still using FTN77 and cares to look?

In any case, it shows the extent to which some parts of Fortran are dark and unvisited!

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Thu Feb 02, 2017 6:17 pm    Post subject: Reply with quote

Yes, the bug is (was?) present in FTN77. In Fortran 77, list-directed I/O from/to an internal file was not standard, but FTN77 allows it as an extension. The following version can be compiled using FTN77 4.03 with /ANSI /CHECK, and avoids internal files:
Code:
      PROGRAM LSTRD
      IMPLICIT NONE
      INTEGER I,IJK(5)
      LOGICAL LJK(5)
      REAL RJK(5)
C
      READ(*,*)IJK
      WRITE(*,'(1X,I4,2X,I3)')(I,IJK(I),I=1,5)
      READ(*,*)RJK
      WRITE(*,'(1X,I4,2X,F6.1)')(I,RJK(I),I=1,5)
      READ(*,*)LJK
      WRITE(*,'(1X,I4,2X,L1)')(I,LJK(I),I=1,5)
      END

The data for the program:
Code:
2 2*3 2*5
2.0 2*3.0 2*5.0
T 2*F 2*T


NOTE: If anyone wishes to try FTN77, it is still available for download -- there is a link to it from the Silverfrost Web page, see http://silverfrost.com/53/ftn77_personal_edition.aspx . However, the self-extracting Zip file that you download will not run in Windows 10-64. You can extract it using 7Zip, etc., but the setup program will also refuse to run in Windows 10-64. However, I was able to copy the entire FTN77 file set from an old Windows XP backup, as well as the old Winhlp program from XP, and then it ran fine on Windows 10-64.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Feb 02, 2017 7:07 pm    Post subject: Reply with quote

Hi Mecej4,

I suspected you would know the answer. This must mean that the facility is so useful that nobody used it in 30 or possibly even 40 years!

Or they couldn't make it work, and gave up without protest.

Wow.

Eddie
Back to top
View user's profile Send private message
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