-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.f90
76 lines (66 loc) · 1.33 KB
/
dist.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
subroutine get_dist(molx)
!subroutine get_dist(nat,npair,echo,xyz,dist)
use parm
implicit none
real(8) dx,dy,dz
logical echo
integer istat
type(molecule) molx
!if(npair.gt.thrP) then
! simple version
! loop over all unique pairs
k=1
do i=1,nat-1
do j=i+1,nat
dx=molx%xyz(1,i)-molx%xyz(1,j)
dy=molx%xyz(2,i)-molx%xyz(2,j)
dz=molx%xyz(3,i)-molx%xyz(3,j)
molx%dist(k)=sqrt(dx*dx+dy*dy+dz*dz)
! print*, molx%dist(k)
k=k+1
enddo
enddo
k=k-1
!else
!k=0
!do i=1,nat
! do j=1,nat
! if(i.gt.j.or.i.eq.j) cycle
! k=k+1
! dx=xyz(1,i)-xyz(1,j)
! dy=xyz(2,i)-xyz(2,j)
! dz=xyz(3,i)-xyz(3,j)
! dist(k)=dx*dx+dy*dy+dz*dz
! enddo
!enddo
! slower and more memory ...
!if(istat.ne.0) stop 'allocation error @ index vectors'
! make index vectors
!k=0
!ki=0
!kj=0
!do i=1,nat-1
! do j=i+1,nat
! k=k+1
! kj(k)=j
! ki(k)=i
! enddo
!enddo
!omp parallel do private(i,j,k,dx,dy,dz)
!do k=1,npair
!i=ki(k)
!j=kj(k)
! dx=molx%xyz(1,i)-molx%xyz(1,j)
! dy=molx%xyz(2,i)-molx%xyz(2,j)
! dz=molx%xyz(3,i)-molx%xyz(3,j)
! molx%dist(k)=dx*dx+dy*dy+dz*dz
!enddo
!omp end parallel do
!endif
!if(echo) then
!write(*,'(2x,a,F6.2,a)') 'Keeping: ',(dble(k)/dble(npair)*100d0),' % of atom pairs after distance screening'
!write(*,'(2x,a,I)') 'npair before screening : ' ,npair
!npair=k
!write(*,'(2x,a,I)') 'npair after screening : ' ,npair
!endif
end subroutine