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