subroutine md_main() c c $Id$ c implicit none c #include "md_common.fh" c if(ntype.eq.0) then c c single energy c ------------- c if(nftri.eq.0) then call md_sp() else call md_spi() endif c elseif(ntype.eq.1) then c c energy minimization c ------------------- c call md_em() c elseif(ntype.eq.2) then c c molecular dynamics c ------------------ c call md_md() c elseif(ntype.eq.3) then c c free energy simulation c ---------------------- c call md_ti() c else call md_abort('Unknown calculation type',ntype) endif c return end subroutine md_sp() c implicit none c #include "md_common.fh" #include "mafdecls.fh" c lpair=.true. lload=.false. lhop=.false. llong=ltwin c c center of mass coordinates c call cf_cenmas(nwmloc,dbl_mb(i_xw),dbl_mb(i_xwm),nsaloc, + int_mb(i_is+(lsatt-1)*msa),int_mb(i_is+(lsmol-1)*msa), + dbl_mb(i_xs),dbl_mb(i_xsm),dbl_mb(i_gsm)) c c periodic boundary conditions c call md_fold(int_mb(i_iw),int_mb(i_is), + dbl_mb(i_xw),dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_xsm)) c c atom redistribution c call sp_travel(box,dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_xwcr), + dbl_mb(i_gw),int_mb(i_iw),nwmloc,dbl_mb(i_xs),dbl_mb(i_vs), + dbl_mb(i_gs),int_mb(i_is),nsaloc) c c center of mass coordinates c call cf_cenmas(nwmloc,dbl_mb(i_xw),dbl_mb(i_xwm),nsaloc, + int_mb(i_is+(lsatt-1)*msa),int_mb(i_is+(lsmol-1)*msa), + dbl_mb(i_xs),dbl_mb(i_xsm),dbl_mb(i_gsm)) c call cf_mass(dbl_mb(i_wws),dbl_mb(i_wws+mwa), + int_mb(i_is+(lsatt-1)*msa),nsaloc) c call md_eminit(dbl_mb(i_xw),dbl_mb(i_yw), + dbl_mb(i_xs),dbl_mb(i_ys)) c c atomic forces and potential energies c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(0,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) c if(.not.lqmmm) call prp_print() c call rtdb_put(irtdb,'md:energy',mt_dbl,1,epot) c c print energies c if(.not.lqmmm) then call cf_print_energy(lfnout) call sp_printf(filtop,lfntop, + int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_fs),npener,dbl_mb(i_esa)) endif c if(ifidi.ne.0) then call md_fd(int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_vs),dbl_mb(i_fs), + int_mb(i_iw),dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_fw)) endif c if(itest.eq.1) call md_test() c return end subroutine md_sp_qmmm() c implicit none c #include "md_common.fh" #include "mafdecls.fh" #include "msgids.fh" lpair=.false. lload=.false. c atomic forces and potential energies c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(0,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) call rtdb_put(irtdb,'md:energy',mt_dbl,1,epot) return end subroutine md_spi() c implicit none c #include "md_common.fh" #include "mafdecls.fh" c external sp_rdtrj,sp_skip,frequency logical sp_rdtrj,sp_skip,frequency c integer import c if(impfr.gt.1) then if(.not.sp_skip(lfntri,impfr-1)) return endif c do 1 import=impfr,impto c if(.not.frequency(import+1-impfr,nftri)) then if(.not.sp_skip(lfntri,1)) return goto 1 endif c lpair=.true. lload=.true. lhop=.false. llong=ltwin c c read frame from trajectory file c if(.not.sp_rdtrj(lfntri,lxw,lvw,lfw,lxs,lvs,lfs, + stime,pres,temp,tempw,temps, + int_mb(i_iw),dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_fw), + dbl_mb(i_xwcr),int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_vs), + dbl_mb(i_fs),nwmloc,nsaloc)) return c c center of mass coordinates c call cf_cenmas(nwmloc,dbl_mb(i_xw),dbl_mb(i_xwm),nsaloc, + int_mb(i_is+(lsatt-1)*msa),int_mb(i_is+(lsmol-1)*msa), + dbl_mb(i_xs),dbl_mb(i_xsm),dbl_mb(i_gsm)) c c periodic boundary conditions c call md_fold(int_mb(i_iw),int_mb(i_is), + dbl_mb(i_xw),dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_xsm)) c c atom redistribution c call sp_travel(box,dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_xwcr), + dbl_mb(i_gw),int_mb(i_iw),nwmloc,dbl_mb(i_xs),dbl_mb(i_vs), + dbl_mb(i_gs),int_mb(i_is),nsaloc) c call cf_mass(dbl_mb(i_wws),dbl_mb(i_wws+mwa), + int_mb(i_is+(lsatt-1)*msa),nsaloc) c call md_eminit(dbl_mb(i_xw),dbl_mb(i_yw), + dbl_mb(i_xs),dbl_mb(i_ys)) c c atomic forces and potential energies c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(import,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) c call prp_step(import,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm) c cx call prp_print() c call rtdb_put(irtdb,'md:energy',mt_dbl,1,epot) c c print energies c if(me.eq.0.and.frequency(import,npener)) + call cf_print_energy(lfnout) c if(me.eq.0.and.frequency(import,nfprop)) call prp_record() c if(me.eq.0.and.frequency(import,npforc)) + call sp_printf(filtop,lfntop, + int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_fs),npener,dbl_mb(i_esa)) c if(ifidi.ne.0) then call md_fd(int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_vs),dbl_mb(i_fs), + int_mb(i_iw),dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_fw)) endif c if(itest.eq.1) call md_test() c 1 continue c return end subroutine md_em() c implicit none c #include "md_common.fh" #include "mafdecls.fh" c integer i_pcgw,l_pcgw,i_pcgs,l_pcgs c llong=ltwin c c center of mass coordinates c call cf_cenmas(nwmloc,dbl_mb(i_xw),dbl_mb(i_xwm),nsaloc, + int_mb(i_is+(lsatt-1)*msa),int_mb(i_is+(lsmol-1)*msa), + dbl_mb(i_xs),dbl_mb(i_xsm),dbl_mb(i_gsm)) c c periodic boundary conditions c call md_fold(int_mb(i_iw),int_mb(i_is), + dbl_mb(i_xw),dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_xsm)) c c atom redistribution c call sp_travel(box,dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_xwcr), + dbl_mb(i_gw),int_mb(i_iw),nwmloc,dbl_mb(i_xs),dbl_mb(i_vs), + dbl_mb(i_gs),int_mb(i_is),nsaloc) c c center of mass coordinates c call cf_cenmas(nwmloc,dbl_mb(i_xw),dbl_mb(i_xwm),nsaloc, + int_mb(i_is+(lsatt-1)*msa),int_mb(i_is+(lsmol-1)*msa), + dbl_mb(i_xs),dbl_mb(i_xsm),dbl_mb(i_gsm)) c call cf_mass(dbl_mb(i_wws),dbl_mb(i_wws+mwa), + int_mb(i_is+(lsatt-1)*msa),nsaloc) c call md_eminit(dbl_mb(i_xw),dbl_mb(i_yw), + dbl_mb(i_xs),dbl_mb(i_ys)) c if(msdit.gt.0) call md_stdesc(int_mb(i_iw+(lwdyn-1)*mwm), + dbl_mb(i_xw),dbl_mb(i_yw),dbl_mb(i_vw),dbl_mb(i_fw), + int_mb(i_is+(lsdyn-1)*msa),int_mb(i_is+(lsmol-1)*msa), + dbl_mb(i_xs),dbl_mb(i_ys),dbl_mb(i_vs),dbl_mb(i_fs), + dbl_mb(i_wws),dbl_mb(i_wws+mwa),int_mb(i_mm),dbl_mb(i_fm), + dbl_mb(i_xsm)) c if(mcgit.gt.0) then if(.not.ma_push_get(mt_dbl,3*mwa*mwm,'pcgw',l_pcgw,i_pcgw)) + call md_abort('Failed to allocate memory for pcgw',me) if(.not.ma_push_get(mt_dbl,3*msa,'pcgs',l_pcgs,i_pcgs)) + call md_abort('Failed to allocate memory for pcgs',me) call md_congra(int_mb(i_iw+(lwdyn-1)*mwm),dbl_mb(i_xw), + dbl_mb(i_yw),dbl_mb(i_vw),dbl_mb(i_fw),dbl_mb(i_pcgw), + int_mb(i_is+(lsdyn-1)*msa),dbl_mb(i_xs),dbl_mb(i_ys), + dbl_mb(i_vs),dbl_mb(i_fs),dbl_mb(i_pcgs),dbl_mb(i_wws), + dbl_mb(i_wws+mwa)) if(.not.ma_pop_stack(l_pcgs)) + call md_abort('Failed to deallocate memory for pcgs',me) if(.not.ma_pop_stack(l_pcgw)) + call md_abort('Failed to deallocate memory for pcgw',me) endif c call cf_print_energy(lfnout) c call sp_printf(filtop,lfntop, + int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_fs),npener,dbl_mb(i_esa)) c return end subroutine md_eminit(xw,yw,xs,ys) c implicit none c #include "md_common.fh" #include "mafdecls.fh" c real*8 xw(mwm,3,mwa),yw(mwm,3,mwa) real*8 xs(msa,3),ys(msa,3) c integer i,j real*8 dxmax c if(nwmloc.gt.0) then do 1 j=1,nwa do 2 i=1,nwmloc yw(i,1,j)=xw(i,1,j) yw(i,2,j)=xw(i,2,j) yw(i,3,j)=xw(i,3,j) 2 continue 1 continue endif c if(nsaloc.gt.0) then do 3 i=1,nsaloc ys(i,1)=xs(i,1) ys(i,2)=xs(i,2) ys(i,3)=xs(i,3) 3 continue endif c return c lpair=.true. lload=.true. lhop=.false. c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c c shake c call md_shake(dbl_mb(i_xw),dbl_mb(i_yw),int_mb(i_iw), + dbl_mb(i_xs),dbl_mb(i_ys),int_mb(i_is),dxmax) c return end subroutine md_stdesc(iwdt,xw,yw,vw,fw,isdt,ismol, + xs,ys,vs,fs,ww,ws,mm,fm,xsm) c implicit none c #include "md_common.fh" #include "mafdecls.fh" #include "msgids.fh" #include "global.fh" c logical frequency external frequency c integer iwdt(mwm),isdt(msa),ismol(msa),mm(msa,2) real*8 xw(mwm,3,mwa),yw(mwm,3,mwa),vw(mwm,3,mwa),fw(mwm,3,mwa) real*8 xs(msa,3),ys(msa,3),vs(msa,3),fs(msa,3) real*8 ww(mwa),ws(msa),xsm(msm,3),fm(msm,7) c integer i,j logical ldone real*8 edif,epsd,epsdw,epsdsw,epsds,ecrit real*8 da,damsd,dx,dxf,dxmax,factor,dxstep,eqrs character*1 cqrs real*8 angle,o(3),p(3),x(3),y(3) c double precision grms(2) integer nrms(2) c damsd=-1.1d0 if(imembr.gt.0) call md_membrane_init(ismol,mm,xs,xsm,fm) c if(lqmmm) then if(me.eq.0) write(6,601) "@","@" end if 601 format( $ /,a1,' Step Energy Delta E SGrms', $ ' WGrms Xmax', $ /,a1,' ---- ---------------- -------- --------', $ ' -------- -------- ') if(me.eq.0) write(lfnout,1000) 1000 format(/,' STEEPEST DESCENT MINIMIZATION',//, + ' Step File Energy Energy Energy ', + ' Energy Energy Largest ',/, + ' wrt gradient Total solvent ', + ' slv-sol solute displacement',/, + ' kJ/mol kJ/mol kJ/mol ', + ' kJ/mol kJ/mol nm',/) c isdit=0 c lpair=.true. lload=.true. lhop=.false. c c atomic forces and potential energies c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(isdit,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) c if(lqmmm) call qmmm_print_energy1(irtdb,epot,uqmmm) c epsd=epot epsdw=epotw epsdsw=epotsw epsds=epots eqrs=epot dx=dx0sd mdstep=0 da=0.01 c 1 continue call timer_start(201) c dxf=dx/fmax c if(nwmloc.gt.0) then do 2 j=1,nwa do 3 i=1,nwmloc yw(i,1,j)=xw(i,1,j) yw(i,2,j)=xw(i,2,j) yw(i,3,j)=xw(i,3,j) vw(i,1,j)=fw(i,1,j) vw(i,2,j)=fw(i,2,j) vw(i,3,j)=fw(i,3,j) 3 continue factor=one/ww(j) do 4 i=1,nwmloc if(iand(iwdt(i),mfixed).ne.lfixed) then dxstep=factor*dxf*fw(i,1,j) xw(i,1,j)=xw(i,1,j)+dxstep dxstep=factor*dxf*fw(i,2,j) xw(i,2,j)=xw(i,2,j)+dxstep dxstep=factor*dxf*fw(i,3,j) xw(i,3,j)=xw(i,3,j)+dxstep endif 4 continue 2 continue endif c if(nsaloc.gt.0) then do 5 i=1,nsaloc ys(i,1)=xs(i,1) ys(i,2)=xs(i,2) ys(i,3)=xs(i,3) vs(i,1)=fs(i,1) vs(i,2)=fs(i,2) vs(i,3)=fs(i,3) 5 continue if(imembr.eq.0) then do 6 i=1,nsaloc if(iand(isdt(i),mfixed).ne.lfixed) then factor=one/ws(i) dxstep=factor*dxf*fs(i,1) xs(i,1)=xs(i,1)+dxstep dxstep=factor*dxf*fs(i,2) xs(i,2)=xs(i,2)+dxstep dxstep=factor*dxf*fs(i,3) xs(i,3)=xs(i,3)+dxstep endif 6 continue else do 16 i=1,msm fm(i,1)=zero fm(i,2)=zero fm(i,3)=zero fm(i,4)=zero fm(i,5)=zero fm(i,6)=zero fm(i,7)=zero 16 continue do 17 i=1,nsaloc factor=one/ws(i) fm(mm(i,2),1)=fm(mm(i,2),1)+factor*fs(i,1) fm(mm(i,2),2)=fm(mm(i,2),2)+factor*fs(i,2) fm(mm(i,2),3)=fm(mm(i,2),3)+factor* + ((xs(i,1)-xsm(mm(i,2),1))*fs(i,2)- + (xs(i,2)-xsm(mm(i,2),2))*fs(i,1)) 17 continue if(np.gt.1) call ga_dgop(mrg_d50,fm,3*msm,'+') do 18 i=1,nsm fm(i,4)=fm(i,3) write(*,'(a,i5,a,i5)') 'Mol ',i,', Angle ',da*fm(i,4) 18 continue do 19 i=1,nsaloc if(iand(isdt(i),mfixed).ne.lfixed) then c c rotations c o(1)=xsm(mm(i,2),1) o(2)=xsm(mm(i,2),1) o(3)=xsm(mm(i,2),1) p(1)=o(1) p(2)=o(2) p(3)=o(3)+1.0d0 x(1)=xs(i,1) x(2)=xs(i,2) x(3)=xs(i,3) angle=da*fm(mm(i,2),4) call rotate(o,p,angle,x,y) xs(i,1)=y(1) xs(i,2)=y(2) xs(i,3)=y(3) c c translations c dxstep=dxf*fm(mm(i,2),1) xs(i,1)=xs(i,1)+dxstep dxstep=dxf*fm(mm(i,2),2) xs(i,2)=xs(i,2)+dxstep c endif 19 continue endif endif c c shake c call md_shake(dbl_mb(i_xw),dbl_mb(i_yw),int_mb(i_iw), + dbl_mb(i_xs),dbl_mb(i_ys),int_mb(i_is),dxmax) c isdit=isdit+1 c lpair=frequency(isdit,nfpair) lload=lpair lhop=.false. llong=(frequency(isdit,nflong).or.lpair).and.ltwin c c atomic forces and potential energies c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(isdit,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) c if(lqmmm) call qmmm_print_energy1(irtdb,epot,uqmmm) c c if energy goes up restore coordinates and forces c ecrit=epot if(icrit.eq.1) ecrit=epot c c changing the logic here so that bad coordinates c are not preserved in the last md iteration (M.V.) c ------------------------------------------------ if(ecrit.gt.epsd) then c call cf_restor(dbl_mb(i_xw),dbl_mb(i_yw),dbl_mb(i_fw), + dbl_mb(i_vw),nwmloc,dbl_mb(i_xs),dbl_mb(i_ys),dbl_mb(i_fs), + dbl_mb(i_vs),nsaloc) c if(isdit.lt.msdit.and.dxmax.gt.dxsdmx) then dx=half*dx da=half*da call timer_stop(201) if(dx.gt.dxsdmx) goto 1 else c c this insures the global restoration of coordinates c so that the right restart file written out c -------------------------------------------------- call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(isdit,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) c endif endif c edif=ecrit-epsd epsd=ecrit epsdw=epotw epsdsw=epotsw epsds=epots c lxw=frequency(mdstep,nfcoor) lxs=frequency(mdstep,nfscoo) c if(lxw.or.lxs) then if(lqmd) then call qmd_wrttrj(lfntrj,mwm,nwmloc,mwa,nwa,msa,nsaloc, + .true.,.false.,.true.,.false.,box,stime,pres,temp,tempw,temps, + dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_xs),dbl_mb(i_vs)) else call sp_wrttrj(lfntrj,lxw,.false.,.false.,lxs,.false.,.false., + stime,pres,temp,tempw,temps, + int_mb(i_iw),dbl_mb(i_xw),dbl_mb(i_vw),dbl_mb(i_fw), + dbl_mb(i_xwcr),int_mb(i_is),dbl_mb(i_xs),dbl_mb(i_vs), + dbl_mb(i_fs)) endif endif c ldone=.not.(dxmax.gt.dxsdmx.and.isdit.lt.msdit) c cqrs=' ' if(frequency(isdit,nfqrs).or.(ldone.and.eqrs.gt.epot)) then write(projct,4000) nserie,isdit,0,filnam(1:56) 4000 format(i2,' em ',i7,' + ',i7,' ',a) call md_wrtrst(lfnqrs,filqrs,.false.) cqrs='*' eqrs=epot endif if(me.eq.0.and.frequency(isdit,nfprop)) call prp_record() c if(me.eq.0) then write(lfnout,600) isdit,cqrs,edif,epsd,epsdw,epsdsw,epsds,dxmax 600 format(i7,1x,a1,3x,5(1pe13.5),0pf12.8) call util_flush(lfnout) endif c if(lqmmm) then nrms(2) = 0 grms(2) = 0.0d0 if(nwmloc.gt.0) then do j=1,nwa do i=1,nwmloc if(iand(iwdt(i),mfixed).ne.lfixed) then nrms(2) = nrms(2) + 1 grms(2) = grms(2) + + fw(i,1,j)*fw(i,1,j) + + fw(i,2,j)*fw(i,2,j) + + fw(i,3,j)*fw(i,3,j) endif end do end do endif c nrms(1) = 0 grms(1) = 0.0d0 do i=1,nsaloc if(iand(isdt(i),mfixed).ne.lfixed) then nrms(1) = nrms(1) + 1 grms(1) = grms(1) + + fs(i,1)*fs(i,1)+ + fs(i,2)*fs(i,2)+ + fs(i,3)*fs(i,3) endif end do call ga_dgop(msg_qmmm_force,grms,2,'+') call ga_igop(msg_qmmm_nat1,nrms,2,'+') do i=1,2 if(nrms(i).ne.0) then grms(i) = sqrt(grms(i)/dble(nrms(i))) grms(i) = grms(i)*5.29177249d-02/2.625499962d+03 end if end do if(me.eq.0) $ write(6,602) "@", isdit, epsd/2.625499962d+03, $ edif/2.625499962d+03, $ grms(1), grms(2), $ dxmax/5.29177249d-02 602 format(a1,i5,f17.8,1p,d9.1,0p,3f9.5) end if c if(itest.gt.0) call md_test() c dx=min(1.2d0*dx,dxmsd) da=min(1.2d0*da,damsd) c call timer_stop(201) if(.not.ldone) goto 1 return end subroutine md_congra(iwdt,xw,yw,vw,fw,pcgw, + isdt,xs,ys,vs,fs,pcgs,ww,ws) c implicit none c #include "md_common.fh" #include "mafdecls.fh" #include "msgids.fh" c logical frequency external frequency c integer iwdt(mwm),isdt(msa) real*8 xw(mwm,3,mwa),yw(mwm,3,mwa),vw(mwm,3,mwa),fw(mwm,3,mwa) real*8 xs(msa,3),ys(msa,3),vs(msa,3),fs(msa,3) real*8 pcgw(mwm,3,mwa),pcgs(msa,3),ww(mwa),ws(msa) c integer iwa,iwm,isa,ix,inner logical ldone real*8 alpha,beta1,beta2,beta3,beta4,beta5,gamma,zeta real*8 dx,ecgnew,eqrs,ecgold,ecgdif,edt,dxf real*8 dxsmax,dxwmax,fnorm1,fnorm2,ypa,ypb,pnorm,dxstep real*8 dxmax,dxfi,ecg0,ecg1,ecg2,epcgw,epcgsw,epcgs character*1 cqrs c if(me.eq.0) write(lfnout,1000) 1000 format(/,' CONJUGATE GRADIENT MINIMIZATION',//, + ' Step File Energy Energy Energy ', + ' Energy Energy Largest ',/, + ' wrt gradient Total solvent ', + ' slv-sol solute displacement',/, + ' kJ/mol kJ/mol kJ/mol ', + ' kJ/mol kJ/mol nm',/) c dx=dx0cg beta1=zero icgit=0 lpair=.true. lload=.true. lhop=.false. c call timer_start(201) c c atomic forces and potential energies c call md_finit(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs), + dbl_mb(i_xsm),dbl_mb(i_xsmp)) call md_forces(int_mb(i_iw),int_mb(i_is),dbl_mb(i_xw), + dbl_mb(i_xwm),dbl_mb(i_xs),dbl_mb(i_fw),dbl_mb(i_fs)) c call prp_proper(isdit,stime,eww,dbl_mb(i_esw), + dbl_mb(i_ess),dbl_mb(i_fss),dbl_mb(i_esk),epme,uqmd,uqmmm, + epot,epotw,epotsw,epots,volume,dwr,dbl_mb(i_dsr),ekin,etot, + npolit,dbl_mb(i_gsm),dbl_mb(i_esa),box,dbl_mb(i_xsm)) c ecgnew=epot eqrs=epot ecgold=ecgnew ecgdif=zero edt=zero c c copy initial coordinates into vw and vs c initialize search direction vectors pcgw and pcgs to zero c if(nwmloc.gt.0) then do 1 iwa=1,nwa do 2 ix=1,3 do 3 iwm=1,nwmloc vw(iwm,ix,iwa)=xw(iwm,ix,iwa) pcgw(iwm,ix,iwa)=zero 3 continue 2 continue 1 continue endif if(nsaloc.gt.0) then do 4 ix=1,3 do 5 isa=1,nsaloc vs(isa,ix)=xs(isa,ix) pcgs(isa,ix)=zero 5 continue 4 continue endif c c take one steepest descent step to get initial search direction c dxf=half*dx/fmax if(nwmloc.gt.0) then do 6 iwa=1,nwa do 7 ix=1,3 do 8 iwm=1,nwmloc yw(iwm,ix,iwa)=xw(iwm,ix,iwa) if(iand(iwdt(iwm),mfixed).ne.lfixed) then xw(iwm,ix,iwa)=xw(iwm,ix,iwa)+dxf*fw(iwm,ix,iwa)/ww(iwa) endif 8 continue 7 continue 6 continue endif if(nsaloc.gt.0) then do 9 ix=1,3 do 10 isa=1,nsaloc ys(isa,ix)=xs(isa,ix) if(iand(isdt(isa),mfixed).ne.lfixed) then xs(isa,ix)=xs(isa,ix)+dxf*fs(isa,ix)/ws(isa) endif 10 continue 9 continue endif c c shake c call md_shake(dbl_mb(i_xw),dbl_mb(i_yw),int_mb(i_iw), + dbl_mb(i_xs),dbl_mb(i_ys),int_mb(i_is),dxmax) c fnorm1=zero dxfi=one/dxf if(nwmloc.gt.0) then do 11 iwa=1,nwa do 12 ix=1,3 do 13 iwm=1,nwmloc fw(iwm,ix,iwa)=(xw(iwm,ix,iwa)-yw(iwm,ix,iwa))*dxfi*ww(iwa) fnorm1=fnorm1+fw(iwm,ix,iwa)**2 13 continue 12 continue 11 continue endif if(nsaloc.gt.0) then do 14 ix=1,3 do 15 isa=1,nsaloc fs(isa,ix)=(xs(isa,ix)-ys(isa,ix))*dxfi*ws(isa) fnorm1=fnorm1+fs(isa,ix)**2 15 continue 14 continue endif c c global sum fnorm1 c call ga_dgop(mrg_d08,fnorm1,1,'+') c ecg0=ecgnew ecg1=ecgnew ecg2=ecgnew icgit=0 c call timer_stop(201) c c outer loop c 100 continue c if(icgit.eq.(icgit/ncgcy)*ncgcy) beta1=zero icgit=icgit+1 lpair=frequency(icgit,nfpair) lload=frequency(icgit,nfload) lhop=.false. c ypa=zero pnorm=zero if(nwmloc.gt.0) then do 16 iwa=1,nwa do 17 ix=1,3 do 18 iwm=1,nwmloc pcgw(iwm,ix,iwa)=fw(iwm,ix,iwa)+beta1*pcgw(iwm,ix,iwa) pnorm=pnorm+pcgw(iwm,ix,iwa)**2 ypa=ypa+pcgw(iwm,ix,iwa)*fw(iwm,ix,iwa) 18 continue 17 continue 16 continue endif if(nsaloc.gt.0) then do 19 ix=1,3 do 20 isa=1,nsaloc pcgs(isa,ix)=fs(isa,ix)+beta1*pcgs(isa,ix) pnorm=pnorm+pcgs(isa,ix)**2 ypa=ypa+pcgs(isa,ix)*fs(isa,ix) 20 continue 19 continue endif c c accumulate pnorm c call ga_dgop(mrg_d09,ypa,1,'+') call ga_dgop(mrg_d10,pnorm,1,'+') c if(pnorm.lt.zero) call md_abort('congra: pnorm