主题:[讨论]请问fortran run time error的问题
程序运行时候出现了这个错误,编译时候没有错误。
At line 14 of file 5_1.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Insufficient data descriptors in format after reversion
请问是什么问题呢?
以下是程序本身,附件里面也有。
module typedef
implicit none
type person
real income,tax
end type person
end module
program main
use typedef
implicit none
type(person),allocatable::people(:)
character(len=79) filename
logical alive
integer:: num,i=1,error=0
write(*,"('please enter the filename and the num of people:')")filename,num
allocate(people(num))
open(10,file=filename,status="old")
do while(.true.)
read(10,"(F5.1)",iostat=error) people(i)%income
i=i+1
if(error/=0) exit
end do
close(10)
do i=1,num
call compute_tax(people(i))
end do
filename="new"//filename
open(10,file=filename,status="replace")
write(10,"(2A10)")"income","tax"
do i=1,num
write(10,"(2F10.2)")people(i)%income,people(i)%tax
end do
stop
end program
subroutine compute_tax(man)
use typedef
implicit none
type(person) man
if (man%income<1000)then
man%tax=man%income*0.03
else if(man%income>1000.and.man%income<5000) then
man%tax=man%income*0.1
else if(man%income>5000) then
man%tax=man%income*0.15
end if
return
end subroutine
At line 14 of file 5_1.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Insufficient data descriptors in format after reversion
请问是什么问题呢?
以下是程序本身,附件里面也有。
module typedef
implicit none
type person
real income,tax
end type person
end module
program main
use typedef
implicit none
type(person),allocatable::people(:)
character(len=79) filename
logical alive
integer:: num,i=1,error=0
write(*,"('please enter the filename and the num of people:')")filename,num
allocate(people(num))
open(10,file=filename,status="old")
do while(.true.)
read(10,"(F5.1)",iostat=error) people(i)%income
i=i+1
if(error/=0) exit
end do
close(10)
do i=1,num
call compute_tax(people(i))
end do
filename="new"//filename
open(10,file=filename,status="replace")
write(10,"(2A10)")"income","tax"
do i=1,num
write(10,"(2F10.2)")people(i)%income,people(i)%tax
end do
stop
end program
subroutine compute_tax(man)
use typedef
implicit none
type(person) man
if (man%income<1000)then
man%tax=man%income*0.03
else if(man%income>1000.and.man%income<5000) then
man%tax=man%income*0.1
else if(man%income>5000) then
man%tax=man%income*0.15
end if
return
end subroutine