- #1
Hejmore
- 3
- 0
Hi, I try to write program to calculating mach number, with using bisection method. When I run program, fortran write to me an error in line 40. Can you help? I tried to calculating function by using wolfram sucesfully but I need to run it on fortran, An equation is 1.7795 - (0.334898 (1 + 0.2 x^2)^6.)/x^2. Can you help me? Thx
My error code:
My error code:
Fortran:
program mach
real pp,z1,z2,sucin,a,b,x,machx,a1
pp=1
a1=0.1
b=3
z1=pp**2-(0.334898*(1+0.2*a1**2)**6)/a1**2
z2=pp**2-(0.334898*(1+0.2*b**2)**6)/b**2
sucin=z1*z2
if(sucin.lt.0) go to 1
if(sucin.gt.0) go to 3
1 continue
do
a=a1
a1=(b+a)/2
z1=pp**2-(0.334898*(1+0.2*a1**2)**6)/a1**2
z2=pp**2-(0.334898*(1+0.2*b**2)**6)/b**2
sucin=z1*z2
machx=a
x=abs(b-a)
if(x.lt.0.0001) exit
if(sucin.lt.0) cycle
if(sucin.gt.0) go to 2
end do
2 continue
do
b=a1
a1=(b+a)/2
z1=pp**2-(0.334898*(1+0.2*a**2)**6)/a**2
z2=pp**2-(0.334898*(1+0.2*a1**2)**6)/a1**2
sucin=z1*z2
machx=b
x=abs((b-a))
if(x.lt.0.0001) exit
if(sucin.lt.0) cycle
if(sucin.gt.0) go to 1
end do
3 continue
print*,'Mach number is'
write(5,*) machx
stop
end program mach
Last edited by a moderator: