forked from m3g/packmol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setibox.f90
30 lines (25 loc) · 852 Bytes
/
setibox.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
!
! Written by Leandro Martínez, 2009-2011.
! Copyright (c) 2009-2018, Leandro Martínez, Jose Mario Martinez,
! Ernesto G. Birgin.
!
! Subroutine setibox: set box index for given coordinates
!
subroutine setibox(x,y,z,sizemin,boxl,nboxes,iboxx,iboxy,iboxz)
implicit none
double precision :: x, y, z, sizemin(3), boxl(3), xtemp, ytemp, ztemp
integer :: nboxes(3), iboxx, iboxy, iboxz
xtemp = x - sizemin(1)
ytemp = y - sizemin(2)
ztemp = z - sizemin(3)
iboxx = int(xtemp/boxl(1)) + 1
iboxy = int(ytemp/boxl(2)) + 1
iboxz = int(ztemp/boxl(3)) + 1
if(xtemp.le.0) iboxx = 1
if(ytemp.le.0) iboxy = 1
if(ztemp.le.0) iboxz = 1
if(iboxx.gt.nboxes(1)) iboxx = nboxes(1)
if(iboxy.gt.nboxes(2)) iboxy = nboxes(2)
if(iboxz.gt.nboxes(3)) iboxz = nboxes(3)
return
end subroutine setibox