-
Notifications
You must be signed in to change notification settings - Fork 0
/
distance_tool.f90
57 lines (45 loc) · 1.35 KB
/
distance_tool.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
program distance_tool
use organize_module, only: point_set_registry
implicit none
integer :: nat_1, nat_2
integer, allocatable :: typ_1(:), typ_2(:)
real, allocatable :: coords_1(:,:), coords_2(:,:)
integer :: i
integer, allocatable :: found(:)
real, allocatable :: dists(:)
integer :: n
!! read first structure
read(*,*) nat_1
allocate( typ_1(1:nat_1) )
allocate( coords_1(1:3, 1:nat_1) )
read(*,*)
do i = 1, nat_1
read(*,*) typ_1(i), coords_1(1,i), coords_1(2,i), coords_1(3,i)
end do
!! read second structure
read(*,*) nat_2
allocate( typ_2(1:nat_2) )
allocate( coords_2(1:3, 1:nat_2) )
read(*,*)
do i = 1, nat_2
read(*,*) typ_2(i), coords_2(1,i), coords_2(2,i), coords_2(3,i)
end do
n = max(nat_1, nat_2)
allocate( found(1:n) )
allocate( dists(1:n) )
found(:) = 0
dists(:) = 0.0
call point_set_registry( nat_1, typ_1, coords_1, &
nat_2, typ_2, coords_2, &
found, dists)
write(*,*) 'set 1 index, set 2 index, distance'
do i = 1, n
write(*,*) i, found(i), dists(i)
end do
write(*,*)
write(*,*) 'norm of dists vector:', sqrt( dot_product( dists, dists) )
write(*,*) 'maximum value of distance:', maxval( dists, 1 )
deallocate( typ_1, coords_1 )
deallocate( typ_2, coords_2 )
deallocate( found, dists )
end program distance_tool