program up
implicit none
!read the file......................................
real :: x(2250),y(2250),z(2250)
integer :: i
open(1,file='XYZ1.txt')
loopi: do i = 1,2250
read(1,*) x(i),y(i),z(i)
end do loopi
close(1)
!........draw a ball and get 4 points..............................................
integer :: a(4)
integer :: j
integer :: n
integer :: k
integer :: l
integer :: m(2250,4)
loopj: do j = 1,2250
k = 0
loopn: do n = 1,2250
if (j == n) then
cycle
end if
if ((x(n)-x(j))**2+(y(n)-y(j))**2+(z(n)-z(j))**2 < 1.8**2) then
k = k + 1
a(k) = n
if (k == 4) then
loopl: do l = 1,4
m(j,l) = a(l)
print *,m(j,l)
end do loopl
end if
end if
end do loopn
end do loopj
end program up
64.5 KB, 下载次数: 0
program up
implicit none
Integer , parameter :: N = 2250 , S = 4
real :: x(N),y(N),z(N)
integer :: i , j , k , l
integer :: a(S)
integer :: m(N,S)
!read the file......................................
open(1,file='XYZ1.txt')
do i = 1,N
read(1,*) x(i),y(i),z(i)
end do
close(1)
!........draw a ball and get 4 points..............................................
do j = 1,N
k = 0
do i = 1,N
if (j == i) cycle
if ((x(i)-x(j))**2+(y(i)-y(j))**2+(z(i)-z(j))**2 < 1.8**2) then
k = k + 1
a(k) = i
if (k == 4) then
do l = 1,S
m(j,l) = a(l)
print *,m(j,l)
end do
end if
end if
end do
end do
end program up
fcode 发表于 2018-9-19 20:31
把所有定义语句放到前面即可。
fcode 发表于 2018-9-19 20:31
把所有定义语句放到前面即可。
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |