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 call read_general_data(*10)
58 c write (iout,*) "read_general_data"
61 c write (iout,*) "molread"
63 c write (iout,*) "MAIN: constr_dist",constr_dist
64 if (constr_dist.gt.0) call read_dist_constr
66 c write (iout,*) "Calling proc_groups"
68 c write (iout,*) "proc_groups exited"
72 c write (iout,*) "Calling parmread",ipar
73 call parmread(ipar,*10)
74 if (.not.separate_parset) then
76 c write (iout,*) "Finished storing parameters",ipar
77 else if (ipar.eq.myparm) then
79 c write (iout,*) "Finished storing parameters",ipar
84 if (adaptive) call PMFread
85 c write (iout,*) "Finished READ_EFREE"
87 call read_protein_data(*10)
88 c write (iout,*) "Finished READ_PROTEIN_DATA"
93 call read_ref_structure(*10)
97 C if (constr_dist.gt.0) call read_dist_constr
98 c write (iout,*) "Begin read_database"
100 call read_database(*10)
101 write (iout,*) "Finished read_database"
103 if (separate_parset) nparmset=1
105 if (ntot(islice).gt.0) then
107 call work_partition(islice,.true.)
108 write (iout,*) "work_partition OK"
111 call enecalc(islice,*10)
112 write (iout,*) "enecalc OK"
114 call WHAM_CALC(islice,*10)
115 write (iout,*) "wham_calc OK"
117 call write_dbase(islice,*10)
118 write (iout,*) "write_dbase OK"
120 if (ensembles.gt.0) then
121 call make_ensembles(islice,*10)
122 write (iout,*) "make_ensembles OK"
128 call MPI_Finalize( IERROR )
131 10 write (iout,*) "Error termination of the program"
132 call MPI_Finalize( IERROR )
135 c------------------------------------------------------------------------------
137 subroutine proc_groups
138 C Split the processors into the Master and Workers group, if needed.
141 include "DIMENSIONS.ZSCOPT"
142 include "DIMENSIONS.FREE"
144 include "COMMON.IOUNITS"
146 include "COMMON.FREE"
147 integer n,chunk,i,j,ii,remainder
148 integer kolor,key,ierror,errcode
152 C Split the communicator if independent runs for different parameter
153 C sets will be performed.
155 if (nparmset.eq.1 .or. .not.separate_parset) then
156 WHAM_COMM = MPI_COMM_WORLD
157 else if (separate_parset) then
158 if (nprocs.lt.nparmset) then
160 & "*** Cannot split parameter sets for fewer processors than sets",
162 call MPI_Finalize(ierror)
165 write (iout,*) "nparmset",nparmset
166 nprocs = nprocs/nparmset
169 write (iout,*) "My old rank",me," kolor",kolor," key",key
170 call MPI_Comm_split(MPI_COMM_WORLD,kolor,key,WHAM_COMM,ierror)
171 call MPI_Comm_size(WHAM_COMM,nprocs,ierror)
172 call MPI_Comm_rank(WHAM_COMM,me,ierror)
173 write (iout,*) "My new rank",me," comm size",nprocs
174 write (iout,*) "MPI_COMM_WORLD",MPI_COMM_WORLD,
175 & " WHAM_COMM",WHAM_COMM
177 write (iout,*) "My parameter set is",myparm
186 c------------------------------------------------------------------------------
187 subroutine work_partition(islice,lprint)
188 c Split the conformations between processors
191 include "DIMENSIONS.ZSCOPT"
192 include "DIMENSIONS.FREE"
194 include "COMMON.IOUNITS"
196 include "COMMON.PROT"
198 integer n,chunk,i,j,ii,remainder
199 integer kolor,key,ierror,errcode
202 C Divide conformations between processors; the first and
203 C the last conformation to handle by ith processor is stored in
204 C indstart(i) and indend(i), respectively.
206 C First try to assign equal number of conformations to each processor.
209 write (iout,*) "n=",n
213 c print *,"i",0," indstart",indstart(0)," scount",
216 indstart(i)=chunk+indstart(i-1)
217 scount(i)=scount(i-1)
218 c print *,"i",i," indstart",indstart(i)," scount",
222 C Determine how many conformations remained yet unassigned.
224 remainder=N-(indstart(nprocs1-1)
225 & +scount(nprocs1-1)-1)
226 c print *,"remainder",remainder
228 C Assign the remainder conformations to consecutive processors, starting
229 C from the lowest rank; this continues until the list is exhausted.
231 if (remainder .gt. 0) then
233 scount(i-1) = scount(i-1) + 1
234 indstart(i) = indstart(i) + i
236 do i=remainder+1,nprocs1-1
237 indstart(i) = indstart(i) + remainder
241 indstart(nprocs1)=N+1
245 indend(i)=indstart(i)+scount(i)-1
246 idispl(i)=indstart(i)-1
251 N=N+indend(i)-indstart(i)+1
254 c print *,"N",n," NTOT",ntot(islice)
255 if (N.ne.ntot(islice)) then
256 write (iout,*) "!!! Checksum error on processor",me,
259 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
263 write (iout,*) "Partition of work between processors"
265 write (iout,'(a,i5,a,i7,a,i7,a,i7)')
266 & "Processor",i," indstart",indstart(i),
267 & " indend",indend(i)," count",scount(i)