Silverfrost Forums

Welcome to our forums

List directed input of logical data with repeat factor fails

15 Oct 2016 12:32 (Edited: 22 Oct 2016 1:11) #18124

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.

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
15 Oct 2016 12:45 #18125

Thank you for the feedback. I have logged this for investigation.

31 Jan 2017 10:30 #18818

This has now been fixed for the next release.

2 Feb 2017 10:10 #18822

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

2 Feb 2017 5:17 #18823

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:

      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:

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.

2 Feb 2017 6:07 #18824

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

Please login to reply.