Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fortran 95 problem: thread error the handle is invalid (6)

Status
Not open for further replies.

engineercv

Programmer
Jul 7, 2014
1
GR
Hi everyone
I'm rather new in programing and while i run this program it stucks.If i hit cancel it says:thread error the handle is invalid(6) and then i have to wait for like 14 secs...
Any ideas?



program main

implicit none
real::a,r,g
integer::iam,iryz,igar,ianw,ikatw,itemp
call opfiles(iam,iryz,igar,ianw,ikatw)
call optemp(ianw,ikatw,itemp)
call ypol(a,r,g,iam,iryz,igar,itemp)
print*,a,r,g
pause

contains

subroutine opfile(afn,iun)
integer::err,iun
real::a
character::afn
rewind(iun)
do
read(iun,*,iostat=err)a
if (err/=0) then
if (err<0) then
exit
else
print*, 'yparxei lathos'
pause
end if
end if
end do
end subroutine




integer function lenfile(iun)
integer::iun,err
real::a
open (iun)
rewind(iun)
lenfile=0
do
read(iun,*,iostat=err)a
if (err==0) then
if (a >=0) then
lenfile=lenfile+1
else
print*, 'uparxei lathos'
pause
end if
else if (err<0) then
exit
end if
end do
end function



subroutine opfiles(iam,iryz,igar,ianw,ikatw)
real::a
integer::nseires,iam,iryz,igar,ianw,ikatw
iam=11
iryz=21
igar=31
ianw=41
ikatw=51
open(iam,file='ammos.txt')
call opfile('ammos.txt',iam)
nseires=lenfile(iam)
open(iryz,file='ryzaki.txt')
call opfile('ryzaki.txt',iryz)
if(nseires/=lenfile(iryz)) then
pause 'uparxei lathos'
end if
open(igar,file='garmpili.txt')
call opfile('garmpili.txt',igar)
if(nseires/=lenfile(igar)) then
pause 'uparxei lathos'
end if
open(ianw,file='anw.txt')
call opfile('anw.txt',ianw)
if(nseires/=lenfile(ianw)) then
pause 'uparxei lathos'
end if
open(ikatw,file='katw.txt')
call opfile('katw.txt',ikatw)
if(nseires/=lenfile(ikatw)) then
pause 'uparxei lathos'
end if
end subroutine





subroutine optemp(ianw,ikatw,itemp)
integer,intent(in)::ianw,ikatw
integer,intent(out)::itemp
integer::i,nseires
real::a,b,c
itemp=61

open(itemp,status='scratch')
rewind(ianw)
rewind(ikatw)
nseires=lenfile(ianw)
do i=1,nseires
read(ianw,*)a
read(ikatw,*)b
c=(a+b)/2.0
write(itemp,*)c
end do
endfile(itemp)
end subroutine




subroutine ypdiaf(a,r,g,s2,iam,iryz,igar,itemp)
real::am,ryz,gar,temp
integer::nseires,i
integer,intent(in)::itemp,iam,iryz,igar
real,intent(out)::a,r,g,s2
rewind(itemp)
rewind(iam)
rewind(iryz)
rewind(igar)
s2=0
nseires=lenfile(iam)
do i=1,nseires
read(iam,*)am
read(iryz,*)ryz
read(igar,*)gar
read(itemp,*)temp
s2=(a*am+r*ryz+g*gar-temp)**2+s2
end do
end subroutine




subroutine ypol(abelt,rbelt,gbelt,iam,iryz,igar,itemp)
real::a,r,g,s2,min
real,intent(out)::abelt,rbelt,gbelt
integer,intent(in)::iam,iryz,igar,itemp
min=10000000000000000000.0
do a=0.0,1.0,0.01
do r=0.0,1.0-a,0.01
g=1.0-a-r
call ypdiaf(a,r,g,s2,iam,iryz,igar,itemp)
if (s2<min) then
min=s2
abelt=a
rbelt=r
gbelt=g
end if
end do
end do
end subroutine

end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top