3 include "DIMENSIONS.ZSCOPT"
7 include 'COMMON.MPISET'
9 double precision bufin(maxpoint),bufout(maxpoint)
11 include "COMMON.PMFDERIV"
12 include "COMMON.IOUNITS"
13 include "COMMON.WEIGHTS"
14 c include "COMMON.MARQ"
15 c character*64 fname(8)
17 character*1 typ(-2:2) /'p','a','G','A','P'/
19 character*16 pmf_print
23 double precision rjunk,sumw(4)
24 write (iout,*) "Calling PMFREAD",torsion_pmf,turn_pmf,eello_pmf
25 call getenv("PMF_DIR",pmf_dir)
26 call getenv("PMF_INFIX",pmf_infix)
27 write (iout,*) "PMF_DIR ",PMF_DIR
28 write (iout,*) "PMF_INFIX",PMF_INFIX
29 call getenv("PMF_PRINT",pmf_print)
30 lprn=index(pmf_print,"PMF_PRINT").gt.0
33 c read(iparin,'(e20.10,1x,a)') x(i),parname(i)
34 c print *,i,x(i)," ",parname(i)
44 c read (iparin,*,end=12,err=12)
45 c & maxit,maxmar,rl,vmarq,tolx,tolf,rtolf,tollam
47 c write (iout,'(//21(1h*)/a/21(1h*))') "Initial parameters:"
49 c write (iout,'(i3,1x,a16,f10.5)') i,parname(i),x(i)
54 c write (iout,'(a,i3)') 'number of variables ',m
55 c write (iout,'(a,i3)') 'number of parameters ',n
71 if (torsion_pmf .or. turn_pmf) then
74 write (iout,*) "Master",Master
75 if (me.eq.Master) then
77 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//typ(it1)//typ(it2)//"_"
78 & //PMF_INFIX(:ilen(PMF_INFIX))
80 write (iout,*) "Reading torsional and turn PMFs"
81 write (iout,'(2a)') "Torsional and turn3 potential file ",torfile
82 open(89,file=torfile,status="old",err=99)
86 read (89,*,end=13,err=13) zz(1,ii),zz(2,ii),zz(3,ii),y(1,ii),
88 if (y(1,ii).ge.999.0 .or. y(2,ii).ge.999.0) cycle
89 c if (zz(1,ii).ne.75.0d0 .or. zz(2,ii).ne.130.0d0 .or.
90 c & zz(3,ii).ne.-45.0d0) cycle
92 & write(iout,'(i7,3f7.1,2f10.5)')ii,zz(1,ii),zz(2,ii),zz(3,ii),
98 npoint=npoint+2*np(it1,it2)
100 write (iout,*)np(it1,it2)," data points found in file"
101 write (iout,*)npoint," data points found so far"
107 if (y(1,i).gt.ymax) ymax=y(1,i)
108 if (y(1,i).lt.ymin) ymin=y(1,i)
111 if (ifunmode.eq.0) then
112 w(1,i)=dexp(-0.169*(y(1,i)-ymin))
113 w(2,i)=1.0*dexp(-0.168*y(2,i))
117 if (y(1,i).ge.999.0) w(1,i)=0.0d0
118 if (y(2,i).ge.999.0) w(2,i)=0.0d0
121 sumw(j)=sumw(j)+w(j,i)
126 w(j,i)=w(j,i)/sumw(j)
132 call work_partition_pmf(np_,.true.)
136 write (iout,*) "After scatter"
137 write (iout,*) "scount_pmf",(scount_pmf(i),i=1,procs)
139 call MPI_Scatter(scount_pmf,1,MPI_INTEGER,np(it1,it2),1,
140 & MPI_INTEGER,Master,WHAM_COMM,ierror)
141 write (iout,*) "After scatter scount np",np(it1,it2)
147 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
148 & MPI_DOUBLE_PRECISION,
149 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
152 y(j,i+i1-1)=bufout(i)
154 write (iout,*) "After scatter y",j
159 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
160 & MPI_DOUBLE_PRECISION,
161 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
164 w(j,i+i1-1)=bufout(i)
166 write (iout,*) "After scatter w",j
173 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
174 & MPI_DOUBLE_PRECISION,
175 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
177 write (iout,*) "After scatter z",j
180 zz(j,i+i1-1)=bufout(i)
184 write (iout,*) "Distributed etor and eturn"
185 do i=i1,i1+np(it1,it2)-1
186 write(iout,'(i7,3f7.1,2f10.5)')i,(zz(j,i),j=1,3),(y(j,i),j=1,2)
193 write (iout,*)np(it1,it2)," data points found in file"
195 endif ! torsion_pmf .or. turn_pmf
202 if (me.eq.Master) then
204 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//typ(it1)//typ(it2)//"_"//
205 & PMF_INFIX(:ilen(PMF_INFIX))
207 write (iout,*) "Reading eello3 PMFs"
208 write (iout,'(2a)') "local-electrostatic PMF file ",torfile
209 open(89,file=torfile,status="old",err=99)
213 read (89,*,end=133,err=133) (zz(j,ii),j=1,8),(y(j,ii),j=1,4)
214 if (y(1,ii).ge.999.0 .or. y(2,ii).ge.999.0 .or. y(3,ii).ge.999.0
215 & .or. y(4,ii).ge.999.0) cycle
216 if (lprn) write(iout,'(i7,8f7.1,4f10.5)')ii,(zz(j,ii),j=1,8),
221 133 npel(it1,it2)=iii-1
223 npoint=npoint+npel(it1,it2)*4
227 if (ifunmode.eq.0) then
228 w(j,ii)=10*dexp(-0.169*(y(j,ii)))
234 sumw(j)=sumw(j)+w(j,i)
239 w(j,i)=w(j,i)/sumw(j)
244 call work_partition_pmf(np_,.true.)
248 write (iout,*) "Before scatter npel"
249 call MPI_Scatter(scount_pmf,1,MPI_INTEGER,npel(it1,it2),1,
250 & MPI_INTEGER,Master,WHAM_COMM,ierror)
251 write (iout,*) "After scatter scount npel",npel(it1,it2)
257 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
258 & MPI_DOUBLE_PRECISION,
259 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
261 write (iout,*) "After scatter y",j
264 y(j,i+i1-1)=bufout(i)
269 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
270 & MPI_DOUBLE_PRECISION,
271 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
273 write (iout,*) "After scatter w",j
276 w(j,i+i1-1)=bufout(i)
283 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
284 & MPI_DOUBLE_PRECISION,
285 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
288 zz(j,i+i1-1)=bufout(i)
290 write (iout,*) "After scatter z",j
294 write (iout,*) "Distributed eelloc"
295 do i=i1,i1+npel(it1,it2)-1
296 write(iout,'(i7,8f7.1,4f10.5)')i,(zz(j,i),j=1,8),(y(j,i),j=1,4)
303 write (iout,*)npel(it1,it2)," data points found in file"
304 write (iout,*)npoint," data points found so far"
313 99 write (iout,*) "Error opening PMF fiie(s)"
317 c-------------------------------------------------------------------------------
318 subroutine work_partition_pmf(n,lprint)
321 include "DIMENSIONS.ZSCOPT"
324 include 'COMMON.MPISET'
325 integer ierror,errcode
326 integer n,ntot,nn,chunk,i,remainder
330 C Divide conformations between processors; for each proteins the first and
331 C the last conformation to handle by ith processor is stored in
332 C indstart(i) and indend(i), respectively.
334 C First try to assign equal number of conformations to each processor.
339 scount_pmf(0) = chunk
341 indstart_pmf(i)=chunk+indstart_pmf(i-1)
342 scount_pmf(i)=scount_pmf(i-1)
345 C Determine how many conformations remained yet unassigned.
347 remainder=N-(indstart_pmf(nprocs1-1)+scount_pmf(nprocs1-1)-1)
348 c print *,"remainder",remainder
350 C Assign the remainder conformations to consecutive processors, starting
351 C from the lowest rank; this continues until the list is exhausted.
353 if (remainder .gt. 0) then
355 scount_pmf(i-1) = scount_pmf(i-1) + 1
356 indstart_pmf(i) = indstart_pmf(i) + i
358 do i=remainder+1,nprocs1-1
359 indstart_pmf(i) = indstart_pmf(i) + remainder
363 indstart_pmf(nprocs1)=N+1
364 scount_pmf(nprocs1)=0
367 indend_pmf(i)=indstart_pmf(i)+scount_pmf(i)-1
368 idispl_pmf(i)=indstart_pmf(i)-1
373 N=N+indend_pmf(i)-indstart_pmf(i)+1
377 write (2,*) "!!! Checksum error on processor",me
379 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
383 write (2,*) "Partition of work between processors"
385 write (2,'(a,i5,a,i7,a,i7,a,i7)')
386 & "Processor",i," indstart",indstart_pmf(i),
387 & " indend",indend_pmf(i)," count",scount_pmf(i)," idispl",