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.NAMES"
15 include "COMMON.TORSION"
16 c include "COMMON.MARQ"
17 c character*64 fname(8)
19 ! character*1 typ(-4:4) /'p','n','a','l','G','L','A','N','P'/
20 character*1 typ(-ntyp1:ntyp1)
22 character*16 pmf_print
26 double precision rjunk,sumw(4)
27 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)
54 do i=-nloctyp+1,nloctyp-1
55 typ(i)=onelet(iloctyp(i))
57 write (iout,*) "typ ",(typ(i),i=-nloctyp+1,nloctyp-1)
60 c write (iout,'(a,i3)') 'number of variables ',m
61 c write (iout,'(a,i3)') 'number of parameters ',n
70 do it2=-nloctyp+1,nloctyp-1
77 if (torsion_pmf .or. turn_pmf) then
80 write (iout,*) "Master",Master
81 if (me.eq.Master) then
83 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//typ(it1)//typ(it2)//"_"
84 & //PMF_INFIX(:ilen(PMF_INFIX))
86 write (iout,*) "Reading torsional and turn PMFs"
87 write (iout,'(2a)') "Torsional and turn3 potential file ",torfile
88 open(89,file=torfile,status="old",err=99)
92 read (89,*,end=13,err=13) zz(1,ii),zz(2,ii),zz(3,ii),y(1,ii),
94 if (y(1,ii).ge.999.0 .or. y(2,ii).ge.999.0) cycle
95 c if (zz(1,ii).ne.75.0d0 .or. zz(2,ii).ne.130.0d0 .or.
96 c & zz(3,ii).ne.-45.0d0) cycle
98 & write(iout,'(i7,3f7.1,2f10.5)')ii,zz(1,ii),zz(2,ii),zz(3,ii),
104 npoint=npoint+2*np(it1,it2)
106 write (iout,*)np(it1,it2)," data points found in file"
107 write (iout,*)npoint," data points found so far"
113 if (y(1,i).gt.ymax) ymax=y(1,i)
114 if (y(1,i).lt.ymin) ymin=y(1,i)
117 if (ifunmode.eq.0) then
118 w(1,i)=dexp(-0.169*(y(1,i)-ymin))
119 w(2,i)=1.0*dexp(-0.168*y(2,i))
123 if (y(1,i).ge.999.0) w(1,i)=0.0d0
124 if (y(2,i).ge.999.0) w(2,i)=0.0d0
127 sumw(j)=sumw(j)+w(j,i)
132 w(j,i)=w(j,i)/sumw(j)
138 call work_partition_pmf(np_,.true.)
142 write (iout,*) "After scatter"
143 write (iout,*) "scount_pmf",(scount_pmf(i),i=1,procs)
145 call MPI_Scatter(scount_pmf,1,MPI_INTEGER,np(it1,it2),1,
146 & MPI_INTEGER,Master,WHAM_COMM,ierror)
147 write (iout,*) "After scatter scount np",np(it1,it2)
153 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
154 & MPI_DOUBLE_PRECISION,
155 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
158 y(j,i+i1-1)=bufout(i)
160 write (iout,*) "After scatter y",j
165 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
166 & MPI_DOUBLE_PRECISION,
167 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
170 w(j,i+i1-1)=bufout(i)
172 write (iout,*) "After scatter w",j
179 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
180 & MPI_DOUBLE_PRECISION,
181 & bufout(1),np(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
183 write (iout,*) "After scatter z",j
186 zz(j,i+i1-1)=bufout(i)
190 write (iout,*) "Distributed etor and eturn"
191 do i=i1,i1+np(it1,it2)-1
192 write(iout,'(i7,3f7.1,2f10.5)')i,(zz(j,i),j=1,3),(y(j,i),j=1,2)
199 write (iout,*)np(it1,it2)," data points found in file"
201 endif ! torsion_pmf .or. turn_pmf
208 if (me.eq.Master) then
210 torfile = PMF_DIR(:ilen(PMF_DIR))//'/'//typ(it1)//typ(it2)//"_"//
211 & PMF_INFIX(:ilen(PMF_INFIX))
213 write (iout,*) "Reading eello3 PMFs"
214 write (iout,'(2a)') "local-electrostatic PMF file ",torfile
215 open(89,file=torfile,status="old",err=99)
219 read (89,*,end=133,err=133) (zz(j,ii),j=1,8),(y(j,ii),j=1,4)
220 if (y(1,ii).ge.999.0 .or. y(2,ii).ge.999.0 .or. y(3,ii).ge.999.0
221 & .or. y(4,ii).ge.999.0) cycle
222 if (lprn) write(iout,'(i7,8f7.1,4f10.5)')ii,(zz(j,ii),j=1,8),
227 133 npel(it1,it2)=iii-1
229 npoint=npoint+npel(it1,it2)*4
233 if (ifunmode.eq.0) then
234 w(j,ii)=10*dexp(-0.169*(y(j,ii)))
240 sumw(j)=sumw(j)+w(j,i)
245 w(j,i)=w(j,i)/sumw(j)
250 call work_partition_pmf(np_,.true.)
254 write (iout,*) "Before scatter npel"
255 call MPI_Scatter(scount_pmf,1,MPI_INTEGER,npel(it1,it2),1,
256 & MPI_INTEGER,Master,WHAM_COMM,ierror)
257 write (iout,*) "After scatter scount npel",npel(it1,it2)
263 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
264 & MPI_DOUBLE_PRECISION,
265 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
267 write (iout,*) "After scatter y",j
270 y(j,i+i1-1)=bufout(i)
275 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
276 & MPI_DOUBLE_PRECISION,
277 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
279 write (iout,*) "After scatter w",j
282 w(j,i+i1-1)=bufout(i)
289 call MPI_Scatterv(bufin(i1),scount_pmf,idispl_pmf,
290 & MPI_DOUBLE_PRECISION,
291 & bufout(1),npel(it1,it2),MPI_DOUBLE_PRECISION,Master,WHAM_COMM,
294 zz(j,i+i1-1)=bufout(i)
296 write (iout,*) "After scatter z",j
300 write (iout,*) "Distributed eelloc"
301 do i=i1,i1+npel(it1,it2)-1
302 write(iout,'(i7,8f7.1,4f10.5)')i,(zz(j,i),j=1,8),(y(j,i),j=1,4)
309 write (iout,*)npel(it1,it2)," data points found in file"
310 write (iout,*)npoint," data points found so far"
319 99 write (iout,*) "Error opening PMF fiie(s)"
323 c-------------------------------------------------------------------------------
324 subroutine work_partition_pmf(n,lprint)
327 include "DIMENSIONS.ZSCOPT"
330 include 'COMMON.MPISET'
331 integer ierror,errcode
332 integer n,ntot,nn,chunk,i,remainder
336 C Divide conformations between processors; for each proteins the first and
337 C the last conformation to handle by ith processor is stored in
338 C indstart(i) and indend(i), respectively.
340 C First try to assign equal number of conformations to each processor.
345 scount_pmf(0) = chunk
347 indstart_pmf(i)=chunk+indstart_pmf(i-1)
348 scount_pmf(i)=scount_pmf(i-1)
351 C Determine how many conformations remained yet unassigned.
353 remainder=N-(indstart_pmf(nprocs1-1)+scount_pmf(nprocs1-1)-1)
354 c print *,"remainder",remainder
356 C Assign the remainder conformations to consecutive processors, starting
357 C from the lowest rank; this continues until the list is exhausted.
359 if (remainder .gt. 0) then
361 scount_pmf(i-1) = scount_pmf(i-1) + 1
362 indstart_pmf(i) = indstart_pmf(i) + i
364 do i=remainder+1,nprocs1-1
365 indstart_pmf(i) = indstart_pmf(i) + remainder
369 indstart_pmf(nprocs1)=N+1
370 scount_pmf(nprocs1)=0
373 indend_pmf(i)=indstart_pmf(i)+scount_pmf(i)-1
374 idispl_pmf(i)=indstart_pmf(i)-1
379 N=N+indend_pmf(i)-indstart_pmf(i)+1
383 write (2,*) "!!! Checksum error on processor",me
385 call MPI_Abort( MPI_COMM_WORLD, Ierror, Errcode )
389 write (2,*) "Partition of work between processors"
391 write (2,'(a,i5,a,i7,a,i7,a,i7)')
392 & "Processor",i," indstart",indstart_pmf(i),
393 & " indend",indend_pmf(i)," count",scount_pmf(i)," idispl",