-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmall_displacement_check.f90
65 lines (51 loc) · 1.78 KB
/
small_displacement_check.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
! program xyz_util.f
!***********************************************************
! Perform operations on an xyz file (TRAJEC.xyz)
! 1) replace negative coords with PBC displacements
!***********************************************************
implicit none
! n = max # of timesteps, m = max # of atoms
integer n, m, i, j, k, count
parameter (n=1000000,m=10000)
integer natom, timestep
real(4) r(m,3), threshold
real(4) dx, dy, dz, dr
character(2) typat
character(128) fin
! Get the xyz filename from the user
write(*,*) 'Name of xyz file'
read(*,*) fin
write(*,*) 'What dr threshold would you like to use?'
read(*,*) threshold
open(1,file=fin,status='old',ERR=90)
count = 0
! Loop over the rest of the file
do i=1,n
! Read in the value of natom and timestep
read(1,*,END=100) natom
read(1,*) timestep
do j=1,natom
! Read in coordinates from xyz file
read(1,*,END=100) typat, r(j,1), r(j,2), r(j,3)
enddo
do j=1,natom
do k=1,natom
if (j.lt.k) then
dx = (r(j,1)-r(k,1))
dy = (r(j,2)-r(k,2))
dz = (r(j,3)-r(k,3))
dr = ( dx**2 + dy**2 + dz**2 )**0.5
if (dr.lt.threshold) then
write(*,*) 'WARNING: dr = ',dr,'j=',j,'k=',k
count = count + 1
endif
endif
enddo
enddo
enddo
100 continue
write(*,*) 'Number of configurations checked:',i-1
write(*,*) "Number of dr's found <",threshold,'was:',count
close(1)
90 continue
END