1 | c **************************************************************
|
---|
2 | c
|
---|
3 | c This file contains the main (PARALLEL TEMPERING JOBS ONLY,
|
---|
4 | C FOR SINGULAR PROCESSOR JOBS USE main)
|
---|
5 | C
|
---|
6 | C This file contains also the subroutine: p_init_molecule
|
---|
7 | c
|
---|
8 | c Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
9 | c Shura Hayryan, Chin-Ku
|
---|
10 | c Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
11 | c Jan H. Meinke, Sandipan Mohanty
|
---|
12 | c
|
---|
13 | C CALLS init_energy,p_init_molecule,partem_p
|
---|
14 | C
|
---|
15 | c **************************************************************
|
---|
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 | cc Number of replicas
|
---|
31 | integer num_replica
|
---|
32 | cc Number of processors per replica
|
---|
33 | integer num_ppr
|
---|
34 | cc Range of processor for crating communicators
|
---|
35 | integer proc_range(3)
|
---|
36 | cc Array of MPI groups
|
---|
37 | integer group(MAX_REPLICA), group_partem
|
---|
38 | cc Array of MPI communicators
|
---|
39 | integer comm(MAX_REPLICA), partem_comm
|
---|
40 | cc Array of nodes acting as masters for the energy calculation.
|
---|
41 | integer ranks(MAX_REPLICA)
|
---|
42 | cc Configuration switch
|
---|
43 | integer switch
|
---|
44 | integer rep_id
|
---|
45 | c set number of replicas
|
---|
46 | double precision eols(MAX_REPLICA)
|
---|
47 |
|
---|
48 |
|
---|
49 | common/updstats/ncalls(5),nacalls(5)
|
---|
50 |
|
---|
51 |
|
---|
52 | c 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 | c =================================================== Energy setup
|
---|
64 | libdir='SMMP/'
|
---|
65 | c Directory for SMMP libraries
|
---|
66 |
|
---|
67 | c The switch in the following line is now not used.
|
---|
68 | flex=.false. ! .true. for Flex / .false. for ECEPP
|
---|
69 |
|
---|
70 | c Choose energy type with the following switch instead ...
|
---|
71 | ientyp = 0
|
---|
72 | c 0 => ECEPP2 or ECEPP3 depending on the value of sh2
|
---|
73 | c 1 => FLEX
|
---|
74 | c 2 => Lund force field
|
---|
75 | c 3 => ECEPP with Abagyan corrections
|
---|
76 | c
|
---|
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 | c calculate CPU time using MPI_Wtime()
|
---|
90 | startwtime = MPI_Wtime()
|
---|
91 |
|
---|
92 |
|
---|
93 | c ================================================= 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 | c 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 | c upchswitch= 0 => No BGS 1 => BGS with probability bgsprob
|
---|
126 | c 2 => temperature dependent choice
|
---|
127 | upchswitch=1
|
---|
128 | rndord=.true.
|
---|
129 | if (ientyp.eq.2) call init_lundff
|
---|
130 | c =================================================================
|
---|
131 | c Distribute nodes to parallel tempering tasks
|
---|
132 | c I assume that the number of nodes available is an integer
|
---|
133 | c multiple n of the number of replicas. Each replica then gets n
|
---|
134 | c processors to do its energy calculation.
|
---|
135 | num_ppr = num_proc / num_replica
|
---|
136 |
|
---|
137 | call mpi_comm_group(mpi_comm_world, group_world, error)
|
---|
138 |
|
---|
139 | c The current version doesn't require a separate variable j. I
|
---|
140 | c could just use i * num_ppr but this way it's more flexible.
|
---|
141 | j = 0
|
---|
142 | do i = 1, num_replica
|
---|
143 | ranks(i) = j
|
---|
144 | proc_range(1) = j
|
---|
145 | proc_range(2) = j + num_ppr - 1
|
---|
146 | proc_range(3) = 1
|
---|
147 | call mpi_group_range_incl(group_world, 1, proc_range, group(i)
|
---|
148 | & ,error)
|
---|
149 | write (*,*) "Assigning rank ", j, proc_range,
|
---|
150 | & "to group", group(i)
|
---|
151 | call flush(6)
|
---|
152 | j = j + num_ppr
|
---|
153 | enddo
|
---|
154 |
|
---|
155 | do i = 1, num_replica
|
---|
156 | call mpi_comm_create(mpi_comm_world, group(i), comm(i),error)
|
---|
157 | if (comm(i).ne.MPI_COMM_NULL) then
|
---|
158 | my_mpi_comm = comm(i)
|
---|
159 | rep_id = i - 1
|
---|
160 | write (*,*) rep_id, "has comm", my_mpi_comm
|
---|
161 | call flush(6)
|
---|
162 | endif
|
---|
163 | enddo
|
---|
164 |
|
---|
165 | c Setup the communicator used for parallel tempering
|
---|
166 | write (*,*) "PTGroup=", ranks(:num_replica)
|
---|
167 | call flush(6)
|
---|
168 | call mpi_group_incl(group_world, num_replica, ranks, group_partem,
|
---|
169 | & error)
|
---|
170 | call mpi_comm_create(mpi_comm_world, group_partem, partem_comm,
|
---|
171 | & error)
|
---|
172 |
|
---|
173 | if (partem_comm.ne.MPI_COMM_NULL) then
|
---|
174 | write (*,*) partem_comm,myrank, "is master for ", rep_id, "."
|
---|
175 | endif
|
---|
176 |
|
---|
177 | call mpi_comm_rank(my_mpi_comm,myrank,ierr)
|
---|
178 | call mpi_comm_size(my_mpi_comm,no,ierr)
|
---|
179 |
|
---|
180 | write (*,*) "My new rank is ", myrank, "of", no
|
---|
181 | call flush(6)
|
---|
182 | ! = Done setting up communicators =====================================
|
---|
183 |
|
---|
184 | if (newsta) then
|
---|
185 | varfile = 'EXAMPLES/1bdd.var'
|
---|
186 | call init_molecule(iabin, grpn, grpc,in_fil,varfile)
|
---|
187 | else
|
---|
188 | filebase = "conf_0000.var"
|
---|
189 | call init_molecule(iabin, grpn, grpc,in_fil,
|
---|
190 | & fileNameMP(filebase, 6, 9, rep_id + 1))
|
---|
191 | endif
|
---|
192 | if (ientyp.eq.3) call init_abgn
|
---|
193 |
|
---|
194 | nml = 1
|
---|
195 |
|
---|
196 | c RRRRRRRRRRMMMMMMMMMMMMSSSSSSSSSSDDDDDDDDDDDDD
|
---|
197 | call rmsinit(nml,'EXAMPLES/1bdd.pdb')
|
---|
198 | c RRRRRRRRRRMMMMMMMMMMMMSSSSSSSSSSDDDDDDDDDDDDD
|
---|
199 |
|
---|
200 | ! READ REFERENCE CONTACT MAP
|
---|
201 | open(12, file = 'EXAMPLES/1bdd.ref', status ="old")
|
---|
202 | nresi=irsml2(nml)-irsml1(nml)+1
|
---|
203 | do i=1,nresi
|
---|
204 | read(12,*) (iref(i,j), j=1,nresi)
|
---|
205 | end do
|
---|
206 | nci = 0
|
---|
207 | do i=1,nresi
|
---|
208 | do j=nresi,i+3,-1
|
---|
209 | if(iref(i,j).eq.1) nci = nci + 1
|
---|
210 | end do
|
---|
211 | end do
|
---|
212 |
|
---|
213 | c ======================================== start of parallel tempering run
|
---|
214 | write (*,*) "There are ", no,
|
---|
215 | & " processors available for ",rep_id
|
---|
216 | call flush(6)
|
---|
217 | nml = 1
|
---|
218 | call distributeWorkLoad(no, nml)
|
---|
219 |
|
---|
220 | call partem_p(num_replica, nequi, nswp, nmes, nsave, newsta,
|
---|
221 | & switch, rep_id, partem_comm)
|
---|
222 | c ======================================== end of parallel tempering run
|
---|
223 | c calculate CPU time using MPI_Wtime()
|
---|
224 | endwtime = MPI_Wtime()
|
---|
225 |
|
---|
226 |
|
---|
227 | if(my_pt_rank.eq.0) then
|
---|
228 | write(*,*) "time for simulation using ", num_proc,
|
---|
229 | & " processors =", endwtime - startwtime, " seconds"
|
---|
230 | call flush(6)
|
---|
231 | endif
|
---|
232 |
|
---|
233 | print *,'update type, num calls, accepted calls '
|
---|
234 | do i=1,5
|
---|
235 | print *,i,ncalls(i),nacalls(i)
|
---|
236 | enddo
|
---|
237 |
|
---|
238 | c ======================================== End of main
|
---|
239 | CALL mpi_finalize(ierr)
|
---|
240 |
|
---|
241 | end
|
---|
242 |
|
---|