1 | !**************************************************************
|
---|
2 | ! Parallel tempering of a system with two Abeta 16--22 peptides
|
---|
3 | ! using 8 replicas.
|
---|
4 | !
|
---|
5 | !
|
---|
6 | ! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
7 | ! Shura Hayryan, Chin-Ku Hu
|
---|
8 | ! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
9 | ! Jan H. Meinke, Sandipan Mohanty
|
---|
10 | !
|
---|
11 | ! CALLS init_energy,init_molecule,partem_p
|
---|
12 | !
|
---|
13 | ! **************************************************************
|
---|
14 | program pmain
|
---|
15 |
|
---|
16 | include '../INCL.H'
|
---|
17 | include '../INCP.H'
|
---|
18 | include '../incl_lund.h'
|
---|
19 | include 'mpif.h'
|
---|
20 |
|
---|
21 | character*80 libdir
|
---|
22 | character*80 in_fil,ou_fil,filebase, varfile
|
---|
23 | character*80 fileNameMP
|
---|
24 |
|
---|
25 | character grpn*4,grpc*4
|
---|
26 | logical newsta
|
---|
27 |
|
---|
28 | !c Number of replicas
|
---|
29 | integer num_replica
|
---|
30 | !c Number of processors per replica
|
---|
31 | integer num_ppr
|
---|
32 | !c Range of processor for crating communicators
|
---|
33 | integer proc_range(3)
|
---|
34 | !c Array of MPI groups
|
---|
35 | integer group(MAX_REPLICA), group_partem
|
---|
36 | !c Array of MPI communicators
|
---|
37 | integer comm(MAX_REPLICA), partem_comm
|
---|
38 | !c Array of nodes acting as masters for the energy calculation.
|
---|
39 | integer ranks(MAX_REPLICA)
|
---|
40 | !c Configuration switch
|
---|
41 | integer switch
|
---|
42 | integer rep_id
|
---|
43 | ! set number of replicas
|
---|
44 | double precision eols(MAX_REPLICA)
|
---|
45 |
|
---|
46 |
|
---|
47 | common/updstats/ncalls(5),nacalls(5)
|
---|
48 |
|
---|
49 |
|
---|
50 | ! MPI stuff, and random number generator initialisation
|
---|
51 |
|
---|
52 | call mpi_init(ierr)
|
---|
53 | call mpi_comm_rank(mpi_comm_world,myrank,ierr)
|
---|
54 | call mpi_comm_size(mpi_comm_world,num_proc,ierr)
|
---|
55 |
|
---|
56 | ! call VTSetup()
|
---|
57 | enysolct = 0
|
---|
58 | seed = 8368
|
---|
59 | call sgrnd(seed) ! Initialize the random number generator
|
---|
60 |
|
---|
61 | ! =================================================== Energy setup
|
---|
62 | libdir='../SMMP/'
|
---|
63 | ! Directory for SMMP libraries
|
---|
64 |
|
---|
65 | ! The switch in the following line is now not used.
|
---|
66 | flex=.false. ! .true. for Flex / .false. for ECEPP
|
---|
67 |
|
---|
68 | ! Choose energy type with the following switch instead ...
|
---|
69 | ientyp = 0
|
---|
70 | ! 0 => ECEPP2 or ECEPP3 depending on the value of sh2
|
---|
71 | ! 1 => FLEX
|
---|
72 | ! 2 => Lund force field
|
---|
73 | ! 3 => ECEPP with Abagyan corrections
|
---|
74 | !
|
---|
75 |
|
---|
76 | sh2=.false. ! .true. for ECEPP/2; .false. for ECEPP3
|
---|
77 | epsd=.false. ! .true. for distance-dependent epsilon
|
---|
78 |
|
---|
79 | itysol= 1 ! 0: vacuum
|
---|
80 | ! >0: numerical solvent energy
|
---|
81 | ! <0: analytical solvent energy & gradients
|
---|
82 | isolscl=.false.
|
---|
83 | tesgrd=.false. ! .true. to check analytical gradients
|
---|
84 |
|
---|
85 | call init_energy(libdir)
|
---|
86 |
|
---|
87 | ! calculate CPU time using MPI_Wtime()
|
---|
88 | startwtime = MPI_Wtime()
|
---|
89 |
|
---|
90 |
|
---|
91 | ! ================================================= Structure setup
|
---|
92 | grpn = 'nh2' ! N-terminal group
|
---|
93 | grpc = 'cooh' ! C-terminal group
|
---|
94 |
|
---|
95 | iabin = 1 ! =0: read from PDB-file
|
---|
96 | ! =1: ab Initio from sequence (& variables)
|
---|
97 |
|
---|
98 | in_fil='abeta.seq' ! Sequence file
|
---|
99 | varfile = ' '
|
---|
100 |
|
---|
101 | newsta=.true.
|
---|
102 | boxsize = 1000.0d0 ! Only relevant for multi-molecule systems
|
---|
103 | num_replica = 8 ! Number of independent replicas. The file
|
---|
104 | ! temperatures must have at least as many
|
---|
105 | ! entries
|
---|
106 | nequi=100 ! Number of MC sweeps before measurements
|
---|
107 | ! and replica exchanges are started
|
---|
108 | nswp=10000 ! Number of sweeps
|
---|
109 | nmes=10 ! Interval for measurements and replica exchange
|
---|
110 | nsave=1000 ! Not used at the moment
|
---|
111 |
|
---|
112 | switch = -1 ! How should the configuration be
|
---|
113 | ! initialized?
|
---|
114 | ! -1 stretched chain
|
---|
115 | ! 0 don't do anything
|
---|
116 | ! 1 initialize each angle to a random value
|
---|
117 |
|
---|
118 | ifrm=0
|
---|
119 | ntlml = 0
|
---|
120 |
|
---|
121 | ! Decide if and when to use BGS, and initialize Lund data structures
|
---|
122 | bgsprob=0.75 ! Prob for BGS, given that it is possible
|
---|
123 | ! upchswitch= 0 => No BGS 1 => BGS with probability bgsprob
|
---|
124 | ! 2 => temperature dependent choice
|
---|
125 | upchswitch=1
|
---|
126 | rndord=.true.
|
---|
127 | ! =================================================================
|
---|
128 | ! Distribute nodes to parallel tempering tasks
|
---|
129 | ! I assume that the number of nodes available is an integer
|
---|
130 | ! multiple n of the number of replicas. Each replica then gets n
|
---|
131 | ! processors to do its energy calculation.
|
---|
132 | num_ppr = num_proc / num_replica
|
---|
133 |
|
---|
134 | call mpi_comm_group(mpi_comm_world, group_world, error)
|
---|
135 |
|
---|
136 | ! The current version doesn't require a separate variable j. I
|
---|
137 | ! could just use i * num_ppr but this way it's more flexible.
|
---|
138 | j = 0
|
---|
139 | do i = 1, num_replica
|
---|
140 | ranks(i) = j
|
---|
141 | proc_range(1) = j
|
---|
142 | proc_range(2) = j + num_ppr - 1
|
---|
143 | proc_range(3) = 1
|
---|
144 | call mpi_group_range_incl(group_world, 1, proc_range, group(i)
|
---|
145 | & ,error)
|
---|
146 | write (*,*) "Assigning rank ", j, proc_range,
|
---|
147 | & "to group", group(i)
|
---|
148 | call flush(6)
|
---|
149 | j = j + num_ppr
|
---|
150 | enddo
|
---|
151 |
|
---|
152 | do i = 1, num_replica
|
---|
153 | call mpi_comm_create(mpi_comm_world, group(i), comm(i),error)
|
---|
154 | if (comm(i).ne.MPI_COMM_NULL) then
|
---|
155 | my_mpi_comm = comm(i)
|
---|
156 | rep_id = i - 1
|
---|
157 | write (*,*) rep_id, "has comm", my_mpi_comm
|
---|
158 | call flush(6)
|
---|
159 | endif
|
---|
160 | enddo
|
---|
161 |
|
---|
162 | ! Setup the communicator used for parallel tempering
|
---|
163 | write (*,*) "PTGroup=", ranks(:num_replica)
|
---|
164 | call flush(6)
|
---|
165 | call mpi_group_incl(group_world, num_replica, ranks, group_partem,
|
---|
166 | & error)
|
---|
167 | call mpi_comm_create(mpi_comm_world, group_partem, partem_comm,
|
---|
168 | & error)
|
---|
169 |
|
---|
170 | if (partem_comm.ne.MPI_COMM_NULL) then
|
---|
171 | write (*,*) partem_comm,myrank, "is master for ", rep_id, "."
|
---|
172 | endif
|
---|
173 |
|
---|
174 | call mpi_comm_rank(my_mpi_comm,myrank,ierr)
|
---|
175 | call mpi_comm_size(my_mpi_comm,no,ierr)
|
---|
176 |
|
---|
177 | write (*,*) "My new rank is ", myrank, "of", no
|
---|
178 | call flush(6)
|
---|
179 | ! = Done setting up communicators =====================================
|
---|
180 | num_mol = 4
|
---|
181 |
|
---|
182 | if (newsta) then
|
---|
183 | varfile = ' '
|
---|
184 | do i = 1, num_mol - 1
|
---|
185 | call init_molecule(iabin, grpn, grpc,in_fil,varfile)
|
---|
186 | end do
|
---|
187 | varfile = 'abeta.var'
|
---|
188 | call init_molecule(iabin, grpn, grpc,in_fil,varfile)
|
---|
189 | else
|
---|
190 | filebase = "conf_0000.var"
|
---|
191 | varfile = ' '
|
---|
192 | do i = 1, num_mol - 1
|
---|
193 | call init_molecule(iabin, grpn, grpc,in_fil,varfile)
|
---|
194 | end do
|
---|
195 | call init_molecule(iabin, grpn, grpc,in_fil,
|
---|
196 | & fileNameMP(filebase, 6, 9, rep_id + 1))
|
---|
197 | endif
|
---|
198 | call init_lund
|
---|
199 | if (ientyp.eq.2) call init_lundff
|
---|
200 | if (ientyp.eq.3) call init_abgn
|
---|
201 |
|
---|
202 |
|
---|
203 | ! ======================================== start of parallel tempering run
|
---|
204 | write (*,*) "There are ", no,
|
---|
205 | & " processors available for ",rep_id
|
---|
206 | call flush(6)
|
---|
207 | do nml = 1, num_mol
|
---|
208 | call distributeWorkLoad(no, nml)
|
---|
209 | end do
|
---|
210 |
|
---|
211 | ! READ REFERENCE CONTACT MAP.
|
---|
212 | ! Contacts needs a reference map, and we would like to get the
|
---|
213 | ! number of existing contacts. We just use a dummy map, since
|
---|
214 | ! Abeta doesn't have a native structure.
|
---|
215 | open(12, file = 'abeta.ref', status ="old")
|
---|
216 | nresi=irsml2(nml)-irsml1(nml)+1
|
---|
217 | write (*,*) 'Number of residues:', nresi
|
---|
218 | do i=1,nresi
|
---|
219 | read(12,*) (iref(i,j), j=1,nresi)
|
---|
220 | write (*,*) iref(i,i)
|
---|
221 | ! do j = 1, nresi
|
---|
222 | ! read(12, *) iref(i,j)
|
---|
223 | ! write (*,*) i,j,iref(i,j)
|
---|
224 | ! end do
|
---|
225 | end do
|
---|
226 | nci = 0
|
---|
227 | do i=1,nresi
|
---|
228 | do j=nresi,i+3,-1
|
---|
229 | if(iref(i,j).eq.1) nci = nci + 1
|
---|
230 | end do
|
---|
231 | end do
|
---|
232 |
|
---|
233 | call setvar(1,vlvr)
|
---|
234 |
|
---|
235 | do nml = 1, num_mol
|
---|
236 | call setvar(nml,vlvr)
|
---|
237 | e1 = enyshe(nml)
|
---|
238 | write (*,*) 'Energy of molecule',nml, ' is ', e1,
|
---|
239 | & '(', eyvw, eyel, eyhb, eyvr, ')'
|
---|
240 | end do
|
---|
241 |
|
---|
242 | ei = eninteract()
|
---|
243 | write (*,*) ' Interaction energy is', ei
|
---|
244 | et = energy()
|
---|
245 | write (*,*) 'Solvent energy is', eysl
|
---|
246 | write (*,*) 'Total energy is ', et
|
---|
247 |
|
---|
248 | call partem_p(num_replica, nequi, nswp, nmes, nsave, newsta,
|
---|
249 | & switch, rep_id, partem_comm)
|
---|
250 | ! ======================================== end of parallel tempering run
|
---|
251 | ! calculate CPU time using MPI_Wtime()
|
---|
252 | endwtime = MPI_Wtime()
|
---|
253 | if(myrank.eq.0.and.rep_id.eq.0) then
|
---|
254 |
|
---|
255 | write(*,*) "time for simulation using ", num_proc,
|
---|
256 | & " processors =", endwtime - startwtime, " seconds"
|
---|
257 | call flush(6)
|
---|
258 | endif
|
---|
259 |
|
---|
260 | ! ======================================== End of main
|
---|
261 | CALL mpi_finalize(ierr)
|
---|
262 |
|
---|
263 | end
|
---|
264 |
|
---|