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,*) "1,4 SCSC repulsive interactions sacled down by 10"
71 write (iout,*) "Calling parmread",ipar
72 call parmread(ipar,*10)
73 if (.not.separate_parset) then
75 write (iout,*) "Finished storing parameters",ipar
76 else if (ipar.eq.myparm) then
78 write (iout,*) "Finished storing parameters",ipar
83 write (iout,*) "Finished READ_EFREE"
85 call read_protein_data(*10)
86 write (iout,*) "Finished READ_PROTEIN_DATA"
91 call read_ref_structure(*10)
95 write (iout,*) "Begin read_database"
97 call read_database(*10)
98 write (iout,*) "Finished read_database"
100 if (separate_parset) nparmset=1
102 if (ntot(islice).gt.0) then
104 call work_partition(islice,.true.)
105 write (iout,*) "work_partition OK"
108 call enecalc(islice,*10)
109 write (iout,*) "enecalc OK"
111 write (iout,*) "Calling WHAM_calc"
113 call WHAM_CALC(islice,*10)
114 write (iout,*) "wham_calc OK"
116 call write_dbase(islice,*10)
117 write (iout,*) "write_dbase OK"
119 if (ensembles.gt.0) then
120 call make_ensembles(islice,*10)
121 write (iout,*) "make_ensembles OK"
127 call MPI_Finalize( IERROR )
130 10 write (iout,*) "Error termination of the program"
131 call MPI_Finalize( IERROR )
134 c------------------------------------------------------------------------------
136 subroutine proc_groups
137 C Split the processors into the Master and Workers group, if needed.
140 include "DIMENSIONS.ZSCOPT"
141 include "DIMENSIONS.FREE"
143 include "COMMON.IOUNITS"
145 include "COMMON.FREE"
146 integer n,chunk,i,j,ii,remainder
147 integer kolor,key,ierror,errcode
151 C Split the communicator if independent runs for different parameter
152 C sets will be performed.
154 if (nparmset.eq.1 .or. .not.separate_parset) then
155 WHAM_COMM = MPI_COMM_WORLD
156 else if (separate_parset) then
157 if (nprocs.lt.nparmset) then
159 & "*** Cannot split parameter sets for fewer processors than sets",
161 call MPI_Finalize(ierror)
164 write (iout,*) "nparmset",nparmset
165 nprocs = nprocs/nparmset
168 write (iout,*) "My old rank",me," kolor",kolor," key",key
169 call MPI_Comm_split(MPI_COMM_WORLD,kolor,key,WHAM_COMM,ierror)
170 call MPI_Comm_size(WHAM_COMM,nprocs,ierror)
171 call MPI_Comm_rank(WHAM_COMM,me,ierror)
172 write (iout,*) "My new rank",me," comm size",nprocs
173 write (iout,*) "MPI_COMM_WORLD",MPI_COMM_WORLD,
174 & " WHAM_COMM",WHAM_COMM
176 write (iout,*) "My parameter set is",myparm
185 c------------------------------------------------------------------------------
186 subroutine work_partition(islice,lprint)
187 c Split the conformations between processors
190 include "DIMENSIONS.ZSCOPT"
191 include "DIMENSIONS.FREE"
193 include "COMMON.IOUNITS"
195 include "COMMON.PROT"
197 integer n,chunk,i,j,ii,remainder
198 integer kolor,key,ierror,errcode
201 C Divide conformations between processors; the first and
202 C the last conformation to handle by ith processor is stored in
203 C indstart(i) and indend(i), respectively.
205 C First try to assign equal number of conformations to each processor.
208 write (iout,*) "n=",n
212 c print *,"i",0," indstart",indstart(0)," scount",
215 indstart(i)=chunk+indstart(i-1)
216 scount(i)=scount(i-1)
217 c print *,"i",i," indstart",indstart(i)," scount",
221 C Determine how many conformations remained yet unassigned.
223 remainder=N-(indstart(nprocs1-1)
224 & +scount(nprocs1-1)-1)
225 c print *,"remainder",remainder
227 C Assign the remainder conformations to consecutive processors, starting
228 C from the lowest rank; this continues until the list is exhausted.
230 if (remainder .gt. 0) then
232 scount(i-1) = scount(i-1) + 1
233 indstart(i) = indstart(i) + i
235 do i=remainder+1,nprocs1-1
236 indstart(i) = indstart(i) + remainder
240 indstart(nprocs1)=N+1
244 indend(i)=indstart(i)+scount(i)-1
245 idispl(i)=indstart(i)-1
250 N=N+indend(i)-indstart(i)+1
253 c print *,"N",n," NTOT",ntot(islice)
254 if (N.ne.ntot(islice)) then
255 write (iout,*) "!!! Checksum error on processor",me,
258 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
262 write (iout,*) "Partition of work between processors"
264 write (iout,'(a,i5,a,i7,a,i7,a,i7)')
265 & "Processor",i," indstart",indstart(i),
266 & " indend",indend(i)," count",scount(i)