forked from m3g/packmol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swaptype.f90
89 lines (77 loc) · 1.8 KB
/
swaptype.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
77
78
79
80
81
82
83
84
85
86
87
88
!
! Written by Leandro Martínez, 2009-2011.
! Copyright (c) 2009-2018, Leandro Martínez, Jose Mario Martinez,
! Ernesto G. Birgin.
!
! Subroutine that swaps indexes for packing molecules one at a time
!
subroutine swaptype(n,x,itype,action)
use sizes, only : nn
use compute_data, only : ntype, comptype, nmols, ntotmol
use input, only : nloop, nloop_all, nloop_type
use swaptypemod
use ahestetic
implicit none
integer ::n, itype, ilubar, ilugan, i, action
double precision :: x(nn)
! Save original data
if ( action == 0 ) then
do i = 1, nn
xfull(i) = x(i)
end do
ntemp = n
ntottemp = ntotmol
end if
! Swapping data for packing this itype
if ( action == 1 ) then
do i = 1, ntype
if(i == itype) then
comptype(i) = .true.
else
comptype(i) = .false.
end if
end do
n = nmols(itype) * 6
ntotmol = nmols(itype)
nloop = nloop_type(itype)
ilubar = 0
do i = 1, itype - 1
ilubar = ilubar + nmols(i) * 3
end do
ilubar = ilubar + 1
ilugan = ntemp/2 + ilubar
do i = 1, n / 2
x(i) = xfull(ilubar)
x(i+n/2) = xfull(ilugan)
ilubar = ilubar + 1
ilugan = ilugan + 1
end do
end if
! Save results for this type
if ( action == 2 ) then
ilubar = 0
do i = 1, itype - 1
ilubar = ilubar + nmols(i)*3
end do
ilubar = ilubar + 1
ilugan = ntemp/2 + ilubar
do i = 1, n/2
xfull(ilubar) = x(i)
xfull(ilugan) = x(i+n/2)
ilubar = ilubar + 1
ilugan = ilugan + 1
end do
end if
! Restore all-molecule vectors
if ( action == 3 ) then
n = ntemp
ntotmol = ntottemp
nloop = nloop_all
do i = 1, n
x(i) = xfull(i)
end do
do i = 1, ntype
comptype(i) = .true.
end do
end if
end subroutine swaptype