[Bug fortran/83152] New: Possible run time error in derived type i/o
ian at rhymneyconsulting dot co.uk
gcc-bugzilla@gcc.gnu.org
Sat Nov 25 12:22:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83152
Bug ID: 83152
Summary: Possible run time error in derived type i/o
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ian at rhymneyconsulting dot co.uk
Target Milestone: ---
I get the following run time error with a dtio example that I believe to be
correct.
Here is the derived type module.
#####
module ch3701_person_module
implicit none
type :: person
character (len=30) :: name
integer :: age
real :: height
real :: weight
contains
procedure :: print_person
generic :: write(formatted) => print_person
procedure :: read_person
generic :: read(formatted) => read_person
end type person
contains
subroutine print_person(p,unit_number,iotype,vlist,iostat,iomsg)
implicit none
class (person) , intent(in) :: p
integer , intent(in) :: unit_number
character (len=*) , intent(in) :: iotype
integer , dimension(:) , intent(in) :: vlist
integer , intent(out) :: iostat
character (len=*) , intent(inout) :: iomsg
character (len=40) :: person_format
person_format="(a,2x,i3,2x,f4.2,2x,f3.0)"
write (unit_number,fmt=person_format) &
p%name,p%age,p%height,p%weight
iostat=0
end subroutine print_person
subroutine read_person(p,unit_number,iotype,vlist,iostat,iomsg)
implicit none
class (person) , intent(inout) :: p
integer , intent(in) :: unit_number
character (len=*) , intent(in) :: iotype
integer , dimension(:) , intent(in) :: vlist
integer , intent(out) :: iostat
character (len=*) , intent(inout) :: iomsg
character (len=40) :: person_format
person_format='(a,2x,i3,2x,f4.2,2x,f3.0)'
read (unit_number,fmt=person_format) &
p%name,p%age,p%height,p%weight
iostat=0
end subroutine read_person
end module ch3701_person_module
#####
Here is the main program
#####
include 'ch3701_person_module.f90'
program ch3701
use ch3701_person_module
integer , parameter :: n=4
type (person) , dimension(n) :: p
integer :: i
open(unit=99,file='ch3701_input_file.txt')
do i=1,n
read( 99 , 10 ) p(i)
10 format( DT )
write( * , 20 ) p(i)
20 format( DT )
end do
end program ch3701
#####
Here is the data file.
#####
Zahpod Beeblebrox 42 1.85 75
Ford Prefect 25 1.75 65
Arthur Dent 30 1.72 68
Trillian 30 1.65 45
#####
Here is the error message.
#####
gfortran_ch3701.exe
At line 61 of file ch3701_person_module.f90 (unit = 99, file =
'ch3701_input_file.txt')
Fortran runtime error: End of record
Error termination. Backtrace:
Could not print backtrace: libbacktrace could not find executable to open
#0 0xffffffff
#1 0xffffffff
#2 0xffffffff
#3 0xffffffff
#4 0xffffffff
#5 0xffffffff
#6 0xffffffff
#7 0xffffffff
#8 0xffffffff
#9 0xffffffff
#10 0xffffffff
#11 0xffffffff
#12 0xffffffff
#13 0xffffffff
#14 0xffffffff
#15 0xffffffff
#####
More information about the Gcc-bugs
mailing list