forked from TinkerTools/tinker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprtxyz.f
111 lines (111 loc) · 3.08 KB
/
prtxyz.f
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
c
c
c ###################################################
c ## COPYRIGHT (C) 1990 by Jay William Ponder ##
c ## All Rights Reserved ##
c ###################################################
c
c ###############################################################
c ## ##
c ## subroutine prtxyz -- output of XYZ-format coordinates ##
c ## ##
c ###############################################################
c
c
c "prtxyz" writes out a set of Cartesian coordinates to an
c external disk file in Tinker XYZ format
c
c
subroutine prtxyz (ixyz)
use atomid
use atoms
use bound
use boxes
use couple
use files
use inform
use titles
implicit none
integer i,j,k,ixyz
integer size,crdsiz
real*8 crdmin,crdmax
logical opened
character*2 atmc
character*2 crdc
character*2 digc
character*25 fstr
character*240 xyzfile
c
c
c open the output unit if not already done
c
inquire (unit=ixyz,opened=opened)
if (.not. opened) then
xyzfile = filename(1:leng)//'.xyz'
call version (xyzfile,'new')
open (unit=ixyz,file=xyzfile,status='new')
end if
c
c check for large systems needing extended formatting
c
atmc = 'i6'
if (n .ge. 100000) atmc = 'i7'
if (n .ge. 1000000) atmc = 'i8'
crdmin = 0.0d0
crdmax = 0.0d0
do i = 1, n
crdmin = min(crdmin,x(i),y(i),z(i))
crdmax = max(crdmax,x(i),y(i),z(i))
end do
crdsiz = 6
if (crdmin .le. -1000.0d0) crdsiz = 7
if (crdmax .ge. 10000.0d0) crdsiz = 7
if (crdmin .le. -10000.0d0) crdsiz = 8
if (crdmax .ge. 100000.0d0) crdsiz = 8
crdsiz = crdsiz + max(6,digits)
size = 0
call numeral (crdsiz,crdc,size)
if (digits .le. 6) then
digc = '6 '
else if (digits .le. 8) then
digc = '8'
else
digc = '10'
end if
c
c write out the number of atoms and the title
c
if (ltitle .eq. 0) then
fstr = '('//atmc//')'
write (ixyz,fstr(1:4)) n
else
fstr = '('//atmc//',2x,a)'
write (ixyz,fstr(1:9)) n,title(1:ltitle)
end if
c
c write out the periodic cell lengths and angles
c
if (use_bounds) then
fstr = '(1x,6f'//crdc//'.'//digc//')'
write (ixyz,fstr) xbox,ybox,zbox,alpha,beta,gamma
end if
c
c write out the coordinate line for each atom
c
fstr = '('//atmc//',2x,a3,3f'//crdc//
& '.'//digc//',i6,8'//atmc//')'
do i = 1, n
k = n12(i)
if (k .eq. 0) then
write (ixyz,fstr) i,name(i),x(i),y(i),z(i),type(i)
else
write (ixyz,fstr) i,name(i),x(i),y(i),z(i),type(i),
& (i12(j,i),j=1,k)
end if
end do
c
c close the output unit if opened by this routine
c
if (.not. opened) close (unit=ixyz)
return
end