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 include "COMMON.TORSION"
15 include "COMMON.NAMES"
16 c include "COMMON.MARQ"
17 c character*64 fname(8)
19 character*1 typ(-2:2) /'p','a','G','A','P'/
21 character*16 pmf_print
25 double precision rjunk,sumw(4)
26 write (iout,*) "Calling PMFREAD",torsion_pmf,turn_pmf,eello_pmf,
28 call getenv("PMF_DIR",pmf_dir)
29 call getenv("PMF_INFIX",pmf_infix)
30 write (iout,*) "PMF_DIR ",PMF_DIR
31 write (iout,*) "PMF_INFIX",PMF_INFIX
32 call getenv("PMF_PRINT",pmf_print)
33 lprn=index(pmf_print,"PMF_PRINT").gt.0
36 c read(iparin,'(e20.10,1x,a)') x(i),parname(i)
37 c print *,i,x(i)," ",parname(i)
47 c read (iparin,*,end=12,err=12)
48 c & maxit,maxmar,rl,vmarq,tolx,tolf,rtolf,tollam
50 c write (iout,'(//21(1h*)/a/21(1h*))') "Initial parameters:"
52 c write (iout,'(i3,1x,a16,f10.5)') i,parname(i),x(i)
57 c write (iout,'(a,i3)') 'number of variables ',m
58 c write (iout,'(a,i3)') 'number of parameters ',n
74 if (torsion_pmf .or. turn_pmf) then
77 write (iout,*) "Master",Master
78 if (me.eq.Master) then
80 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//typ(it1)//typ(it2)//"_"
81 & //PMF_INFIX(:ilen(PMF_INFIX))
83 write (iout,*) "Reading torsional and turn PMFs"
84 write (iout,'(2a)') "Torsional and turn3 potential file ",torfile
85 open(89,file=torfile,status="old",err=99)
89 read (89,*,end=13,err=13) zz(1,ii),zz(2,ii),zz(3,ii),y(1,ii),
91 if (y(1,ii).ge.999.0 .or. y(2,ii).ge.999.0) cycle
92 c if (zz(1,ii).ne.75.0d0 .or. zz(2,ii).ne.130.0d0 .or.
93 c & zz(3,ii).ne.-45.0d0) cycle
95 & write(iout,'(i7,3f7.1,2f10.5)')ii,zz(1,ii),zz(2,ii),zz(3,ii),
101 npoint=npoint+2*np(it1,it2)
103 write (iout,*)np(it1,it2)," data points found in file"
104 write (iout,*)npoint," data points found so far"
110 if (y(1,i).gt.ymax) ymax=y(1,i)
111 if (y(1,i).lt.ymin) ymin=y(1,i)
114 if (ifunmode.eq.0) then
115 w(1,i)=dexp(-0.169*(y(1,i)-ymin))
116 w(2,i)=1.0*dexp(-0.168*y(2,i))
120 if (y(1,i).ge.999.0) w(1,i)=0.0d0
121 if (y(2,i).ge.999.0) w(2,i)=0.0d0
124 sumw(j)=sumw(j)+w(j,i)
129 w(j,i)=w(j,i)/sumw(j)
135 call work_partition_pmf(np_,.true.)
139 write (iout,*) "After scatter"
140 write (iout,*) "scount_pmf",(scount_pmf(i),i=1,procs)
142 call MPI_Scatter(scount_pmf,1,MPI_INTEGER,np(it1,it2),1,
143 & MPI_INTEGER,Master,WHAM_COMM,ierror)
144 write (iout,*) "After scatter scount np",np(it1,it2)
150 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
151 & MPI_DOUBLE_PRECISION,
152 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
155 y(j,i+i1-1)=bufout(i)
157 write (iout,*) "After scatter y",j
162 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
163 & MPI_DOUBLE_PRECISION,
164 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
167 w(j,i+i1-1)=bufout(i)
169 write (iout,*) "After scatter w",j
176 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
177 & MPI_DOUBLE_PRECISION,
178 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
180 write (iout,*) "After scatter z",j
183 zz(j,i+i1-1)=bufout(i)
187 write (iout,*) "Distributed etor and eturn"
188 do i=i1,i1+np(it1,it2)-1
189 write(iout,'(i7,3f7.1,2f10.5)')i,(zz(j,i),j=1,3),(y(j,i),j=1,2)
196 write (iout,*)np(it1,it2)," data points found in file"
198 endif ! torsion_pmf .or. turn_pmf
205 if (me.eq.Master) then
207 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//typ(it1)//typ(it2)//"_"//
208 & PMF_INFIX(:ilen(PMF_INFIX))
210 write (iout,*) "Reading eello3 PMFs"
211 write (iout,'(2a)') "local-electrostatic PMF file ",torfile
212 open(89,file=torfile,status="old",err=99)
216 read (89,*,end=133,err=133) (zz(j,ii),j=1,8),(y(j,ii),j=1,4)
217 if (y(1,ii).ge.999.0 .or. y(2,ii).ge.999.0 .or. y(3,ii).ge.999.0
218 & .or. y(4,ii).ge.999.0) cycle
219 if (lprn) write(iout,'(i7,8f7.1,4f10.5)')ii,(zz(j,ii),j=1,8),
224 133 npel(it1,it2)=iii-1
226 npoint=npoint+npel(it1,it2)*4
230 if (ifunmode.eq.0) then
231 w(j,ii)=10*dexp(-0.169*(y(j,ii)))
237 sumw(j)=sumw(j)+w(j,i)
242 w(j,i)=w(j,i)/sumw(j)
247 call work_partition_pmf(np_,.true.)
251 write (iout,*) "Before scatter npel"
252 call MPI_Scatter(scount_pmf,1,MPI_INTEGER,npel(it1,it2),1,
253 & MPI_INTEGER,Master,WHAM_COMM,ierror)
254 write (iout,*) "After scatter scount npel",npel(it1,it2)
260 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
261 & MPI_DOUBLE_PRECISION,
262 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
264 write (iout,*) "After scatter y",j
267 y(j,i+i1-1)=bufout(i)
272 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
273 & MPI_DOUBLE_PRECISION,
274 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
276 write (iout,*) "After scatter w",j
279 w(j,i+i1-1)=bufout(i)
286 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
287 & MPI_DOUBLE_PRECISION,
288 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
291 zz(j,i+i1-1)=bufout(i)
293 write (iout,*) "After scatter z",j
297 write (iout,*) "Distributed eelloc"
298 do i=i1,i1+npel(it1,it2)-1
299 write(iout,'(i7,8f7.1,4f10.5)')i,(zz(j,i),j=1,8),(y(j,i),j=1,4)
306 write (iout,*)npel(it1,it2)," data points found in file"
307 write (iout,*)npoint," data points found so far"
316 call getenv("ANGLE_PMF_INFIX",angle_pmf_infix)
319 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//onelet(iloctyp(i))
320 & //"_"//ANGLE_PMF_INFIX(:ilen(ANGLE_PMF_INFIX))//".thet"
321 write (iout,*) "Reading theta PMF file",torfile
322 open(89,file=torfile,status="old",err=99)
324 read(89,*,end=112,err=112) thet_point(j,i),pmf_thet(j,i)
325 nthet_point(i)=nthet_point(i)+1
330 write (iout,*) "Type ",onelet(iloctyp(i))," npoint",
332 do j=1,nthet_point(i)
333 write (iout,'(f10.1,1pe15.5)') thet_point(j,i),pmf_thet(j,i)
339 99 write (iout,*) "Error opening PMF fiie(s)"
343 c-------------------------------------------------------------------------------
344 subroutine work_partition_pmf(n,lprint)
347 include "DIMENSIONS.ZSCOPT"
350 include 'COMMON.MPISET'
351 integer ierror,errcode
352 integer n,ntot,nn,chunk,i,remainder
356 C Divide conformations between processors; for each proteins the first and
357 C the last conformation to handle by ith processor is stored in
358 C indstart(i) and indend(i), respectively.
360 C First try to assign equal number of conformations to each processor.
365 scount_pmf(0) = chunk
367 indstart_pmf(i)=chunk+indstart_pmf(i-1)
368 scount_pmf(i)=scount_pmf(i-1)
371 C Determine how many conformations remained yet unassigned.
373 remainder=N-(indstart_pmf(nprocs1-1)+scount_pmf(nprocs1-1)-1)
374 c print *,"remainder",remainder
376 C Assign the remainder conformations to consecutive processors, starting
377 C from the lowest rank; this continues until the list is exhausted.
379 if (remainder .gt. 0) then
381 scount_pmf(i-1) = scount_pmf(i-1) + 1
382 indstart_pmf(i) = indstart_pmf(i) + i
384 do i=remainder+1,nprocs1-1
385 indstart_pmf(i) = indstart_pmf(i) + remainder
389 indstart_pmf(nprocs1)=N+1
390 scount_pmf(nprocs1)=0
393 indend_pmf(i)=indstart_pmf(i)+scount_pmf(i)-1
394 idispl_pmf(i)=indstart_pmf(i)-1
399 N=N+indend_pmf(i)-indstart_pmf(i)+1
403 write (2,*) "!!! Checksum error on processor",me
405 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
409 write (2,*) "Partition of work between processors"
411 write (2,'(a,i5,a,i7,a,i7,a,i7)')
412 & "Processor",i," indstart",indstart_pmf(i),
413 & " indend",indend_pmf(i)," count",scount_pmf(i)," idispl",