Skip to content

Commit 70fad6d

Browse files
committed
allow generic parameter files and multiple PARAMETERS keywords
1 parent 55ec6f3 commit 70fad6d

4 files changed

Lines changed: 140 additions & 94 deletions

File tree

doc/tinker-guide.pdf

255 Bytes
Binary file not shown.

source/getkey.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ subroutine getkey
5454
end if
5555
end do
5656
c
57-
c try to get keyfile from base name of current system
57+
c check for a keyfile with base name of current system
5858
c
5959
if (.not. exist) then
6060
keyfile = filename(1:leng)//'.key'

source/getprm.f

Lines changed: 128 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
c ## All Rights Reserved ##
66
c ###################################################
77
c
8-
c #############################################################
9-
c ## ##
10-
c ## subroutine getprm -- get force field parameter file ##
11-
c ## ##
12-
c #############################################################
8+
c ##############################################################
9+
c ## ##
10+
c ## subroutine getprm -- get force field parameter files ##
11+
c ## ##
12+
c ##############################################################
1313
c
1414
c
15-
c "getprm" finds the potential energy parameter file
16-
c and then opens and reads the parameters
15+
c "getprm" finds any potential energy parameter files and
16+
c then opens and reads the parameters
1717
c
1818
c
1919
subroutine getprm
@@ -24,27 +24,53 @@ subroutine getprm
2424
use keys
2525
use params
2626
implicit none
27+
integer maxfile
28+
parameter (maxfile=12)
2729
integer i,j,iprm
28-
integer nask,next
30+
integer nfile,nask
31+
integer trimtext,next
2932
integer freeunit
30-
integer trimtext
3133
logical exist,useprm
3234
character*4 none
3335
character*20 keyword
3436
character*240 prmfile
3537
character*240 prefix
3638
character*240 record
3739
character*240 string
40+
character*240 ifile(maxfile)
3841
c
3942
c
40-
c set the default name for the parameter file
43+
c set default usage and number of parameter files
4144
c
4245
useprm = .true.
46+
nfile = 0
47+
c
48+
c check for parameter file with base name of current system
49+
c
4350
prmfile = filename(1:leng)//'.prm'
51+
call version (prmfile,'old')
52+
inquire (file=prmfile,exist=exist)
53+
if (exist) then
54+
nfile = nfile + 1
55+
ifile(nfile) = prmfile
56+
end if
57+
c
58+
c check for the existence of a generic parameter file
59+
c
60+
if (ldir .eq. 0) then
61+
prmfile = 'tinker.prm'
62+
else
63+
prmfile = filename(1:ldir)//'tinker.prm'
64+
end if
65+
call version (prmfile,'old')
66+
inquire (file=prmfile,exist=exist)
67+
if (exist) then
68+
nfile = nfile + 1
69+
ifile(nfile) = prmfile
70+
end if
4471
c
4572
c try to get a parameter filename from the command line
4673
c
47-
exist = .false.
4874
do i = 1, narg-1
4975
string = arg(i)
5076
call upcase (string)
@@ -57,29 +83,72 @@ subroutine getprm
5783
end if
5884
call suffix (prmfile,'prm','old')
5985
inquire (file=prmfile,exist=exist)
60-
if (.not. exist) then
86+
if (exist) then
87+
nfile = nfile + 1
88+
ifile(nfile) = prmfile
89+
else
6190
write (iout,10)
62-
10 format (/,' GETPRM -- Parameter File Specified',
63-
& ' on Command Line not Found')
91+
10 format (/,' GETPRM -- Parameter File Named on',
92+
& ' Command Line not Found')
6493
call fatal
6594
end if
6695
end if
6796
end do
6897
c
6998
c search the keyword list for the parameter filename
7099
c
71-
if (.not. exist) then
72-
do i = 1, nkey
100+
do i = 1, nkey
101+
next = 1
102+
record = keyline(i)
103+
call gettext (record,keyword,next)
104+
call upcase (keyword)
105+
if (keyword(1:11).eq.'PARAMETERS '
106+
& .or. keyword(1:10).eq.'PARAMETER ') then
107+
string = record(next:240)
73108
next = 1
74-
record = keyline(i)
75-
call gettext (record,keyword,next)
76-
call upcase (keyword)
77-
if (keyword(1:11).eq.'PARAMETERS '
78-
& .or. keyword(1:10).eq.'PARAMETER ') then
79-
string = record(next:240)
80-
next = 1
81-
call getstring (string,prmfile,next)
82-
if (next .eq. 1) call gettext (string,prmfile,next)
109+
call getstring (string,prmfile,next)
110+
if (next .eq. 1) call gettext (string,prmfile,next)
111+
if (prmfile(1:2) .eq. '~/') then
112+
call getenv ('HOME',prefix)
113+
prmfile = prefix(1:trimtext(prefix))//
114+
& prmfile(2:trimtext(prmfile))
115+
end if
116+
call suffix (prmfile,'prm','old')
117+
inquire (file=prmfile,exist=exist)
118+
if (exist) then
119+
do j = 1, nfile
120+
if (prmfile .eq. ifile(j)) goto 20
121+
end do
122+
nfile = nfile + 1
123+
ifile(nfile) = prmfile
124+
20 continue
125+
else
126+
none = prmfile(1:4)
127+
call upcase (none)
128+
if (none .eq. 'NONE') useprm = .false.
129+
end if
130+
end if
131+
end do
132+
if (.not. useprm) nfile = 0
133+
c
134+
c if necessary, ask for the parameter filename
135+
c
136+
if (useprm .and. nfile.eq.0) then
137+
nask = 0
138+
exist = .false.
139+
do while (.not.exist .and. nask.lt.maxask)
140+
nask = nask + 1
141+
write (iout,30)
142+
30 format (/,' Enter Parameter File Name [<Enter>=NONE] : ',$)
143+
read (input,40) prmfile
144+
40 format (a240)
145+
next = 1
146+
call getword (prmfile,none,next)
147+
call upcase (none)
148+
if (next.eq.1 .or. none.eq.'NONE') then
149+
exist = .true.
150+
useprm = .false.
151+
else
83152
if (prmfile(1:2) .eq. '~/') then
84153
call getenv ('HOME',prefix)
85154
prmfile = prefix(1:trimtext(prefix))//
@@ -91,77 +160,56 @@ subroutine getprm
91160
end do
92161
end if
93162
c
94-
c test for user specified absence of a parameter file
163+
c check to make sure a parameter file is available
95164
c
96-
if (.not. exist) then
97-
none = prmfile(1:4)
98-
call upcase (none)
99-
if (none .eq. 'NONE') then
100-
exist = .true.
101-
useprm = .false.
102-
end if
165+
if (useprm .and. nfile.eq.0) then
166+
write (iout,50)
167+
50 format (/,' GETPRM -- A Valid Parameter File',
168+
& ' was not Provided')
169+
call fatal
103170
end if
104171
c
105-
c if necessary, ask for the parameter filename
106-
c
107-
nask = 0
108-
do while (.not.exist .and. nask.lt.maxask)
109-
nask = nask + 1
110-
write (iout,20)
111-
20 format (/,' Enter Parameter File Name [<Enter>=NONE] : ',$)
112-
read (input,30) prmfile
113-
30 format (a240)
114-
next = 1
115-
call getword (prmfile,none,next)
116-
call upcase (none)
117-
if (next .eq. 1) then
118-
exist = .true.
119-
useprm = .false.
120-
else if (none.eq.'NONE' .and. next.eq.5) then
121-
exist = .true.
122-
useprm = .false.
123-
else
124-
if (prmfile(1:2) .eq. '~/') then
125-
call getenv ('HOME',prefix)
126-
prmfile = prefix(1:trimtext(prefix))//
127-
& prmfile(2:trimtext(prmfile))
128-
end if
129-
call suffix (prmfile,'prm','old')
130-
inquire (file=prmfile,exist=exist)
131-
end if
132-
end do
133-
if (.not. exist) call fatal
134-
c
135-
c read the parameter file to get number of lines
172+
c read the parameter files and count the total lines
136173
c
137174
nprm = 0
138175
if (useprm) then
139-
iprm = freeunit ()
140-
open (unit=iprm,file=prmfile,status='old')
141-
rewind (unit=iprm)
142-
do while (.true.)
143-
read (iprm,40,err=50,end=50)
144-
40 format ()
145-
nprm = nprm + 1
176+
do i = 1, nfile
177+
iprm = freeunit ()
178+
prmfile = ifile(i)
179+
open (unit=iprm,file=prmfile,status='old')
180+
rewind (unit=iprm)
181+
do while (.true.)
182+
read (iprm,60,err=70,end=70)
183+
60 format ()
184+
nprm = nprm + 1
185+
end do
186+
70 continue
187+
close (unit=iprm)
146188
end do
147-
50 continue
148-
rewind (unit=iprm)
149189
end if
150190
c
151191
c perform dynamic allocation of some global arrays
152192
c
153193
if (allocated(prmline)) deallocate (prmline)
154194
allocate (prmline(nprm))
155195
c
156-
c reread the parameter file and store for latter use
196+
c reread the parameter files and store for latter use
157197
c
158-
do i = 1, nprm
159-
read (iprm,60,err=70,end=70) record
160-
60 format (a240)
161-
prmline(i) = record
198+
nprm = 0
199+
do i = 1, nfile
200+
iprm = freeunit ()
201+
prmfile = ifile(i)
202+
open (unit=iprm,file=prmfile,status='old')
203+
rewind (unit=iprm)
204+
dowhile (.true.)
205+
read (iprm,80,err=90,end=90) record
206+
80 format (a240)
207+
nprm = nprm + 1
208+
prmline(nprm) = record
209+
end do
210+
90 continue
211+
close (unit=iprm)
162212
end do
163-
70 continue
164-
close (unit=iprm)
165213
c
166214
c convert underbar characters to dashes in all keywords
167215
c

source/xyzpdb.f

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ subroutine getside (resname,ires,ci,cai,cbi)
862862
c if residue is a terminal cap, there is no side chain
863863
c
864864
cbi = 0
865+
if (cai .eq. 0) return
865866
if (resname .eq. 'H2N') return
866867
if (resname .eq. 'FOR') return
867868
if (resname .eq. 'ACE') return
@@ -871,19 +872,16 @@ subroutine getside (resname,ires,ci,cai,cbi)
871872
c
872873
c find the beta carbon atom for the current residue
873874
c
874-
do i = 1, n
875-
if (i.ne.ci .and. atomic(i).eq.6) then
876-
do j = 1, 4
877-
if (i12(j,i) .eq. cai) then
878-
cbi = i
879-
if (resname .ne. 'AIB') then
880-
call pdbatom (' CB ',resname,ires,cbi)
881-
else
882-
call pdbatom (' CB1',resname,ires,cbi)
883-
end if
884-
goto 10
885-
end if
886-
end do
875+
do i = 1, n12(cai)
876+
j = i12(i,cai)
877+
if (j.ne.ci .and. atomic(j).eq.6) then
878+
cbi = j
879+
if (resname .ne. 'AIB') then
880+
call pdbatom (' CB ',resname,ires,cbi)
881+
else
882+
call pdbatom (' CB1',resname,ires,cbi)
883+
end if
884+
goto 10
887885
end if
888886
end do
889887
10 continue

0 commit comments

Comments
 (0)