我想问是否有人知道为什么我用 Fortran 编写的这个程序的第一个循环根本不起作用。因为do r = 0, 5, 0.1
只有第一个数字r
是 read r=0
。我能做些什么来使它成为可能?
implicit none
real , allocatable ::x(:)
real , allocatable ::y(:)
real , allocatable ::h(:)
integer i , n , a , j , d
real hp1 , s , c , r
real , allocatable ::T1(:)
open (10,file='point.txt', status='old')
open (6,file='pointr2.txt',status='new')
read (10,*) n
allocate (x(n))
allocate (y(n))
allocate (h(n))
allocate (T1(n))
s=0
d=0
c=0
do r=0.0000 , 5.0000 , 0.1
do j= 1, n
if ( j.gt.1 ) goto 39
do i=1,n
read (10,*) x(i), y(i), h(i)
write (6,*) x(i), y(i), h(i)
end do
close (10)
call highest ( h,n,hp1,a )
write (6,*) hp1
write (6,*) ' The First highest point number' , a
write (6,*) x(a)
39 if ( j.eq. a ) goto 100
s=abs((h(j)-h(a))/(x(j)-x(a)))
d=((x(j)-x(a))**2+(y(j)-y(a))**2+(h(j)-h(a))**2)**0.5
c=((x(j)-x(a))**2+(y(j)-y(a))**2)
T1(j)=atan((y(a)-y(j))/(x(a)-x(j)))
if ( c .eq.r**2 .and. d .ge. 0.0025 .and.s.ge.0.and.s .le. 0.04) then
T1(j)= atan((y(a)-y(j))/(x(a)-x(j)))
write (6,*) 'Group 1' , j ,T1(j)
end if
write (6,*) s, c ,T1(j)
100 end do
end
do
end
subroutine highest ( h,n,hp1,a )
implicit none
integer i , n ,a
real hp1
real h(n)
hp1=h(1)
a= 1
do i=1,n
if ( h(i) .gt.hp1 ) then
hp1=h(i)
a = i
end if
end do
end subroutine
我的输入是:
6
0.01 0.02 0.03
0.13 0.14 0.1504
0.04 0.05 0.06
0.07 0.08 0.15
0.10 0.11 0.12
0.15 0.042020410 0.15