Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29283 Discussions

Simple question but I am still confused!

wail
Beginner
414 Views
Hello everyone,

When I compiled my program no error encountered,but when I executed it
it gave this message
"forrtl: severe <24>: end-of-file during read, unit 11,file
D:myfilesinputs.dat"
I have tried to solve for this problem, for example:
1-I thought that my input file might have spaces that cause error when
reading the numbers.

2-Adding an error control statement such as"ERR=111"
open (11,file ='inputs.dat',status ='old',action ='read',ERR=111)
3- I have tried to use the(IOSTAT=) statement as the following
READ(11,*;IOSTAT=ierr) your_data
if(ierr==0) then
write(*,*) 'no error during read'
elseif(ierr<0) then
write(*,*) 'error : end of file'
elseif(ierr>0) then
write(*,*) 'other error'
endif
it showed no error in all "read" lines except the lines after
<>

I could not solve this problem. May be becuase it is my first time to
write such a program.

Below is part of the program, hopefully someone might help.
Thanks to all
wael

-------------------------
program wael

implicit none
integer::i,j,nels,n,nn,s,iel,NEQ,k,kk,t,mm,mmm,tt,count1,count2
integer::iph,ilo,yy,vv,Nphi,Nload,Ndispx,idisp,rr,count11,count22
real::EI,L,power
!------------------------------dynamic
arrays----------------------------------
real,allocatable::phi(:),length(:),km(:,:),phi1(:,:),load(:)
real,allocatable::dtheta1(:),dtheta(:),lmoment(:),mom(:),dispx(:)

integer,allocatable::pre(:)

!------------------------input and
initialisation------------------------------

open (11,file ='inputs.dat',status ='old',action ='read',ERR=111)
open (12,file ='solution.dat',status ='replace',action='write')
!----------------------------------------------------------------------
! 1-Reading number of elements and EI
!----------------------------------------------------------------------
read(11,*)nels,EI !

nn=nels+1
s=((nels*2)-1)+3
NEQ=s
allocate (phi(nn), length(nels),km(s,s),phi1(nels,nn),load(nn))
allocate (dtheta1(s),pre(s),dispx(nn),mom(nn))
allocate (dtheta(s),lmoment(s))

!----------------------------------------------------------------------
! Initializing Vectors and Arrays
!----------------------------------------------------------------------

do k=1,s
do kk=1,s
km(k,kk)=0.0
end do
end do

do t=1,s
dtheta(t)=0.0
dtheta1(t)=0.0
end do


do i=1,nn
phi(i)=0.0
load(i)=0.0
dispx(i)=0.0
pre(i)=0.0
mom(i)=0.0
end do


!----------------------------------------------------------------------
! 2-Reading Variables provided if any
!----------------------------------------------------------------------
read (11,*) NPhi,Nload,Ndispx
if (Nphi/=0) GOTO 100

100 read (11,*) (iph,phi(iph),yy=1,NPhi)

if (Nload/=0)GOTO 200
200 read (11,*) (ilo,load(ilo),vv=1,Nload)
if (Ndispx/=0)GOTO 300
300 read (11,*) (idisp,dispx(idisp),rr=1,Ndispx)


read (11,*) (length(j),j=1,nels)
count1=1
count2=1
do i=1,s
mm=MOD(i,2)
if(mm/=0)then
dtheta1(i)=dispx(count1)
count1=count1+1
pre(i)=1
else

dtheta1(i)=phi(count2)
count2=cou nt2+1
pre(i)=1
endif

end do


!------------------------------------------------------------------------------
! Matrix
!------------------------------------------------------------------------------
elements_1: do iel=1,nels
n=(iel*2)-1
length(iel)=L

power=L**3


km(n,n)=km(n,n)+12*EI/power
km(n,n+1)=km(n,n+1)+6*EI*L/power
km(n,n+2)=km(n,n+2)-12*EI/power
km(n,n+3)=km(n,n+3)+6*EI*L/power

km(n+1,n)=km(n+1,n)+6*EI*L/power
km(n+1,n+1)=km(n+1,n+1)+((4*EI*L**2)/power)
km(n+1,n+2)=km(n+1,n+2)-6*EI*L/power
km(n+1,n+3)=km(n+1,n+3)+((2*EI*L**2)/power)

km(n+2,n)=km(n+2,n)-12*EI/power
km(n+2,n+1)=km(n+2,n+1)-6*EI*L/power
km(n+2,n+2)=km(n+2,n+2)+12*EI/power
km(n+2,n+3)=km(n+2,n+3)-6*EI*L/power

km(n+3,n)=km(n+3,n)+6*EI*L/power
km(n+3,n+1)=km(n+3,n+1)+((2*EI*L**2)/power)
km(n+3,n+2)=km(n+3,n+2)-6*EI*L/power
km(n+3,n+3)=km(n+3,n+3)+((4*EI*L**2)/power)

end do elements_1

call gauss(NEQ,load,km,pre,dtheta1)
call BAKSUB(NEQ,load,km,pre,dtheta1,dtheta,lmoment)

!------------------------------------------------------------------------------
! outputs
!------------------------------------------------------------------------------
count11=1
count22=1
do i=1,s
mmm=MOD(i,2)
if (mmm/=0) then
load(count11)=lmoment(i)
phi(count11)=dtheta(i)
count11=count11+1
else
mom(count22)=lmoment(i)
dispx(count22)=dtheta(i)
count22=count22+1
endif
end do
!------------------------------------------------------------------------------
! Printing the Node,Displacement,Phi,Moment and Shear
!------------------------------------------------------------------------------

results: do i=1,nn
write (12,1000)i,dispx(i),phi(i),mom(i),load(i)
1000 Format (4x,i5,4x,e12.4,4x,e12.4,4x,e12.4,4x,e12.4)
end do results


111 end program wael
0 Kudos
2 Replies
Intel_C_Intel
Employee
414 Views
Maybe you need to add an error control statement such as"END=111"

Often you need an "ERR=111" AND "END=111"

David
0 Kudos
Intel_C_Intel
Employee
414 Views
Wael,
The problem appears to be that there is less data in your input file than your program is asking for. This can only be solved by looking at both the program and the data file.
The "ERR=" statement on the OPEN will only trap errors on the OPEN itself, not on any subsequent read. Adding an "IOSTAT=" qualifier to a READ should stop the system aborting the program execution; a "END=" qualifier should not also be _necessary_ .
I suggest that you either 1) examine the program together with the data file and e.g. count data items or 2) use the debugger to examine the data as it is read in, to see where it goes wrong.
Hope this helps,
Joe
0 Kudos
Reply