1 subroutine WHAM_CALC(islice,*)
2 ! Weighed Histogram Analysis Method (WHAM) code
3 ! Written by A. Liwo based on the work of Kumar et al.,
4 ! J.Comput.Chem., 13, 1011 (1992)
6 ! 2/1/05 Multiple temperatures allowed.
7 ! 2/2/05 Free energies calculated directly from data points
8 ! acc. to Eq. (21) of Kumar et al.; final histograms also
9 ! constructed based on this equation.
10 ! 2/12/05 Multiple parameter sets included
12 ! 2/2/05 Parallel version
15 include "DIMENSIONS.ZSCOPT"
16 include "DIMENSIONS.FREE"
17 integer MaxBinRms,MaxBinRgy
18 parameter (MaxBinRms=100,MaxBinRgy=100)
20 c parameter (MaxHdim=200000)
21 parameter (MaxHdim=200)
23 parameter (maxinde=200)
27 integer ierror,errcode,status(MPI_STATUS_SIZE)
29 include "COMMON.CONTROL"
30 include "COMMON.IOUNITS"
32 include "COMMON.ENERGIES"
33 include "COMMON.FFIELD"
34 include "COMMON.SBRIDGE"
36 include "COMMON.ENEPS"
37 integer MaxPoint,MaxPointProc
38 parameter (MaxPoint=MaxStr,
39 & MaxPointProc=MaxStr_Proc)
40 double precision finorm_max,potfac,entmin,entmax,expfac,vf
41 double precision entfac_min,entfac_min_t
42 parameter (finorm_max=1.0d0)
44 integer i,ii,j,jj,k,kk,l,m,ind,iter,t,tmax,ient,ientmax,iln
45 integer start,end,iharm,ib,iib,nbin1,nbin,nbin_rms,nbin_rgy,
46 & nbin_rmsrgy,liczba,iparm,nFi,indrgy,indrms
47 integer htot(0:MaxHdim),histent(0:2000)
48 double precision v(MaxPointProc,MaxR,MaxT_h,Max_Parm)
49 double precision energia(0:max_ene)
51 integer tmax_t,upindE_p
52 double precision fi_p(MaxR,MaxT_h,Max_Parm),
53 & fi_p_min(MaxR,MaxT_h,Max_Parm)
54 double precision sumW_p(0:Max_GridT,Max_Parm),
55 & sumE_p(0:Max_GridT,Max_Parm),sumEsq_p(0:Max_GridT,Max_Parm),
56 & sumQ_p(MaxQ1,0:Max_GridT,Max_Parm),
57 & sumQsq_p(MaxQ1,0:Max_GridT,Max_Parm),
58 & sumEQ_p(MaxQ1,0:Max_GridT,Max_Parm),
59 & sumEprim_p(MaxQ1,0:Max_GridT,Max_Parm),
60 & sumEbis_p(0:Max_GridT,Max_Parm)
61 double precision hfin_p(0:MaxHdim,maxT_h),
62 & hfin_ent_p(0:MaxHdim),histE_p(0:maxindE),sumH,
63 & hrmsrgy_p(0:MaxBinRgy,0:MaxBinRms,maxT_h)
64 double precision rgymin_t,rmsmin_t,rgymax_t,rmsmax_t
65 double precision potEmin_t_all(maxT_h,Max_Parm),entmin_p,entmax_p
66 integer histent_p(0:2000)
67 logical lprint /.true./
69 double precision rgymin,rmsmin,rgymax,rmsmax
70 double precision sumW(0:NGridT,Max_Parm),sumE(0:NGridT,Max_Parm),
71 & sumEsq(0:NGridT,Max_Parm),sumQ(MaxQ1,0:NGridT,Max_Parm),
72 & sumQsq(MaxQ1,0:NGridT,Max_Parm),sumEQ(MaxQ1,0:NGridT,Max_Parm),
73 & sumEprim(0:NGridT,Max_Parm),sumEbis(0:NGridT,Max_Parm),betaT,
75 double precision fi(MaxR,maxT_h,Max_Parm),
76 & fi_min(MaxR,maxT_h,Max_Parm),
77 & dd,dd1,dd2,hh,dmin,denom,finorm,avefi,pom,
78 & hfin(0:MaxHdim,maxT_h),histE(0:maxindE),
79 & hrmsrgy(0:MaxBinRgy,0:MaxBinRms,maxT_h),
80 & potEmin_all(maxT_h,Max_Parm),potEmin,potEmin_min,ent,
81 & hfin_ent(0:MaxHdim),vmax,aux
82 double precision fT(6),fTprim(6),fTbis(6),quot,quotl1,quotl,kfacl,
83 & eprim,ebis,temper,kfac/2.4d0/,T0/300.0d0/,
84 & eplus,eminus,logfac,tanhT,tt
85 double precision etot,evdw,evdw_t,evdw2,ees,evdw1,ebe,etors,
86 & escloc,ehpb,ecorr,ecorr5,ecorr6,eello_turn4,eello_turn3,
87 & eturn6,eel_loc,edihcnstr,etors_d,estr,evdw2_14,esccor,
88 & ehomology_constr,edfadis,edfator,edfanei,edfabet
91 integer ind_point(maxpoint),upindE,indE
99 write(licz2,'(bz,i2.2)') islice
101 write (iout,'(//80(1h-)/"Solving WHAM equations for slice",
102 & i2/80(1h-)//)') islice
103 write (iout,*) "delta",delta," nbin1",nbin1
104 write (iout,*) "MaxN",MaxN," MaxQ",MaxQ," MaHdim",MaxHdim
110 potEmin_all(j,i)=1.0d10
125 if (q(nQ+1,i).lt.rmsmin) rmsmin=q(nQ+1,i)
126 if (q(nQ+1,i).gt.rmsmax) rmsmax=q(nQ+1,i)
127 if (q(nQ+2,i).lt.rgymin) rgymin=q(nQ+2,i)
128 if (q(nQ+2,i).gt.rgymax) rgymax=q(nQ+2,i)
131 ind=(q(j,i)-dmin+1.0d-8)/delta
133 ind_point(i)=ind_point(i)+ind
135 ind_point(i)=ind_point(i)+nbin1**(j-1)*ind
137 if (ind_point(i).lt.0 .or. ind_point(i).gt.MaxHdim) then
138 write (iout,*) "Error - index exceeds range for point",i,
139 & " q=",q(j,i)," ind",ind_point(i)
141 write (iout,*) "Processor",me1
143 call MPI_Abort(MPI_COMM_WORLD, Ierror, Errcode )
148 if (ind_point(i).gt.tmax) tmax=ind_point(i)
149 htot(ind_point(i))=htot(ind_point(i))+1
151 write (iout,*) "i",i,"q",(q(j,i),j=1,nQ)," ind",ind_point(i),
152 & " htot",htot(ind_point(i))
159 write (iout,'(a)') "Numbers of counts in Q bins"
161 if (htot(t).gt.0) then
162 write (iout,'(i15,$)') t
165 jj = mod(liczba,nbin1)
167 write (iout,'(i5,$)') jj
169 write (iout,'(i8)') htot(t)
173 write (iout,'(a,i3)') "Number of data points for parameter set",
175 write (iout,'(i7,$)') ((snk(m,ib,iparm,islice),m=1,nr(ib,iparm)),
177 write (iout,'(i8)') stot(islice)
183 call MPI_AllReduce(tmax,tmax_t,1,MPI_INTEGER,MPI_MAX,
186 call MPI_AllReduce(rmsmin,rmsmin_t,1,MPI_DOUBLE_PRECISION,
187 & MPI_MIN,WHAM_COMM,IERROR)
188 call MPI_AllReduce(rmsmax,rmsmax_t,1,MPI_DOUBLE_PRECISION,
189 & MPI_MAX,WHAM_COMM,IERROR)
190 call MPI_AllReduce(rgymin,rgymin_t,1,MPI_DOUBLE_PRECISION,
191 & MPI_MIN,WHAM_COMM,IERROR)
192 call MPI_AllReduce(rgymax,rgymax_t,1,MPI_DOUBLE_PRECISION,
193 & MPI_MAX,WHAM_COMM,IERROR)
199 rmsmin=deltrms*dint(rmsmin/deltrms)
200 rmsmax=deltrms*dint(rmsmax/deltrms)
201 rgymin=deltrms*dint(rgymin/deltrgy)
202 rgymax=deltrms*dint(rgymax/deltrgy)
203 nbin_rms=(rmsmax-rmsmin)/deltrms
204 nbin_rgy=(rgymax-rgymin)/deltrgy
205 write (iout,*) "rmsmin",rmsmin," rmsmax",rmsmax," rgymin",rgymin,
206 & " rgymax",rgymax," nbin_rms",nbin_rms," nbin_rgy",nbin_rgy
213 write (iout,*) "nFi",nFi
214 ! Compute the Boltzmann factor corresponing to restrain potentials in different
221 c write (9,'(3i5,f10.5)') i,(iparm,potE(i,iparm),iparm=1,nParmSet)
224 write (iout,'(2i5,22f8.2)') i,iparm,
225 & (enetb(k,i,iparm),k=1,22)
227 call restore_parm(iparm)
229 write (iout,*) wsc,wscp,welec,wvdwpp,wang,wtor,wscloc,
230 & wcorr,wcorr5,wcorr6,wturn4,wturn3,wturn6,wel_loc,
231 & wtor_d,wsccor,wbond
234 if (rescale_mode.eq.1) then
235 quot=1.0d0/(beta_h(ib,iparm)*1.987D-3*T0)
242 fT(l)=kfacl/(kfacl-1.0d0+quotl)
245 tt = 1.0d0/(beta_h(ib,iparm)*1.987D-3)
246 ft(6)=(320.0d0+80.0d0*dtanh((tt-320.0d0)/80.0d0))/320.0d0
248 ft(6)=1.0d0/(beta_h(ib,iparm)*1.987D-3*T0)
252 else if (rescale_mode.eq.2) then
253 quot=1.0d0/(T0*beta_h(ib,iparm)*1.987D-3)
257 fT(l)=1.12692801104297249644d0/
258 & dlog(dexp(quotl)+dexp(-quotl))
261 tt = 1.0d0/(beta_h(ib,iparm)*1.987D-3)
262 ft(6)=(320.0d0+80.0d0*dtanh((tt-320.0d0)/80.0d0))/320.0d0
264 ft(6)=1.0d0/(beta_h(ib,iparm)*1.987D-3*T0)
268 c write (iout,*) 1.0d0/(beta_h(ib,iparm)*1.987D-3),ft
269 else if (rescale_mode.eq.0) then
274 write (iout,*) "Error in WHAM_CALC: wrong RESCALE_MODE",
279 evdw=enetb(1,i,iparm)
280 evdw_t=enetb(21,i,iparm)
282 evdw2_14=enetb(17,i,iparm)
283 evdw2=enetb(2,i,iparm)+evdw2_14
285 evdw2=enetb(2,i,iparm)
290 evdw1=enetb(16,i,iparm)
295 ecorr=enetb(4,i,iparm)
296 ecorr5=enetb(5,i,iparm)
297 ecorr6=enetb(6,i,iparm)
298 eel_loc=enetb(7,i,iparm)
299 eello_turn3=enetb(8,i,iparm)
300 eello_turn4=enetb(9,i,iparm)
301 eturn6=enetb(10,i,iparm)
302 ebe=enetb(11,i,iparm)
303 escloc=enetb(12,i,iparm)
304 etors=enetb(13,i,iparm)
305 etors_d=enetb(14,i,iparm)
306 ehpb=enetb(15,i,iparm)
307 estr=enetb(18,i,iparm)
308 esccor=enetb(19,i,iparm)
309 edihcnstr=enetb(20,i,iparm)
310 ehomology_constr=enetb(22,i,iparm)
311 edfadis=enetb(23,i,iparm)
312 edfator=enetb(24,i,iparm)
313 edfanei=enetb(25,i,iparm)
314 edfabet=enetb(26,i,iparm)
316 write (iout,'(3i5,6f5.2,16f12.3)') i,ib,iparm,(ft(l),l=1,6),
317 & evdw+evdw_t,evdw2,ees,evdw1,ecorr,eel_loc,estr,ebe,escloc,
318 & etors,etors_d,eello_turn3,eello_turn4,esccor,
319 & ehomology_constr,edfadis,edfator,edfanei,edfabet
323 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+ft(1)*welec*ees
325 & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc
326 & +wstrain*ehpb+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5
327 & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4
328 & +ft(2)*wturn3*eello_turn3
329 & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc
330 & +edihcnstr+ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor
331 & +wbond*estr+wdfa_dist*edfadis
332 & +wdfa_tor*edfator+wdfa_nei*edfanei+wdfa_beta*edfabet
334 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2
335 & +ft(1)*welec*(ees+evdw1)
336 & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc
337 & +wstrain*ehpb+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5
338 & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4
339 & +ft(2)*wturn3*eello_turn3
340 & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc+edihcnstr
341 & +ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor
342 & +wbond*estr+wdfa_dist*edfadis
343 & +wdfa_tor*edfator+wdfa_nei*edfanei+wdfa_beta*edfabet
346 write (iout,*) i,iparm,1.0d0/(beta_h(ib,iparm)*1.987D-3),
350 if (iparm.eq.1 .and. ib.eq.1) then
351 write (iout,*)"Conformation",i
354 energia(k)=enetb(k,i,iparm)
356 call enerprint(energia(0),fT)
360 write (iout,*) "homol_nset",homol_nset,nR(ib,iparm)
362 if (homol_nset.gt.1) then
365 Econstr=waga_homology(kk)*ehomology_constr
367 & -beta_h(ib,iparm)*(etot+Econstr)
369 write (iout,'(4i5,4e15.5)') i,kk,ib,iparm,
370 & etot,Econstr,v(i,kk,ib,iparm)
376 etot=etot+ehomology_constr
381 Econstr=Econstr+Kh(j,kk,ib,iparm)
382 & *(dd-q0(j,kk,ib,iparm))**2
385 & -beta_h(ib,iparm)*(etot+Econstr)
387 write (iout,'(4i5,4e15.5)') i,kk,ib,iparm,
388 & etot,v(i,kk,ib,iparm)
396 ! Simple iteration to calculate free energies corresponding to all simulation
400 ! Compute new free-energy values corresponding to the righ-hand side of the
401 ! equation and their derivatives.
402 write (iout,*) "------------------------fi"
413 vf=v(t,l,k,i)+f(l,k,i)
414 if (vf.gt.vmax) vmax=vf
422 aux=f(l,k,i)+v(t,l,k,i)-vmax
424 & denom=denom+snk(l,k,i,islice)*dexp(aux)
428 entfac(t)=-dlog(denom)-vmax
429 if (entfac(t).lt.entfac_min) entfac_min=entfac(t)
431 write (iout,*) t,"vmax",vmax," denom",denom,"entfac",entfac(t)
435 c write (iout,*) "entfac_min before AllReduce",entfac_min
436 c call MPI_AllReduce(entfac_min,entfac_min_t,1,
437 c & MPI_DOUBLE_PRECISION,MPI_MAX,WHAM_COMM,IERROR)
438 c entfac_min=entfac_min_t
439 c write (iout,*) "entfac_min after AllReduce",entfac_min
443 c entfac(t)=entfac(t)-entfac_min
446 c do t=1,ntot(islice)
447 c entfac(t)=entfac(t)-entfac_min
452 do ii=1,nR(iib,iparm)
454 fi_p_min(ii,iib,iparm)=-1.0d10
456 aux=v(t,ii,iib,iparm)+entfac(t)
457 if (aux.gt.fi_p_min(ii,iib,iparm))
458 & fi_p_min(ii,iib,iparm)=aux
462 aux=v(t,ii,iib,iparm)+entfac(t)
463 if (aux.gt.fi_min(ii,iib,iparm))
464 & fi_min(ii,iib,iparm)=aux
472 write (iout,*) "fi_min before AllReduce"
475 write (iout,*) (i,j,k,fi_p_min(k,j,i),k=1,nR(j,i))
479 call MPI_AllReduce(fi_p_min,fi_min,MaxR*MaxT_h*nParmSet,
480 & MPI_DOUBLE_PRECISION,MPI_MAX,WHAM_COMM,IERROR)
482 write (iout,*) "fi_min after AllReduce"
485 write (iout,*) (i,j,k,fi_min(k,j,i),k=1,nR(j,i))
492 do ii=1,nR(iib,iparm)
494 fi_p(ii,iib,iparm)=0.0d0
496 fi_p(ii,iib,iparm)=fi_p(ii,iib,iparm)
497 & +dexp(v(t,ii,iib,iparm)+entfac(t)-fi_min(ii,iib,iparm))
499 write (iout,'(4i5,4e15.5)') t,ii,iib,iparm,
500 & v(t,ii,iib,iparm),entfac(t),fi_min(ii,iib,iparm),
505 fi(ii,iib,iparm)=0.0d0
507 fi(ii,iib,iparm)=fi(ii,iib,iparm)
508 & +dexp(v(t,ii,iib,iparm)+entfac(t)-fi_min(ii,iib,iparm))
517 write (iout,*) "fi before MPI_Reduce me",me,' master',master
520 write (iout,*) "iparm",iparm," ib",ib
521 write (iout,*) "beta=",beta_h(ib,iparm)
522 write (iout,'(8e15.5)') (fi_p(i,ib,iparm),i=1,nR(ib,iparm))
527 write (iout,*) "REDUCE size",maxR,MaxT_h,nParmSet,
528 & maxR*MaxT_h*nParmSet
529 write (iout,*) "MPI_COMM_WORLD",MPI_COMM_WORLD,
530 & " WHAM_COMM",WHAM_COMM
532 call MPI_Reduce(fi_p(1,1,1),fi(1,1,1),maxR*MaxT_h*nParmSet,
533 & MPI_DOUBLE_PRECISION,
534 & MPI_SUM,Master,WHAM_COMM,IERROR)
536 write (iout,*) "fi after MPI_Reduce nparmset",nparmset
538 write (iout,*) "iparm",iparm
540 write (iout,*) "beta=",beta_h(ib,iparm)
541 write (iout,'(8e15.5)') (fi(i,ib,iparm),i=1,nR(ib,iparm))
545 if (me1.eq.Master) then
551 fi(i,ib,iparm)=-dlog(fi(i,ib,iparm))-fi_min(i,ib,iparm)
552 avefi=avefi+fi(i,ib,iparm)
558 write (iout,*) "Parameter set",iparm
560 write (iout,*) "beta=",beta_h(ib,iparm)
562 fi(i,ib,iparm)=fi(i,ib,iparm)-avefi
564 write (iout,'(8f10.5)') (fi(i,ib,iparm),i=1,nR(ib,iparm))
565 write (iout,'(8f10.5)') (f(i,ib,iparm),i=1,nR(ib,iparm))
569 ! Compute the norm of free-energy increments.
574 finorm=finorm+dabs(fi(i,ib,iparm)-f(i,ib,iparm))
575 f(i,ib,iparm)=fi(i,ib,iparm)
580 write (iout,*) 'Iteration',iter,' finorm',finorm
584 call MPI_Bcast(f(1,1,1),MaxR*MaxT_h*nParmSet,
585 & MPI_DOUBLE_PRECISION,Master,
587 call MPI_Bcast(finorm,1,MPI_DOUBLE_PRECISION,Master,
590 ! Exit, if the increment norm is smaller than pre-assigned tolerance.
591 if (finorm.lt.fimin) then
592 write (iout,*) 'Iteration converged'
599 ! Now, put together the histograms from all simulations, in order to get the
600 ! unbiased total histogram.
602 C Determine the minimum free energies
608 c write (9,'(3i5,f10.5)') i,(iparm,potE(i,iparm),iparm=1,nParmSet)
611 write (iout,'(2i5,21f8.2)') i,iparm,
612 & (enetb(k,i,iparm),k=1,22)
614 call restore_parm(iparm)
616 write (iout,*) wsc,wscp,welec,wvdwpp,wang,wtor,wscloc,
617 & wcorr,wcorr5,wcorr6,wturn4,wturn3,wturn6,wel_loc,
618 & wtor_d,wsccor,wbond
621 if (rescale_mode.eq.1) then
622 quot=1.0d0/(beta_h(ib,iparm)*1.987D-3*T0)
629 fT(l)=kfacl/(kfacl-1.0d0+quotl)
632 tt = 1.0d0/(beta_h(ib,iparm)*1.987D-3)
633 ft(6)=(320.0d0+80.0d0*dtanh((tt-320.0d0)/80.0d0))/320.0d0
635 ft(6)=1.0d0/(beta_h(ib,iparm)*1.987D-3*T0)
639 else if (rescale_mode.eq.2) then
640 quot=1.0d0/(T0*beta_h(ib,iparm)*1.987D-3)
644 fT(l)=1.12692801104297249644d0/
645 & dlog(dexp(quotl)+dexp(-quotl))
648 tt = 1.0d0/(beta_h(ib,iparm)*1.987D-3)
649 ft(6)=(320.0d0+80.0d0*dtanh((tt-320.0d0)/80.0d0))/320.0d0
651 ft(6)=1.0d0/(beta_h(ib,iparm)*1.987D-3*T0)
655 c write (iout,*) 1.0d0/(beta_h(ib,iparm)*1.987D-3),ft
656 else if (rescale_mode.eq.0) then
661 write (iout,*) "Error in WHAM_CALC: wrong RESCALE_MODE",
666 evdw=enetb(1,i,iparm)
667 evdw_t=enetb(21,i,iparm)
669 evdw2_14=enetb(17,i,iparm)
670 evdw2=enetb(2,i,iparm)+evdw2_14
672 evdw2=enetb(2,i,iparm)
677 evdw1=enetb(16,i,iparm)
682 ecorr=enetb(4,i,iparm)
683 ecorr5=enetb(5,i,iparm)
684 ecorr6=enetb(6,i,iparm)
685 eel_loc=enetb(7,i,iparm)
686 eello_turn3=enetb(8,i,iparm)
687 eello_turn4=enetb(9,i,iparm)
688 eturn6=enetb(10,i,iparm)
689 ebe=enetb(11,i,iparm)
690 escloc=enetb(12,i,iparm)
691 etors=enetb(13,i,iparm)
692 etors_d=enetb(14,i,iparm)
693 ehpb=enetb(15,i,iparm)
694 estr=enetb(18,i,iparm)
695 esccor=enetb(19,i,iparm)
696 edihcnstr=enetb(20,i,iparm)
697 ehomology_constr=enetb(22,i,iparm)
699 & ehomology_constr=waga_homology(homol_nset)*ehomology_constr
700 edfadis=enetb(23,i,iparm)
701 edfator=enetb(24,i,iparm)
702 edfanei=enetb(25,i,iparm)
703 edfabet=enetb(26,i,iparm)
705 write (iout,'(3i5,6f5.2,17f12.3)') i,ib,iparm,(ft(l),l=1,6),
706 & evdw+evdw_t,evdw2,ees,evdw1,ecorr,eel_loc,estr,ebe,escloc,
707 & etors,etors_d,eello_turn3,eello_turn4,esccor,edihcnstr,
708 & ehomology_constr+wdfa_dist*edfadis+wdfa_tor*edfator+
709 & wdfa_nei*edfanei+wdfa_beta*edfabet
713 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+ft(1)*welec*ees
715 & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc
716 & +wstrain*ehpb+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5
717 & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4
718 & +ft(2)*wturn3*eello_turn3
719 & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc
720 & +edihcnstr+ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor
721 & +wbond*estr+ehomology_constr+wdfa_dist*edfadis
722 & +wdfa_tor*edfator+wdfa_nei*edfanei+wdfa_beta*edfabet
724 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2
725 & +ft(1)*welec*(ees+evdw1)
726 & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc
727 & +wstrain*ehpb+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5
728 & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4
729 & +ft(2)*wturn3*eello_turn3
730 & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc+edihcnstr
731 & +ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor
732 & +wbond*estr+ehomology_constr+wdfa_dist*edfadis
733 & +wdfa_tor*edfator+wdfa_nei*edfanei+wdfa_beta*edfabet
736 write (iout,*) "i",i," ib",ib,
737 & " temp",1.0d0/(1.987d-3*beta_h(ib,iparm))," etot",etot,
738 & " entfac",entfac(i)," ecorr",etot-entfac(i)/beta_h(ib,iparm)
739 etot=etot-entfac(i)/beta_h(ib,iparm)
741 if(etot.lt.potEmin_all(ib,iparm)) potEmin_all(ib,iparm)=etot
743 write (iout,*) "efree",etot," potEmin",potEmin_all(ib,iparm)
749 write (iout,*) "The potEmin array before reduction"
751 write (iout,*) "Parameter set",i
753 write (iout,*) j,PotEmin_all(j,i)
756 write (iout,*) "potEmin_min",potEmin_min
759 C Determine the minimum energes for all parameter sets and temperatures
760 call MPI_AllReduce(potEmin_all(1,1),potEmin_t_all(1,1),
761 & maxT_h*nParmSet,MPI_DOUBLE_PRECISION,MPI_MIN,WHAM_COMM,IERROR)
764 potEmin_all(j,i)=potEmin_t_all(j,i)
768 potEmin_min=potEmin_all(1,1)
771 if (potEmin_all(j,i).lt.potEmin_min)
772 & potEmin_min=potEmin_all(j,i)
776 write (iout,*) "The potEmin array"
778 write (iout,*) "Parameter set",i
780 write (iout,*) j,PotEmin_all(j,i)
783 write (iout,*) "potEmin_min",potEmin_min
795 write (iout,*) "--------------hist"
799 sumW_p(i,iparm)=0.0d0
800 sumE_p(i,iparm)=0.0d0
801 sumEbis_p(i,iparm)=0.0d0
802 sumEsq_p(i,iparm)=0.0d0
804 sumQ_p(j,i,iparm)=0.0d0
805 sumQsq_p(j,i,iparm)=0.0d0
806 sumEQ_p(j,i,iparm)=0.0d0
816 sumEbis(i,iparm)=0.0d0
817 sumEsq(i,iparm)=0.0d0
819 sumQ(j,i,iparm)=0.0d0
820 sumQsq(j,i,iparm)=0.0d0
821 sumEQ(j,i,iparm)=0.0d0
827 c 8/26/05 entropy distribution
832 c ent=-dlog(entfac(t))
834 if (ent.lt.entmin_p) entmin_p=ent
835 if (ent.gt.entmax_p) entmax_p=ent
837 write (iout,*) "entmin",entmin_p," entmax",entmax_p
839 call MPI_Allreduce(entmin_p,entmin,1,MPI_DOUBLE_PRECISION,MPI_MIN,
841 call MPI_Allreduce(entmax_p,entmax,1,MPI_DOUBLE_PRECISION,MPI_MAX,
843 ientmax=entmax-entmin
844 if (ientmax.gt.2000) ientmax=2000
845 write (iout,*) "entmin",entmin," entmax",entmax," ientmax",ientmax
848 c ient=-dlog(entfac(t))-entmin
849 ient=entfac(t)-entmin
850 if (ient.le.2000) histent_p(ient)=histent_p(ient)+1
852 call MPI_Allreduce(histent_p(0),histent(0),ientmax+1,MPI_INTEGER,
853 & MPI_SUM,WHAM_COMM,IERROR)
854 if (me1.eq.Master) then
855 write (iout,*) "Entropy histogram"
857 write(iout,'(f15.4,i10)') entmin+i,histent(i)
865 if (ent.lt.entmin) entmin=ent
866 if (ent.gt.entmax) entmax=ent
868 ientmax=-dlog(entmax)-entmin
869 if (ientmax.gt.2000) ientmax=2000
871 ient=entfac(t)-entmin
872 if (ient.le.2000) histent(ient)=histent(ient)+1
874 write (iout,*) "Entropy histogram"
876 write(iout,'(2f15.4)') entmin+i,histent(i)
881 c write (iout,*) "me1",me1," scount",scount(me1)
907 hrmsrgy(j,i,ib)=0.0d0
909 hrmsrgy_p(j,i,ib)=0.0d0
921 hfin_ent_p(ind)=hfin_ent_p(ind)+dexp(entfac(t))
923 hfin_ent(ind)=hfin_ent(ind)+dexp(entfac(t))
925 call restore_parm(iparm)
926 evdw=enetb(21,t,iparm)
927 evdw_t=enetb(1,t,iparm)
929 evdw2_14=enetb(17,t,iparm)
930 evdw2=enetb(2,t,iparm)+evdw2_14
932 evdw2=enetb(2,t,iparm)
937 evdw1=enetb(16,t,iparm)
942 ecorr=enetb(4,t,iparm)
943 ecorr5=enetb(5,t,iparm)
944 ecorr6=enetb(6,t,iparm)
945 eel_loc=enetb(7,t,iparm)
946 eello_turn3=enetb(8,t,iparm)
947 eello_turn4=enetb(9,t,iparm)
948 eturn6=enetb(10,t,iparm)
949 ebe=enetb(11,t,iparm)
950 escloc=enetb(12,t,iparm)
951 etors=enetb(13,t,iparm)
952 etors_d=enetb(14,t,iparm)
953 ehpb=enetb(15,t,iparm)
954 estr=enetb(18,t,iparm)
955 esccor=enetb(19,t,iparm)
956 edihcnstr=enetb(20,t,iparm)
957 ehomology_constr=enetb(22,t,iparm)
959 & ehomology_constr=waga_homology(homol_nset)*ehomology_constr
960 edfadis=enetb(23,t,iparm)
961 edfator=enetb(24,t,iparm)
962 edfanei=enetb(25,t,iparm)
963 edfabet=enetb(26,t,iparm)
965 betaT=startGridT+k*delta_T
969 if (rescale_mode.eq.1) then
977 denom=kfacl-1.0d0+quotl
979 ftprim(l)=-l*ft(l)*quotl1/(T0*denom)
980 ftbis(l)=l*kfacl*quotl1*
981 & (2*l*quotl-(l-1)*denom)/(quot*t0*t0*denom**3)
984 ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
986 ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
987 ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
988 & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
998 else if (rescale_mode.eq.2) then
1006 logfac=1.0d0/dlog(eplus+eminus)
1007 tanhT=(eplus-eminus)/(eplus+eminus)
1008 fT(l)=1.12692801104297249644d0*logfac
1009 ftprim(l)=-l*quotl1*ft(l)*tanhT*logfac/T0
1010 ftbis(l)=(l-1)*ftprim(l)/(quot*T0)-
1011 & 2*l*quotl1/T0*logfac*
1012 & (2*l*quotl1*ft(l)/(T0*(eplus+eminus)**2)
1016 ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
1018 ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
1019 ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
1020 & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
1021 #elif defined(FUNCT)
1030 else if (rescale_mode.eq.0) then
1036 write (iout,*) "Error in WHAM_CALC: wrong RESCALE_MODE",
1041 c write (iout,*) "ftprim",ftprim
1042 c write (iout,*) "ftbis",ftbis
1043 betaT=1.0d0/(1.987D-3*betaT)
1044 if (betaT.ge.beta_h(1,iparm)) then
1045 potEmin=potEmin_all(1,iparm)
1046 c write(iout,*) "first",temper,potEmin
1047 else if (betaT.lt.beta_h(nT_h(iparm),iparm)) then
1048 potEmin=potEmin_all(nT_h(iparm),iparm)
1049 c write (iout,*) "last",temper,potEmin
1051 do l=1,nT_h(iparm)-1
1052 if (betaT.le.beta_h(l,iparm) .and.
1053 & betaT.gt.beta_h(l+1,iparm)) then
1054 potEmin=potEmin_all(l,iparm)
1055 c write (iout,*) "l",l,
1056 c & betaT,1.0d0/(1.987D-3*beta_h(l,iparm)),
1057 c & 1.0d0/(1.987D-3*beta_h(l+1,iparm)),temper,potEmin
1062 c write (iout,*) ib," PotEmin",potEmin
1064 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+ft(1)*welec*ees
1066 & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc
1067 & +wstrain*ehpb+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5
1068 & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4
1069 & +ft(2)*wturn3*eello_turn3
1070 & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc
1071 & +edihcnstr+ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor
1072 & +wbond*estr+ehomology_constr
1073 eprim=ftprim(6)*evdw_t+ftprim(1)*welec*ees
1074 & +ftprim(1)*wtor*etors+
1075 & ftprim(3)*wcorr*ecorr+ftprim(4)*wcorr5*ecorr5+
1076 & ftprim(5)*wcorr6*ecorr6+ftprim(3)*wturn4*eello_turn4+
1077 & ftprim(2)*wturn3*eello_turn3+ftprim(5)*wturn6*eturn6+
1078 & ftprim(2)*wel_loc*eel_loc+ftprim(2)*wtor_d*etors_d+
1079 & ftprim(1)*wsccor*esccor
1080 ebis=ftbis(1)*welec*ees+ftbis(1)*wtor*etors+
1081 & ftbis(3)*wcorr*ecorr+ftbis(4)*wcorr5*ecorr5+
1082 & ftbis(5)*wcorr6*ecorr6+ftbis(3)*wturn4*eello_turn4+
1083 & ftbis(2)*wturn3*eello_turn3+ftbis(5)*wturn6*eturn6+
1084 & ftbis(2)*wel_loc*eel_loc+ftbis(2)*wtor_d*etors_d+
1085 & ftbis(1)*wsccor*esccor
1087 etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2
1088 & +ft(1)*welec*(ees+evdw1)
1089 & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc
1090 & +wstrain*ehpb+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5
1091 & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4
1092 & +ft(2)*wturn3*eello_turn3
1093 & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc+edihcnstr
1094 & +ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor
1095 & +wbond*estr+ehomology_constr
1096 eprim=ftprim(6)*evdw_t+ftprim(1)*welec*(ees+evdw1)
1097 & +ftprim(1)*wtor*etors+
1098 & ftprim(3)*wcorr*ecorr+ftprim(4)*wcorr5*ecorr5+
1099 & ftprim(5)*wcorr6*ecorr6+ftprim(3)*wturn4*eello_turn4+
1100 & ftprim(2)*wturn3*eello_turn3+ftprim(5)*wturn6*eturn6+
1101 & ftprim(2)*wel_loc*eel_loc+ftprim(2)*wtor_d*etors_d+
1102 & ftprim(1)*wsccor*esccor
1103 ebis=ftbis(1)*welec*(ees+evdw1)+ftbis(1)*wtor*etors+
1104 & ftbis(3)*wcorr*ecorr+ftbis(4)*wcorr5*ecorr5+
1105 & ftbis(5)*wcorr6*ecorr6+ftbis(3)*wturn4*eello_turn4+
1106 & ftbis(2)*wturn3*eello_turn3+ftbis(5)*wturn6*eturn6+
1107 & ftbis(2)*wel_loc*eel_loc+ftbis(2)*wtor_d*etors_d+
1108 & ftprim(1)*wsccor*esccor
1110 weight=dexp(-betaT*(etot-potEmin)+entfac(t))
1112 write (iout,'(3i5,6f5.2,17f12.3)') i,ib,iparm,(ft(l),l=1,6),
1113 & evdw+evdw_t,evdw2,ees,evdw1,ecorr,eel_loc,estr,ebe,escloc,
1114 & etors,etors_d,eello_turn3,eello_turn4,esccor,edihcnstr,
1115 & ehomology_constr+wdfa_dist*edfadis+wdfa_tor*edfator+
1116 & wdfa_nei*edfanei+wdfa_beta*edfabet
1117 write (iout,*) "iparm",iparm," t",t," temper",temper,
1118 & " etot",etot," entfac",entfac(t),
1119 & " efree",etot-entfac(t)/betaT," potEmin",potEmin,
1120 & " boltz",-betaT*(etot-potEmin)+entfac(t),
1121 & " weight",weight," ebis",ebis
1123 etot=etot-temper*eprim
1125 sumW_p(k,iparm)=sumW_p(k,iparm)+weight
1126 sumE_p(k,iparm)=sumE_p(k,iparm)+etot*weight
1127 sumEbis_p(k,iparm)=sumEbis_p(k,iparm)+ebis*weight
1128 sumEsq_p(k,iparm)=sumEsq_p(k,iparm)+etot**2*weight
1130 sumQ_p(j,k,iparm)=sumQ_p(j,k,iparm)+q(j,t)*weight
1131 sumQsq_p(j,k,iparm)=sumQsq_p(j,k,iparm)+q(j,t)**2*weight
1132 sumEQ_p(j,k,iparm)=sumEQ_p(j,k,iparm)
1133 & +etot*q(j,t)*weight
1136 sumW(k,iparm)=sumW(k,iparm)+weight
1137 sumE(k,iparm)=sumE(k,iparm)+etot*weight
1138 sumEbis(k,iparm)=sumEbis(k,iparm)+ebis*weight
1139 sumEsq(k,iparm)=sumEsq(k,iparm)+etot**2*weight
1141 sumQ(j,k,iparm)=sumQ(j,k,iparm)+q(j,t)*weight
1142 sumQsq(j,k,iparm)=sumQsq(j,k,iparm)+q(j,t)**2*weight
1143 sumEQ(j,k,iparm)=sumEQ(j,k,iparm)
1144 & +etot*q(j,t)*weight
1148 indE = aint(potE(t,iparm)-aint(potEmin))
1149 if (indE.ge.0 .and. indE.le.maxinde) then
1150 if (indE.gt.upindE_p) upindE_p=indE
1151 histE_p(indE)=histE_p(indE)+dexp(-entfac(t))
1155 potEmin=potEmin_all(ib,iparm)
1156 expfac=dexp(-beta_h(ib,iparm)*(etot-potEmin)+entfac(t))
1157 hfin_p(ind,ib)=hfin_p(ind,ib)+
1158 & dexp(-beta_h(ib,iparm)*(etot-potEmin)+entfac(t))
1160 indrgy=dint((q(nQ+2,t)-rgymin)/deltrgy)
1161 indrms=dint((q(nQ+1,t)-rmsmin)/deltrms)
1162 hrmsrgy_p(indrgy,indrms,ib)=
1163 & hrmsrgy_p(indrgy,indrms,ib)+expfac
1168 potEmin=potEmin_all(ib,iparm)
1169 expfac=dexp(-beta_h(ib,iparm)*(etot-potEmin)+entfac(t))
1170 hfin(ind,ib)=hfin(ind,ib)+
1171 & dexp(-beta_h(ib,iparm)*(etot-potEmin)+entfac(t))
1173 indrgy=dint((q(nQ+2,t)-rgymin)/deltrgy)
1174 indrms=dint((q(nQ+1,t)-rmsmin)/deltrms)
1175 hrmsrgy(indrgy,indrms,ib)=
1176 & hrmsrgy(indrgy,indrms,ib)+expfac
1182 if (histout) call MPI_Reduce(hfin_p(0,ib),hfin(0,ib),nbin,
1183 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1185 call MPI_Reduce(hrmsrgy_p(0,0,ib),hrmsrgy(0,0,ib),
1186 & (MaxBinRgy+1)*(nbin_rms+1),MPI_DOUBLE_PRECISION,MPI_SUM,Master,
1190 call MPI_Reduce(upindE_p,upindE,1,
1191 & MPI_INTEGER,MPI_MAX,Master,WHAM_COMM,IERROR)
1192 call MPI_Reduce(histE_p(0),histE(0),maxindE,
1193 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1195 if (me1.eq.master) then
1199 write (iout,'(6x,$)')
1200 write (iout,'(f20.2,$)') (1.0d0/(1.987D-3*beta_h(ib,iparm)),
1204 write (iout,'(/a)') 'Final histograms'
1206 if (nslice.eq.1) then
1207 if (separate_parset) then
1208 write(licz3,"(bz,i3.3)") myparm
1209 histname=prefix(:ilen(prefix))//'_par'//licz3//'.hist'
1211 histname=prefix(:ilen(prefix))//'.hist'
1214 if (separate_parset) then
1215 write(licz3,"(bz,i3.3)") myparm
1216 histname=prefix(:ilen(prefix))//'_par'//licz3//
1217 & '_slice_'//licz2//'.hist'
1219 histname=prefix(:ilen(prefix))//'_slice_'//licz2//'.hist'
1222 #if defined(AIX) || defined(PGI)
1223 open (ihist,file=histname,position='append')
1225 open (ihist,file=histname,access='append')
1233 sumH=sumH+hfin(t,ib)
1235 if (sumH.gt.0.0d0) then
1237 jj = mod(liczba,nbin1)
1239 write (iout,'(f6.3,$)') dmin+(jj+0.5d0)*delta
1241 & write (ihist,'(f6.3,$)') dmin+(jj+0.5d0)*delta
1244 write (iout,'(e20.10,$)') hfin(t,ib)
1245 if (histfile) write (ihist,'(e20.10,$)') hfin(t,ib)
1247 write (iout,'(i5)') iparm
1248 if (histfile) write (ihist,'(i5)') iparm
1255 if (nslice.eq.1) then
1256 if (separate_parset) then
1257 write(licz3,"(bz,i3.3)") myparm
1258 histname=prefix(:ilen(prefix))//"_par"//licz3//'.ent'
1260 histname=prefix(:ilen(prefix))//'.ent'
1263 if (separate_parset) then
1264 write(licz3,"(bz,i3.3)") myparm
1265 histname=prefix(:ilen(prefix))//'par_'//licz3//
1266 & '_slice_'//licz2//'.ent'
1268 histname=prefix(:ilen(prefix))//'_slice_'//licz2//'.ent'
1271 #if defined(AIX) || defined(PGI)
1272 open (ihist,file=histname,position='append')
1274 open (ihist,file=histname,access='append')
1276 write (ihist,'(a)') "# Microcanonical entropy"
1278 write (ihist,'(f8.0,$)') dint(potEmin)+i
1279 if (histE(i).gt.0.0e0) then
1280 write (ihist,'(f15.5,$)') dlog(histE(i))
1282 write (ihist,'(f15.5,$)') 0.0d0
1288 write (iout,*) "Microcanonical entropy"
1290 write (iout,'(f8.0,$)') dint(potEmin)+i
1291 if (histE(i).gt.0.0e0) then
1292 write (iout,'(f15.5,$)') dlog(histE(i))
1294 write (iout,'(f15.5,$)') 0.0d0
1299 if (nslice.eq.1) then
1300 if (separate_parset) then
1301 write(licz3,"(bz,i3.3)") myparm
1302 histname=prefix(:ilen(prefix))//'_par'//licz3//'.rmsrgy'
1304 histname=prefix(:ilen(prefix))//'.rmsrgy'
1307 if (separate_parset) then
1308 write(licz3,"(bz,i3.3)") myparm
1309 histname=prefix(:ilen(prefix))//'_par'//licz3//
1310 & '_slice_'//licz2//'.rmsrgy'
1312 histname=prefix(:ilen(prefix))//'_slice_'//licz2//'.rmsrgy'
1315 #if defined(AIX) || defined(PGI)
1316 open (ihist,file=histname,position='append')
1318 open (ihist,file=histname,access='append')
1322 write(ihist,'(2f8.2,$)')
1323 & rgymin+deltrgy*j,rmsmin+deltrms*i
1325 if (hrmsrgy(j,i,ib).gt.0.0d0) then
1326 write(ihist,'(e14.5,$)')
1327 & -dlog(hrmsrgy(j,i,ib))/beta_h(ib,iparm)
1330 write(ihist,'(e14.5,$)') 1.0d6
1333 write (ihist,'(i2)') iparm
1341 call MPI_Reduce(hfin_ent_p(0),hfin_ent(0),nbin,
1342 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1343 call MPI_Reduce(sumW_p(0,1),sumW(0,1),(nGridT+1)*nParmSet,
1344 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1345 call MPI_Reduce(sumE_p(0,1),sumE(0,1),(nGridT+1)*nParmSet,
1346 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1347 call MPI_Reduce(sumEbis_p(0,1),sumEbis(0,1),(nGridT+1)*nParmSet,
1348 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1349 call MPI_Reduce(sumEsq_p(0,1),sumEsq(0,1),(nGridT+1)*nParmSet,
1350 & MPI_DOUBLE_PRECISION,MPI_SUM,Master,WHAM_COMM,IERROR)
1351 call MPI_Reduce(sumQ_p(1,0,1),sumQ(1,0,1),
1352 & MaxQ1*(nGridT+1)*nParmSet,MPI_DOUBLE_PRECISION,MPI_SUM,Master,
1354 call MPI_Reduce(sumQsq_p(1,0,1),sumQsq(1,0,1),
1355 & MaxQ1*(nGridT+1)*nParmSet,MPI_DOUBLE_PRECISION,MPI_SUM,Master,
1357 call MPI_Reduce(sumEQ_p(1,0,1),sumEQ(1,0,1),
1358 & MaxQ1*(nGridT+1)*nParmSet,MPI_DOUBLE_PRECISION,MPI_SUM,Master,
1360 if (me.eq.master) then
1362 write (iout,'(/a)') 'Thermal characteristics of folding'
1363 if (nslice.eq.1) then
1366 nazwa=prefix(:ilen(prefix))//"_slice_"//licz2
1369 if (nparmset.eq.1 .and. .not.separate_parset) then
1370 nazwa=nazwa(:iln)//".thermal"
1371 else if (nparmset.eq.1 .and. separate_parset) then
1372 write(licz3,"(bz,i3.3)") myparm
1373 nazwa=nazwa(:iln)//"_par_"//licz3//".thermal"
1376 if (nparmset.gt.1) then
1377 write(licz3,"(bz,i3.3)") iparm
1378 nazwa=nazwa(:iln)//"_par_"//licz3//".thermal"
1381 if (separate_parset) then
1382 write (iout,'(a,i3)') "Parameter set",myparm
1384 write (iout,'(a,i3)') "Parameter set",iparm
1387 betaT=1.0d0/(1.987D-3*(startGridT+i*delta_T))
1388 if (betaT.ge.beta_h(1,iparm)) then
1389 potEmin=potEmin_all(1,iparm)
1390 else if (betaT.lt.beta_h(nT_h(iparm),iparm)) then
1391 potEmin=potEmin_all(nT_h(iparm),iparm)
1393 do l=1,nT_h(iparm)-1
1394 if (betaT.le.beta_h(l,iparm) .and.
1395 & betaT.gt.beta_h(l+1,iparm)) then
1396 potEmin=potEmin_all(l,iparm)
1401 sumE(i,iparm)=sumE(i,iparm)/sumW(i,iparm)
1402 sumEbis(i,iparm)=(startGridT+i*delta_T)*sumEbis(i,iparm)/
1404 sumEsq(i,iparm)=(sumEsq(i,iparm)/sumW(i,iparm)
1405 & -sumE(i,iparm)**2)/(1.987D-3*(startGridT+i*delta_T)**2)
1407 sumQ(j,i,iparm)=sumQ(j,i,iparm)/sumW(i,iparm)
1408 sumQsq(j,i,iparm)=sumQsq(j,i,iparm)/sumW(i,iparm)
1409 & -sumQ(j,i,iparm)**2
1410 sumEQ(j,i,iparm)=sumEQ(j,i,iparm)/sumW(i,iparm)
1411 & -sumQ(j,i,iparm)*sumE(i,iparm)
1413 sumW(i,iparm)=-dlog(sumW(i,iparm))*(1.987D-3*
1414 & (startGridT+i*delta_T))+potEmin
1415 write (iout,'(f7.1,2f15.5,$)') startGridT+i*delta_T,
1416 & sumW(i,iparm),sumE(i,iparm)
1417 write (iout,'(f10.5,$)') (sumQ(j,i,iparm),j=1,nQ+2)
1418 write (iout,'(e15.5,$)') sumEsq(i,iparm)-sumEbis(i,iparm),
1419 & (sumQsq(j,i,iparm),j=1,nQ+2),(sumEQ(j,i,iparm),j=1,nQ+2)
1421 write (34,'(f7.1,2f15.5,$)') startGridT+i*delta_T,
1422 & sumW(i,iparm),sumE(i,iparm)
1423 write (34,'(f10.5,$)') (sumQ(j,i,iparm),j=1,nQ+2)
1424 write (34,'(e15.5,$)') sumEsq(i,iparm)-sumEbis(i,iparm),
1425 & (sumQsq(j,i,iparm),j=1,nQ+2),(sumEQ(j,i,iparm),j=1,nQ+2)
1432 if (hfin_ent(t).gt.0.0d0) then
1434 jj = mod(liczba,nbin1)
1435 write (iout,'(f6.3,e20.10," ent")') dmin+(jj+0.5d0)*delta,
1437 if (histfile) write (ihist,'(f6.3,e20.10," ent")')
1438 & dmin+(jj+0.5d0)*delta,
1442 if (histfile) close(ihist)
1446 ! Write data for zscore
1447 if (nslice.eq.1) then
1448 zscname=prefix(:ilen(prefix))//".zsc"
1450 zscname=prefix(:ilen(prefix))//"_slice_"//licz2//".zsc"
1452 #if defined(AIX) || defined(PGI)
1453 open (izsc,file=prefix(:ilen(prefix))//'.zsc',position='append')
1455 open (izsc,file=prefix(:ilen(prefix))//'.zsc',access='append')
1457 write (izsc,'("NQ=",i1," NPARM=",i1)') nQ,nParmSet
1459 write (izsc,'("NT=",i1)') nT_h(iparm)
1461 write (izsc,'("TEMP=",f6.1," NR=",i2," SNK=",$)')
1462 & 1.0d0/(beta_h(ib,iparm)*1.987D-3),nR(ib,iparm)
1463 jj = min0(nR(ib,iparm),7)
1464 write (izsc,'(i8,$)') (snk(i,ib,iparm,islice),i=1,jj)
1465 write (izsc,'(a1,$)') (" ",i=22+8*jj+1,79)
1466 write (izsc,'("&")')
1467 if (nR(ib,iparm).gt.7) then
1468 do ii=8,nR(ib,iparm),9
1469 jj = min0(nR(ib,iparm),ii+8)
1470 write (izsc,'(i8,$)') (snk(i,ib,iparm,islice),i=ii,jj)
1471 write (izsc,'(a1,$') (" ",i=(jj-ii+1)*8+1,79)
1472 write (izsc,'("&")')
1475 write (izsc,'("FI=",$)')
1476 jj=min0(nR(ib,iparm),7)
1477 write (izsc,'(f10.5,$)') (fi(i,ib,iparm),i=1,jj)
1478 write (izsc,'(a1,$)') (" ",i=3+10*jj+1,79)
1479 write (izsc,'("&")')
1480 if (nR(ib,iparm).gt.7) then
1481 do ii=8,nR(ib,iparm),9
1482 jj = min0(nR(ib,iparm),ii+8)
1483 write (izsc,'(f10.5,$)') (fi(i,ib,iparm),i=ii,jj)
1484 if (jj.eq.nR(ib,iparm)) then
1487 write (izsc,'(a1,$)') (" ",i=10*(jj-ii+1)+1,79)
1488 write (izsc,'(t80,"&")')
1493 write (izsc,'("KH=",$)')
1494 write (izsc,'(f7.2,$)') (Kh(j,i,ib,iparm),j=1,nQ)
1495 write (izsc,'(" Q0=",$)')
1496 write (izsc,'(f7.5,$)') (q0(j,i,ib,iparm),j=1,nQ)