2 c Creation/update of the database of conformations
8 cMS$ATTRIBUTES C :: proc_proc
11 include "DIMENSIONS.ZSCOPT"
12 include "DIMENSIONS.FREE"
15 integer IERROR,ERRCODE
18 include "COMMON.IOUNITS"
20 include "COMMON.CONTROL"
21 include "COMMON.ALLPARM"
23 double precision rr,x(max_paropt)
27 call MPI_Init( IERROR )
28 call MPI_Comm_rank( MPI_COMM_WORLD, me, IERROR )
29 call MPI_Comm_size( MPI_COMM_WORLD, nprocs, IERROR )
32 write(iout,*) "SEVERE ERROR - Can't initialize MPI."
33 call mpi_finalize(ierror)
36 if (nprocs.gt.MaxProcs+1) then
37 write (2,*) "Error - too many processors",
39 write (2,*) "Increase MaxProcs and recompile"
40 call MPI_Finalize(IERROR)
57 write (iout,*) "calling read_general_data"
58 call read_general_data(*10)
59 write (iout,*) "read_general_data"
61 write (iout,*) "calling molread"
63 write (iout,*) "molread"
65 write (iout,*) "MAIN: constr_dist",constr_dist
66 if (constr_dist.gt.0) call read_dist_constr
68 c write (iout,*) "Calling proc_groups"
70 c write (iout,*) "proc_groups exited"
74 write (iout,*) "Calling parmread",ipar
75 call parmread(ipar,*10)
76 if (.not.separate_parset) then
78 write (iout,*) "Finished storing parameters",ipar
79 else if (ipar.eq.myparm) then
81 write (iout,*) "Finished storing parameters",ipar
86 if (adaptive) call PMFread
87 c write (iout,*) "Finished READ_EFREE"
89 call read_protein_data(*10)
90 c write (iout,*) "Finished READ_PROTEIN_DATA"
95 call read_ref_structure(*10)
99 C if (constr_dist.gt.0) call read_dist_constr
100 c write (iout,*) "Begin read_database"
102 call read_database(*10)
103 write (iout,*) "Finished read_database"
105 if (separate_parset) nparmset=1
107 if (ntot(islice).gt.0) then
109 call work_partition(islice,.true.)
110 write (iout,*) "work_partition OK"
113 call enecalc(islice,*10)
114 write (iout,*) "enecalc OK"
116 call WHAM_CALC(islice,*10)
117 write (iout,*) "wham_calc OK"
119 call write_dbase(islice,*10)
120 write (iout,*) "write_dbase OK"
122 if (ensembles.gt.0) then
123 call make_ensembles(islice,*10)
124 write (iout,*) "make_ensembles OK"
130 call MPI_Finalize( IERROR )
133 10 write (iout,*) "Error termination of the program"
134 call MPI_Finalize( IERROR )
137 c------------------------------------------------------------------------------
139 subroutine proc_groups
140 C Split the processors into the Master and Workers group, if needed.
143 include "DIMENSIONS.ZSCOPT"
144 include "DIMENSIONS.FREE"
146 include "COMMON.IOUNITS"
148 include "COMMON.FREE"
149 integer n,chunk,i,j,ii,remainder
150 integer kolor,key,ierror,errcode
154 C Split the communicator if independent runs for different parameter
155 C sets will be performed.
157 if (nparmset.eq.1 .or. .not.separate_parset) then
158 WHAM_COMM = MPI_COMM_WORLD
159 else if (separate_parset) then
160 if (nprocs.lt.nparmset) then
162 & "*** Cannot split parameter sets for fewer processors than sets",
164 call MPI_Finalize(ierror)
167 write (iout,*) "nparmset",nparmset
168 nprocs = nprocs/nparmset
171 write (iout,*) "My old rank",me," kolor",kolor," key",key
172 call MPI_Comm_split(MPI_COMM_WORLD,kolor,key,WHAM_COMM,ierror)
173 call MPI_Comm_size(WHAM_COMM,nprocs,ierror)
174 call MPI_Comm_rank(WHAM_COMM,me,ierror)
175 write (iout,*) "My new rank",me," comm size",nprocs
176 write (iout,*) "MPI_COMM_WORLD",MPI_COMM_WORLD,
177 & " WHAM_COMM",WHAM_COMM
179 write (iout,*) "My parameter set is",myparm
188 c------------------------------------------------------------------------------
189 subroutine work_partition(islice,lprint)
190 c Split the conformations between processors
193 include "DIMENSIONS.ZSCOPT"
194 include "DIMENSIONS.FREE"
196 include "COMMON.IOUNITS"
198 include "COMMON.PROT"
200 integer n,chunk,i,j,ii,remainder
201 integer kolor,key,ierror,errcode
204 C Divide conformations between processors; the first and
205 C the last conformation to handle by ith processor is stored in
206 C indstart(i) and indend(i), respectively.
208 C First try to assign equal number of conformations to each processor.
211 write (iout,*) "n=",n
215 c print *,"i",0," indstart",indstart(0)," scount",
218 indstart(i)=chunk+indstart(i-1)
219 scount(i)=scount(i-1)
220 c print *,"i",i," indstart",indstart(i)," scount",
224 C Determine how many conformations remained yet unassigned.
226 remainder=N-(indstart(nprocs1-1)
227 & +scount(nprocs1-1)-1)
228 c print *,"remainder",remainder
230 C Assign the remainder conformations to consecutive processors, starting
231 C from the lowest rank; this continues until the list is exhausted.
233 if (remainder .gt. 0) then
235 scount(i-1) = scount(i-1) + 1
236 indstart(i) = indstart(i) + i
238 do i=remainder+1,nprocs1-1
239 indstart(i) = indstart(i) + remainder
243 indstart(nprocs1)=N+1
247 indend(i)=indstart(i)+scount(i)-1
248 idispl(i)=indstart(i)-1
253 N=N+indend(i)-indstart(i)+1
256 c print *,"N",n," NTOT",ntot(islice)
257 if (N.ne.ntot(islice)) then
258 write (iout,*) "!!! Checksum error on processor",me,
261 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
265 write (iout,*) "Partition of work between processors"
267 write (iout,'(a,i5,a,i7,a,i7,a,i7)')
268 & "Processor",i," indstart",indstart(i),
269 & " indend",indend(i)," count",scount(i)