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)
62 write (iout,*) "Calling proc_groups"
64 write (iout,*) "proc_groups exited"
68 write (iout,*) "Calling parmread",ipar
69 call parmread(ipar,*10)
70 if (.not.separate_parset) then
72 write (iout,*) "Finished storing parameters",ipar
73 else if (ipar.eq.myparm) then
75 write (iout,*) "Finished storing parameters",ipar
80 write (iout,*) "Finished READ_EFREE"
82 call read_protein_data(*10)
83 write (iout,*) "Finished READ_PROTEIN_DATA"
88 call read_ref_structure(*10)
91 if (constr_dist.gt.0) call read_dist_constr
93 write (iout,*) "Begin read_database"
95 call read_database(*10)
96 write (iout,*) "Finished read_database"
98 if (separate_parset) nparmset=1
100 if (ntot(islice).gt.0) then
102 call work_partition(islice,.true.)
103 write (iout,*) "work_partition OK"
106 call enecalc(islice,*10)
107 write (iout,*) "enecalc OK"
109 call WHAM_CALC(islice,*10)
110 write (iout,*) "wham_calc OK"
112 call write_dbase(islice,*10)
113 write (iout,*) "write_dbase OK"
115 if (ensembles.gt.0) then
116 call make_ensembles(islice,*10)
117 write (iout,*) "make_ensembles OK"
123 call MPI_Finalize( IERROR )
126 10 write (iout,*) "Error termination of the program"
127 call MPI_Finalize( IERROR )
130 c------------------------------------------------------------------------------
132 subroutine proc_groups
133 C Split the processors into the Master and Workers group, if needed.
136 include "DIMENSIONS.ZSCOPT"
137 include "DIMENSIONS.FREE"
139 include "COMMON.IOUNITS"
141 include "COMMON.FREE"
142 integer n,chunk,i,j,ii,remainder
143 integer kolor,key,ierror,errcode
147 C Split the communicator if independent runs for different parameter
148 C sets will be performed.
150 if (nparmset.eq.1 .or. .not.separate_parset) then
151 WHAM_COMM = MPI_COMM_WORLD
152 else if (separate_parset) then
153 if (nprocs.lt.nparmset) then
155 & "*** Cannot split parameter sets for fewer processors than sets",
157 call MPI_Finalize(ierror)
160 write (iout,*) "nparmset",nparmset
161 nprocs = nprocs/nparmset
164 write (iout,*) "My old rank",me," kolor",kolor," key",key
165 call MPI_Comm_split(MPI_COMM_WORLD,kolor,key,WHAM_COMM,ierror)
166 call MPI_Comm_size(WHAM_COMM,nprocs,ierror)
167 call MPI_Comm_rank(WHAM_COMM,me,ierror)
168 write (iout,*) "My new rank",me," comm size",nprocs
169 write (iout,*) "MPI_COMM_WORLD",MPI_COMM_WORLD,
170 & " WHAM_COMM",WHAM_COMM
172 write (iout,*) "My parameter set is",myparm
181 c------------------------------------------------------------------------------
182 subroutine work_partition(islice,lprint)
183 c Split the conformations between processors
186 include "DIMENSIONS.ZSCOPT"
187 include "DIMENSIONS.FREE"
189 include "COMMON.IOUNITS"
191 include "COMMON.PROT"
193 integer n,chunk,i,j,ii,remainder
194 integer kolor,key,ierror,errcode
197 C Divide conformations between processors; the first and
198 C the last conformation to handle by ith processor is stored in
199 C indstart(i) and indend(i), respectively.
201 C First try to assign equal number of conformations to each processor.
204 write (iout,*) "n=",n
208 c print *,"i",0," indstart",indstart(0)," scount",
211 indstart(i)=chunk+indstart(i-1)
212 scount(i)=scount(i-1)
213 c print *,"i",i," indstart",indstart(i)," scount",
217 C Determine how many conformations remained yet unassigned.
219 remainder=N-(indstart(nprocs1-1)
220 & +scount(nprocs1-1)-1)
221 c print *,"remainder",remainder
223 C Assign the remainder conformations to consecutive processors, starting
224 C from the lowest rank; this continues until the list is exhausted.
226 if (remainder .gt. 0) then
228 scount(i-1) = scount(i-1) + 1
229 indstart(i) = indstart(i) + i
231 do i=remainder+1,nprocs1-1
232 indstart(i) = indstart(i) + remainder
236 indstart(nprocs1)=N+1
240 indend(i)=indstart(i)+scount(i)-1
241 idispl(i)=indstart(i)-1
246 N=N+indend(i)-indstart(i)+1
249 c print *,"N",n," NTOT",ntot(islice)
250 if (N.ne.ntot(islice)) then
251 write (iout,*) "!!! Checksum error on processor",me,
254 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
258 write (iout,*) "Partition of work between processors"
260 write (iout,'(a,i5,a,i7,a,i7,a,i7)')
261 & "Processor",i," indstart",indstart(i),
262 & " indend",indend(i)," count",scount(i)