1 subroutine probabl(ibb,nlist,ncon,*)
2 ! construct the conformational ensembles at REMD temperatures
9 integer ierror,errcode,status(MPI_STATUS_SIZE)
11 include "COMMON.CONTROL"
12 include "COMMON.IOUNITS"
14 include "COMMON.FFIELD"
15 include "COMMON.INTERACT"
16 include "COMMON.SBRIDGE"
17 include "COMMON.CHAIN"
18 include "COMMON.CLUSTER"
19 real*4 csingle(3,maxres2)
20 double precision fT(6),fTprim(6),fTbis(6),quot,quotl1,quotl,kfacl,
21 & eprim,ebis,temper,kfac/2.4d0/,T0/300.0d0/
22 double precision etot,evdw,evdw2,ees,evdw1,ebe,etors,escloc,
23 & ehpb,ecorr,ecorr5,ecorr6,eello_turn4,eello_turn3,
24 & eturn6,eel_loc,edihcnstr,etors_d,estr,evdw2_14,esccor,
25 & evdw_t,esaxs,eliptran,ehomology_constr
26 integer i,ii,ik,iproc,iscor,j,k,l,ib,ibb,ib_start,ib_end,nlist,
28 double precision qfree,sumprob,eini,rmsdev
29 real*4 probab(maxconf),totprob(maxconf),aux
35 real*4 Fdimless(maxconf), Fdimless_buf(maxconf)
36 double precision energia(0:max_ene), totfree_buf(0:maxconf),
40 & "Probabilities will be summed over all temperatures"
57 if (rescale_mode.eq.1) then
58 quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
65 fT(l)=kfacl/(kfacl-1.0d0+quotl)
68 ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
70 ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
71 ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
72 & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
83 else if (rescale_mode.eq.2) then
84 quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
88 fT(l)=1.12692801104297249644d0/
89 & dlog(dexp(quotl)+dexp(-quotl))
91 c write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
94 ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
96 ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
97 ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
98 & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
110 c write (iout,*) i,list_conf(i)
113 write (iout,*) me," indstart",indstart(me)," indend",indend(me)
114 call daread_ccoords(indstart(me),indend(me))
116 C write (iout,*) "ncon",ncon
128 c(k,j)=allcart(k,j,i)
129 c(k,j+nres)=allcart(k,j+nres,i)
130 C write(iout,*) "coord",i,j,k,allcart(k,j,i),c(k,j),
131 C & c(k,j+nres),allcart(k,j+nres,i)
134 C write(iout,*) "out of j loop"
138 c(k,nres+nres)=c(k,nres)
140 C write(iout,*) "after nres+nres",nss_all(i)
144 ihpb(j)=ihpb_all(j,i)
145 jhpb(j)=jhpb_all(j,i)
147 call int_from_cart1(.false.)
148 C write(iout,*) "before etotal"
150 call etotal(energia(0),fT)
151 c write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres)
152 c write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct)
153 c call enerprint(energia(0),fT)
154 c call pdbout(totfree(i),16,i)
156 write (iout,*) i," energia",(energia(j),j=0,max_ene)
157 write (iout,*) "etot", etot
158 write (iout,*) "ft(6)", ft(6)
161 enetb(k,i)=energia(k)
165 C write (iout,*) "i",i," ii",ii,"ib",ib,scount(me)
167 do ib=ib_start,ib_end
168 temper=1.0d0/(beta_h(ib)*1.987D-3)
177 c write (iout,*) evdw
181 evdw2=enetb(2,i)+evdw2_14
197 eello_turn3=enetb(8,i)
198 eello_turn4=enetb(9,i)
207 edihcnstr=enetb(20,i)
210 ehomology_constr=enetb(24,i)
212 if (rescale_mode.eq.1) then
213 quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
220 fT(l)=kfacl/(kfacl-1.0d0+quotl)
223 ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
225 ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
226 ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
227 & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
238 else if (rescale_mode.eq.2) then
239 quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
243 fT(l)=1.12692801104297249644d0/
244 & dlog(dexp(quotl)+dexp(-quotl))
246 c write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
249 ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
251 ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
252 ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
253 & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
264 c write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
266 c call etotal(energia(0),fT)
269 if (shield_mode.gt.0) then
270 etot=ft(1)*wsc*(evdw+ft(6)*evdw_t)+ft(1)*wscp*evdw2
272 & +ft(1)*wvdwpp*evdw1
273 & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
274 & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
275 & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
276 & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
277 & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
278 & +wbond*estr+wsccor*ft(1)*esccor+!ethetacnstr
279 & +wliptran*eliptran+wsaxs*esaxs
281 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+welec*ft(1)*ees
283 & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
284 & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
285 & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
286 & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
287 & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
288 & +wbond*estr+wsccor*ft(1)*esccor+ehomology_constr
289 & +wliptran*eliptran+wsaxs*esaxs
292 if (shield_mode.gt.0) then
293 etot=ft(1)*wsc*(evdw+ft(6)*evdw_t)+ft(1)*wscp*evdw2
294 & +welec*ft(1)*(ees+evdw1)
295 & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
296 & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
297 & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
298 & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
299 & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
300 & +wbond*estr+wsccor*ft(1)*esccor+ehomology_constr
301 & +wliptran*eliptran+wsaxs*esaxs
303 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2
304 & +welec*ft(1)*(ees+evdw1)
305 & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
306 & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
307 & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
308 & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
309 & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
310 & +wbond*estr+wsccor*ft(1)*esccor+!ethetacnstr
311 & +wliptran*eliptran+wsaxs*esaxs
315 write (iout,*) "etot2", etot
316 write (iout,*) "evdw", wsc, evdw,evdw_t
317 write (iout,*) "evdw2", wscp, evdw2
318 write (iout,*) "welec", ft(1),welec,ees
319 write (iout,*) "evdw1", wvdwpp,evdw1
320 write (iout,*) "ebe", ebe,wang
326 write (iout,'(2i5,30f10.2)') i,ii,etot,
327 & (enetb(ijk,i),ijk=1,max_ene)
329 Fdimless(i)=beta_h(ib)*etot+entfac(ii)
331 write (iout,*) "fdim calc", i,ii,ib,
332 & 1.0d0/(1.987d-3*beta_h(ib)),totfree(i),
333 & entfac(ii),Fdimless(i)
335 Fdimless_buf(i)=Fdimless(i)
336 totfree_buf(i)=totfree(i)
340 c WRITE (iout,*) "Wchodze do call MPI_Gatherv1 (Propabl)"
341 call MPI_Gatherv(Fdimless_buf(1),scount(me),
342 & MPI_REAL,Fdimless(1),
343 & scount(0),idispl(0),MPI_REAL,Master,
344 & MPI_COMM_WORLD, IERROR)
345 c WRITE (iout,*) "Wchodze do call MPI_Gatherv2 (Propabl)"
346 call MPI_Gatherv(totfree_buf(1),scount(me),
347 & MPI_DOUBLE_PRECISION,totfree(1),
348 & scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master,
349 & MPI_COMM_WORLD, IERROR)
350 c WRITE (iout,*) "Wchodze do call MPI_Gatherv3 (Propabl)"
351 c WRITE (iout,*) "Wychodze z call MPI_Gatherv (Propabl)"
354 if (Fdimless(i).lt.aux) aux=Fdimless(i)
358 probab(i)=exp(aux-fdimless(i))
359 sumprob=sumprob+probab(i)
362 probab(i)=probab(i)/sumprob
363 totprob(i)=totprob(i)+probab(i)
364 c write (iout,*) ib,i,probab(i),totprob(i)
369 sumprob=sumprob+totprob(i)
371 write (iout,*) "sumprob",sumprob
373 totprob(i)=totprob(i)/sumprob
376 c Fdimless(i)=-dlog(Fdimless(i))
377 Fdimless(i)=-alog(totprob(i))
379 call MPI_Gatherv(entfac_buf(indstart(me)+1),scount(me),
380 & MPI_DOUBLE_PRECISION,entfac(1),
381 & scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master,
382 & MPI_COMM_WORLD, IERROR)
383 c WRITE (iout,*) "Wychodze z call MPI_Gatherv (Propabl)"
384 if (me.eq.Master) then
385 c WRITE (iout,*) "me.eq.Master"
388 write (iout,*) "The FDIMLESS array before sorting"
390 c write (iout,*) i,fdimless(i)
393 c WRITE (iout,*) "Wchodze do call mysort1"
394 call mysort1(ncon,Fdimless,list_conf)
395 c WRITE (iout,*) "Wychodze z call mysort1"
397 write (iout,*) "The FDIMLESS array after sorting"
399 write (iout,*) i,list_conf(i),fdimless(i)
402 c WRITE (iout,*) "Wchodze do petli i=1,ncon totfree(i)=fdimless(i)"
404 totfree(i)=fdimless(i)
408 qfree=qfree+exp(-fdimless(i)+fdimless(1))
409 c write (iout,*) "fdimless", fdimless(i)
411 c write (iout,*) "qfree",qfree
414 write (iout,*) "ncon", ncon,maxstr_proc
415 do i=1,min0(ncon,maxstr_proc)-1
416 sumprob=sumprob+exp(-fdimless(i)+fdimless(1))/qfree
418 write (iout,*) "tu szukaj ponizej 7"
419 write (iout,*) i,ib,beta_h(ib),
420 & 1.0d0/(1.987d-3*beta_h(ib)),list_conf(i),
421 & totfree(list_conf(i)),
422 & -entfac(list_conf(i)),fdimless(i),sumprob
424 if (sumprob.gt.prob_limit) goto 122
425 c if (sumprob.gt.1.00d0) goto 122
431 call MPI_Bcast(nlist, 1, MPI_INTEGER, Master, MPI_COMM_WORLD,
433 call MPI_Bcast(list_conf,nlist,MPI_INTEGER,Master,MPI_COMM_WORLD,
436 c write (iout,*) "iproc",iproc," indstart",indstart(iproc),
437 c & " indend",indend(iproc)
439 write (iout,*) "nlist",nlist
442 write (iout,'(80(1h-)/i4,a,f6.3,a,10f6.1/80(1h-))')
443 & nlist," conformations found within",prob_limit,
444 & " probablity cut_off in the temperature range ",
445 & (1.0d0/(1.987d-3*beta_h(ib)),ib=1,nT)
447 write (iout,'(80(1h-)/i4,a,f6.3,a,f6.1/80(1h-))')
448 & nlist," conformations found within",prob_limit,
449 &" probablity cut_off at temperature ",1.0d0/(1.987d-3*beta_h(ibb))
453 !--------------------------------------------------
454 subroutine mysort1(n, x, ipermut)
456 integer i,j,imax,ipm,n
464 if (x(j).lt.xtemp) then
472 ipermut(imax)=ipermut(i)