3 implicit real*8 (a-h,o-z)
6 include 'COMMON.CONTROL'
10 include 'COMMON.LANGEVIN'
12 include 'COMMON.LANGEVIN.lang0'
14 include 'COMMON.CHAIN'
15 include 'COMMON.DERIV'
17 include 'COMMON.LOCAL'
18 include 'COMMON.INTERACT'
19 include 'COMMON.IOUNITS'
20 include 'COMMON.NAMES'
21 include 'COMMON.TIME1'
23 include 'COMMON.SETUP'
26 double precision cm(3),L(3),vcm(3)
27 double precision energia(0:n_ene)
28 double precision remd_t_bath(maxprocs)
29 integer iremd_iset(maxprocs)
31 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
32 double precision remd_ene(0:n_ene+4,maxprocs),t_bath_old
33 integer iremd_acc(maxprocs),iremd_tot(maxprocs)
34 integer iremd_acc_usa(maxprocs),iremd_tot_usa(maxprocs)
40 cold integer nup(0:maxprocs),ndown(0:maxprocs)
41 integer rep2i(0:maxprocs),ireqi(maxprocs)
42 integer icache_all(maxprocs)
43 integer status(MPI_STATUS_SIZE),statusi(MPI_STATUS_SIZE,maxprocs)
44 logical synflag,end_of_run,file_exist /.false./,ovrtim
51 if(me.eq.king.or..not.out1file) then
52 write (iout,*) 'MREMD',nodes,'time before',time00-walltime
53 write (iout,*) "NREP=",nrep
57 if (ilen(tmpdir).gt.0 .and. (me.eq.king)) then
58 call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_mremd.rst")
60 mremd_rst_name=prefix(:ilen(prefix))//"_mremd.rst"
62 cd print *,'MREMD',nodes
63 cd print *,'mmm',me,remd_mlist,(remd_m(i),i=1,nrep)
64 cde write (iout,*) "Start MREMD: me",me," t_bath",t_bath
76 do il1=1,max0(mset(il),1)
92 if(me.eq.king.or..not.out1file) then
93 write(iout,*) "i2rep",(i2rep(i),i=0,nodes-1)
94 write(iout,*) "i2set",(i2set(i),i=0,nodes-1)
95 write(iout,*) "i,j,il,il1,i_index(i,j,il,il1)"
100 write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
107 c print *,'i2rep',me,i2rep(me)
108 c print *,'rep2i',(rep2i(i),i=0,nrep)
110 cold if (i2rep(me).eq.nrep) then
113 cold nup(0)=remd_m(i2rep(me)+1)
114 cold k=rep2i(int(i2rep(me)))+1
121 cd print '(i4,a4,100i4)',me,' nup',(nup(i),i=0,nup(0))
123 cold if (i2rep(me).eq.1) then
126 cold ndown(0)=remd_m(i2rep(me)-1)
127 cold k=rep2i(i2rep(me)-2)+1
134 cd print '(i4,a6,100i4)',me,' ndown',(ndown(i),i=0,ndown(0))
137 write (*,*) "Processor",me," rest",rest,"
138 & restart1fie",restart1file
139 if(rest.and.restart1file) then
141 & inquire(file=mremd_rst_name,exist=file_exist)
142 cd write (*,*) me," Before broadcast: file_exist",file_exist
143 call MPI_Bcast(file_exist,1,MPI_LOGICAL,king,CG_COMM,
145 cd write (*,*) me," After broadcast: file_exist",file_exist
147 if(me.eq.king.or..not.out1file)
148 & write (iout,*) 'Master is reading restart1file'
149 call read1restart(i_index)
151 if(me.eq.king.or..not.out1file)
152 & write (iout,*) 'WARNING : no restart1file'
155 if(me.eq.king.or..not.out1file) then
156 write(iout,*) "i2set",(i2set(i),i=0,nodes-1)
157 write(iout,*) "i_index"
162 write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
171 if (rest.and..not.restart1file)
172 & inquire(file=mremd_rst_name,exist=file_exist)
173 if(.not.file_exist.and.rest.and..not.restart1file)
174 & write(iout,*) 'WARNING : no restart file',mremd_rst_name
175 IF (rest.and.file_exist.and..not.restart1file) THEN
176 write (iout,*) 'Master is reading restart file',
178 open(irest2,file=mremd_rst_name,status='unknown')
180 read (irest2,*) (i2rep(i),i=0,nodes-1)
182 read (irest2,*) (ifirst(i),i=1,remd_m(1))
185 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
187 read (irest2,*) ndowna(0,il),
188 & (ndowna(i,il),i=1,ndowna(0,il))
190 if(usampl.or.hremd.gt.0) then
194 read (irest2,*) (mset(i),i=1,nset)
196 read (irest2,*) (i2set(i),i=0,nodes-1)
201 read(irest2,*) (i_index(i,j,il,il1),j=1,remd_m(i))
206 write(iout,*) "i2set",(i2set(i),i=0,nodes-1)
207 write(iout,*) "i_index"
212 write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
221 write (iout,'(a6,1000i5)') "i2rep",(i2rep(i),i=0,nodes-1)
222 write (iout,'(a6,1000i5)') "ifirst",
223 & (ifirst(i),i=1,remd_m(1))
225 write (iout,'(a6,i4,a1,100i4)') "nupa",il,":",
226 & (nupa(i,il),i=1,nupa(0,il))
227 write (iout,'(a6,i4,a1,100i4)') "ndowna",il,":",
228 & (ndowna(i,il),i=1,ndowna(0,il))
230 ELSE IF (.not.(rest.and.file_exist)) THEN
236 if (i2rep(il-1).eq.nrep) then
239 nupa(0,il)=remd_m(i2rep(il-1)+1)
240 k=rep2i(int(i2rep(il-1)))+1
246 if (i2rep(il-1).eq.1) then
249 ndowna(0,il)=remd_m(i2rep(il-1)-1)
250 k=rep2i(i2rep(il-1)-2)+1
258 write (iout,'(a6,100i4)') "ifirst",
259 & (ifirst(i),i=1,remd_m(1))
261 write (iout,'(a6,i4,a1,100i4)') "nupa",il,":",
262 & (nupa(i,il),i=1,nupa(0,il))
263 write (iout,'(a6,i4,a1,100i4)') "ndowna",il,":",
264 & (ndowna(i,il),i=1,ndowna(0,il))
270 c t_bath=retmin+(retmax-retmin)*me/(nodes-1)
271 if(.not.(rest.and.file_exist.and.restart1file)) then
272 if (me .eq. king) then
275 t_bath=retmin+(retmax-retmin)*exp(float(i2rep(me)-nrep))
277 cd print *,'ttt',me,remd_tlist,(remd_t(i),i=1,nrep)
278 if (remd_tlist) t_bath=remd_t(int(i2rep(me)))
281 if(usampl.or.hremd.gt.0) then
283 if (hremd.gt.0) call set_hweights(iset)
284 if(me.eq.king.or..not.out1file)
285 & write(iout,*) me,"iset=",iset,"t_bath=",t_bath
288 stdfp=dsqrt(2*Rb*t_bath/d_time)
290 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
293 c print *,'irep',me,t_bath
295 if (me.eq.king .or. .not. out1file)
296 & write (iout,'(a60,f10.5)') "REMD Temperature:",t_bath
297 call rescale_weights(t_bath)
301 c------copy MD--------------
302 c The driver for molecular dynamics subroutines
303 c------------------------------------------------
309 if(me.eq.king.or..not.out1file)
310 & write (iout,'(20(1h=),a20,20(1h=))') "MD calculation started"
316 c Determine the inverse of the inertia matrix.
317 call setup_MD_matrices
321 if (me.eq.king .or. .not. out1file)
322 & write (iout,'(a60,f10.5)') "REMD restart Temperature:",t_bath
323 stdfp=dsqrt(2*Rb*t_bath/d_time)
325 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
327 if (lang.gt.0 .and. .not.surfarea) then
329 stdforcp(i)=stdfp*dsqrt(gamp)
332 stdforcsc(i)=stdfsc(itype(i))*dsqrt(gamsc(itype(i)))
334 elseif (lang.gt.0 .and. surfarea ) then
337 call rescale_weights(t_bath)
341 t_MDsetup = MPI_Wtime()-tt0
343 t_MDsetup = tcpu()-tt0
346 c Entering the MD loop
352 if (lang.eq.2 .or. lang.eq.3) then
356 call sd_verlet_p_setup
358 call sd_verlet_ciccotti_setup
362 pfric0_mat(i,j,0)=pfric_mat(i,j)
363 afric0_mat(i,j,0)=afric_mat(i,j)
364 vfric0_mat(i,j,0)=vfric_mat(i,j)
365 prand0_mat(i,j,0)=prand_mat(i,j)
366 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
367 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
372 flag_stoch(i)=.false.
376 & "LANG=2 or 3 NOT SUPPORTED. Recompile without -DLANG0"
378 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
382 else if (lang.eq.1 .or. lang.eq.4) then
386 if (me.eq.king .or. .not. out1file)
387 & write(iout,*) 'Setup time',time00-walltime
388 ctime call flush(iout)
390 t_langsetup=MPI_Wtime()-tt0
393 t_langsetup=tcpu()-tt0
398 do while(.not.end_of_run)
400 if(itime.eq.n_timestep.and.me.eq.king) end_of_run=.true.
401 if(mremdsync.and.itime.eq.n_timestep) end_of_run=.true.
403 if (lang.gt.0 .and. surfarea .and.
404 & mod(itime,reset_fricmat).eq.0) then
405 if (lang.eq.2 .or. lang.eq.3) then
409 call sd_verlet_p_setup
411 call sd_verlet_ciccotti_setup
415 pfric0_mat(i,j,0)=pfric_mat(i,j)
416 afric0_mat(i,j,0)=afric_mat(i,j)
417 vfric0_mat(i,j,0)=vfric_mat(i,j)
418 prand0_mat(i,j,0)=prand_mat(i,j)
419 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
420 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
425 flag_stoch(i)=.false.
428 else if (lang.eq.1 .or. lang.eq.4) then
431 write (iout,'(a,i10)')
432 & "Friction matrix reset based on surface area, itime",itime
434 if (reset_vel .and. tbf .and. lang.eq.0
435 & .and. mod(itime,count_reset_vel).eq.0) then
437 if (me.eq.king .or. .not. out1file)
438 & write(iout,'(a,f20.2)')
439 & "Velocities reset to random values, time",totT
442 d_t_old(j,i)=d_t(j,i)
446 if (reset_moment .and. mod(itime,count_reset_moment).eq.0) then
450 d_t(j,0)=d_t(j,0)-vcm(j)
453 kinetic_T=2.0d0/(dimen3*Rb)*EK
454 scalfac=dsqrt(T_bath/kinetic_T)
455 cd write(iout,'(a,f20.2)') "Momenta zeroed out, time",totT
458 d_t_old(j,i)=scalfac*d_t(j,i)
464 c Time-reversible RESPA algorithm
465 c (Tuckerman et al., J. Chem. Phys., 97, 1990, 1992)
466 call RESPA_step(itime)
468 c Variable time step algorithm.
469 call velverlet_step(itime)
473 call brown_step(itime)
475 print *,"Brown dynamics not here!"
477 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
482 if(hmc.gt.0 .and. mod(itime,hmc).eq.0) then
487 if (mod(itime,ntwe).eq.0) call statout(itime)
489 if (mod(itime,ntwx).eq.0.and..not.traj1file) then
490 write (tytul,'("time",f8.2," temp",f8.1)') totT,t_bath
492 call pdbout(potE,tytul,ipdb)
497 if (mod(itime,ntwx).eq.0.and.traj1file) then
498 if(ntwx_cache.lt.max_cache_traj_use) then
499 ntwx_cache=ntwx_cache+1
501 if (max_cache_traj_use.ne.1)
502 & print *,itime,"processor ",me," over cache ",ntwx_cache
505 totT_cache(i)=totT_cache(i+1)
506 EK_cache(i)=EK_cache(i+1)
507 potE_cache(i)=potE_cache(i+1)
508 t_bath_cache(i)=t_bath_cache(i+1)
509 Uconst_cache(i)=Uconst_cache(i+1)
510 iset_cache(i)=iset_cache(i+1)
513 qfrag_cache(ii,i)=qfrag_cache(ii,i+1)
516 qpair_cache(ii,i)=qpair_cache(ii,i+1)
519 utheta_cache(ii,i)=utheta_cache(ii,i+1)
520 ugamma_cache(ii,i)=ugamma_cache(ii,i+1)
521 uscdiff_cache(ii,i)=uscdiff_cache(ii,i+1)
527 c_cache(j,ii,i)=c_cache(j,ii,i+1)
533 totT_cache(ntwx_cache)=totT
534 EK_cache(ntwx_cache)=EK
535 potE_cache(ntwx_cache)=potE
536 t_bath_cache(ntwx_cache)=t_bath
537 Uconst_cache(ntwx_cache)=Uconst
538 iset_cache(ntwx_cache)=iset
541 qfrag_cache(i,ntwx_cache)=qfrag(i)
544 qpair_cache(i,ntwx_cache)=qpair(i)
547 utheta_cache(i,ntwx_cache)=utheta(i)
548 ugamma_cache(i,ntwx_cache)=ugamma(i)
549 uscdiff_cache(i,ntwx_cache)=uscdiff(i)
554 c_cache(j,i,ntwx_cache)=c(j,i)
559 if ((rstcount.eq.1000.or.itime.eq.n_timestep)
560 & .and..not.restart1file) then
563 open(irest1,file=mremd_rst_name,status='unknown')
564 write (irest1,*) "i2rep"
565 write (irest1,*) (i2rep(i),i=0,nodes-1)
566 write (irest1,*) "ifirst"
567 write (irest1,*) (ifirst(i),i=1,remd_m(1))
569 write (irest1,*) "nupa",il
570 write (irest1,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
571 write (irest1,*) "ndowna",il
572 write (irest1,*) ndowna(0,il),
573 & (ndowna(i,il),i=1,ndowna(0,il))
575 if(usampl.or.hremd.gt.0) then
576 write (irest1,*) "nset"
577 write (irest1,*) nset
578 write (irest1,*) "mset"
579 write (irest1,*) (mset(i),i=1,nset)
580 write (irest1,*) "i2set"
581 write (irest1,*) (i2set(i),i=0,nodes-1)
582 write (irest1,*) "i_index"
586 write(irest1,*) (i_index(i,j,il,il1),j=1,remd_m(i))
594 open(irest2,file=rest2name,status='unknown')
595 write(irest2,*) totT,EK,potE,totE,t_bath
597 write (irest2,'(3e15.5)') (d_t(j,i),j=1,3)
600 write (irest2,'(3e15.5)') (dc(j,i),j=1,3)
602 if(usampl.or.hremd.gt.0) then
603 write (irest2,*) iset
610 c forced synchronization
611 if (mod(itime,i_sync_step).eq.0 .and. me.ne.king
612 & .and. .not. mremdsync) then
614 call mpi_iprobe(0,101,CG_COMM,synflag,status,ierr)
616 call mpi_recv(itime_master, 1, MPI_INTEGER,
617 & 0,101,CG_COMM, status, ierr)
618 call mpi_barrier(CG_COMM, ierr)
619 cdeb if (out1file.or.traj1file) then
620 cdeb call mpi_gather(itime,1,mpi_integer,
621 cdeb & icache_all,1,mpi_integer,king,
624 & call mpi_gather(ntwx_cache,1,mpi_integer,
625 & icache_all,1,mpi_integer,king,
628 & write(iout,*) 'REMD synchro at',itime_master,itime
629 if (itime_master.ge.n_timestep .or. ovrtim())
631 ctime call flush(iout)
636 if ((mod(itime,nstex).eq.0.and.me.eq.king
637 & .or.end_of_run.and.me.eq.king )
638 & .and. .not. mremdsync ) then
642 call mpi_isend(itime,1,MPI_INTEGER,i,101,
643 & CG_COMM, ireqi(i), ierr)
644 cd write(iout,*) 'REMD synchro with',i
647 call mpi_waitall(nodes-1,ireqi,statusi,ierr)
648 call mpi_barrier(CG_COMM, ierr)
650 write(iout,*) 'REMD synchro at',itime,'time=',time01-time01_
651 if (out1file.or.traj1file) then
652 cdeb call mpi_gather(itime,1,mpi_integer,
653 cdeb & itime_all,1,mpi_integer,king,
655 cdeb write(iout,'(a19,8000i8)') ' REMD synchro itime',
656 cdeb & (itime_all(i),i=1,nodes)
658 cdeb imin_itime=itime_all(1)
660 cdeb if(itime_all(i).lt.imin_itime) imin_itime=itime_all(i)
662 cdeb ii_write=(imin_itime-imin_itime_old)/ntwx
663 cdeb imin_itime_old=int(imin_itime/ntwx)*ntwx
664 cdeb write(iout,*) imin_itime,imin_itime_old,ii_write
665 call mpi_gather(ntwx_cache,1,mpi_integer,
666 & icache_all,1,mpi_integer,king,
668 c write(iout,'(a19,8000i8)') ' ntwx_cache',
669 c & (icache_all(i),i=1,nodes)
670 ii_write=icache_all(1)
672 if(icache_all(i).lt.ii_write) ii_write=icache_all(i)
674 c write(iout,*) "MIN ii_write=",ii_write
677 ctime call flush(iout)
679 if(mremdsync .and. mod(itime,nstex).eq.0) then
681 if (me.eq.king .or. .not. out1file)
682 & write(iout,*) 'REMD synchro at',itime
685 call mpi_gather(ntwx_cache,1,mpi_integer,
686 & icache_all,1,mpi_integer,king,
689 write(iout,'(a19,8000i8)') ' ntwx_cache',
690 & (icache_all(i),i=1,nodes)
691 ii_write=icache_all(1)
693 if(icache_all(i).lt.ii_write) ii_write=icache_all(i)
695 write(iout,*) "MIN ii_write=",ii_write
698 ctest call flush(iout)
701 c Update the time safety limiy
702 if (time001-time00.gt.safety) then
703 safety=time001-time00+600
704 if (me.eq.king .or. .not. out1file)
705 & write (iout,*) "****** SAFETY increased to",safety," s"
707 if (ovrtim()) end_of_run=.true.
709 if(synflag.and..not.end_of_run) then
713 c write(iout,*) 'REMD before',me,t_bath
715 c call mpi_gather(t_bath,1,mpi_double_precision,
716 c & remd_t_bath,1,mpi_double_precision,king,
718 potEcomp(n_ene+1)=t_bath
721 potEcomp(n_ene+2)=iset
722 if (iset.lt.nset) then
726 potEcomp(n_ene+3)=Uconst
733 potEcomp(n_ene+4)=Uconst
737 if(hremd.gt.0) potEcomp(n_ene+2)=iset
738 call mpi_gather(potEcomp(0),n_ene+5,mpi_double_precision,
739 & remd_ene(0,1),n_ene+5,mpi_double_precision,king,
742 call mpi_gather(elow,1,mpi_double_precision,
743 & elowi,1,mpi_double_precision,king,
745 call mpi_gather(ehigh,1,mpi_double_precision,
746 & ehighi,1,mpi_double_precision,king,
751 if (me.eq.king .or. .not. out1file) then
752 write(iout,*) 'REMD gather times=',time03-time01
756 if (restart1file) call write1rst(i_index)
759 if (me.eq.king .or. .not. out1file) then
760 write(iout,*) 'REMD writing rst time=',time04-time03
763 if (traj1file) call write1traj
765 cdeb call mpi_gather(ntwx_cache,1,mpi_integer,
766 cdeb & icache_all,1,mpi_integer,king,
768 cdeb write(iout,'(a19,8000i8)') ' ntwx_cache after traj1file',
769 cdeb & (icache_all(i),i=1,nodes)
774 if (me.eq.king .or. .not. out1file) then
775 write(iout,*) 'REMD writing traj time=',time05-time04
776 ctime call flush(iout)
782 remd_t_bath(i)=remd_ene(n_ene+1,i)
783 iremd_iset(i)=remd_ene(n_ene+2,i)
786 co write(iout,*) 'REMD exchange temp,ene,elow,ehigh'
788 write(iout,'(i4,4f12.5)') i,remd_t_bath(i),remd_ene(0,i),
792 write(iout,*) 'REMD exchange temp,ene'
794 write(iout,'(i4,2f12.5)') i,remd_t_bath(i),remd_ene(0,i)
795 write(iout,'(6f12.5)') (remd_ene(j,i),j=1,n_ene)
798 c-------------------------------------
799 IF(.not.usampl.and.hremd.eq.0) THEN
800 write (iout,*) "Enter exchnge, remd_m",remd_m(1),
802 ctime call flush(iout)
803 write (iout,*) "remd_m(1)",remd_m(1)
805 i=ifirst(iran_num(1,remd_m(1)))
807 ctime call flush(iout)
811 write (iout,*) "i",i," nupa(0,i)",int(nupa(0,i))
812 if(i.gt.0.and.nupa(0,i).gt.0) then
814 c if (i.eq.1 .and. int(nupa(0,i)).eq.1) then
816 c & "CHUJ ABSOLUTNY!!! No way to sample a distinct replica in MREMD"
818 c call MPI_Abort(MPI_COMM_WORLD,ERRCODE,ierr)
820 c do while (iex.eq.i)
821 c write (iout,*) "upper",nupa(int(nupa(0,i)),i)
822 iex=nupa(iran_num(1,int(nupa(0,i))),i)
824 c write (iout,*) "nupa(0,i)",nupa(0,i)," iex",iex
826 call muca_delta(remd_t_bath,remd_ene,i,iex,delta)
828 c Swap temperatures between conformations i and iex with recalculating the free energies
829 c following temperature changes.
830 ene_iex_iex=remd_ene(0,iex)
831 ene_i_i=remd_ene(0,i)
832 c write (iout,*) "i",i," ene_i_i",ene_i_i,
833 c & " iex",iex," ene_iex_iex",ene_iex_iex
834 c write (iout,*) "rescaling weights with temperature",
837 call rescale_weights(remd_t_bath(i))
839 c write (iout,*) "0,iex",remd_t_bath(i)
840 c call enerprint(remd_ene(0,iex))
842 call sum_energy(remd_ene(0,iex),.false.)
843 ene_iex_i=remd_ene(0,iex)
844 c write (iout,*) "ene_iex_i",remd_ene(0,iex)
846 c write (iout,*) "0,i",remd_t_bath(i)
847 c call enerprint(remd_ene(0,i))
849 call sum_energy(remd_ene(0,i),.false.)
850 c write (iout,*) "ene_i_i",remd_ene(0,i)
852 c write (iout,*) "rescaling weights with temperature",
854 if (abs(ene_i_i-remd_ene(0,i)).gt.ene_tol) then
855 write (iout,*) "ERROR: inconsistent energies:",i,
856 & ene_i_i,remd_ene(0,i)
858 call rescale_weights(remd_t_bath(iex))
860 c write (iout,*) "0,i",remd_t_bath(iex)
861 c call enerprint(remd_ene(0,i))
863 call sum_energy(remd_ene(0,i),.false.)
864 c write (iout,*) "ene_i_iex",remd_ene(0,i)
866 ene_i_iex=remd_ene(0,i)
868 c write (iout,*) "0,iex",remd_t_bath(iex)
869 c call enerprint(remd_ene(0,iex))
871 call sum_energy(remd_ene(0,iex),.false.)
872 if (abs(ene_iex_iex-remd_ene(0,iex)).gt.ene_tol) then
873 write (iout,*) "ERROR: inconsistent energies:",iex,
874 & ene_iex_iex,remd_ene(0,iex)
876 c write (iout,*) "ene_iex_iex",remd_ene(0,iex)
877 c write (iout,*) "i",i," iex",iex
878 c write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
879 c & " ene_i_iex",ene_i_iex,
880 c & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
882 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
883 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
885 c write(iout,*) 'delta',delta
886 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
887 c & (remd_ene(i)-remd_ene(iex))/Rb/
888 c & (remd_t_bath(i)*remd_t_bath(iex))
890 if (delta .gt. 50.0d0) then
896 else if (delta.lt.-50.0d0) then
905 iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
906 xxx=ran_number(0.0d0,1.0d0)
907 c write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
909 if (delta .gt. xxx) then
911 remd_t_bath(i)=remd_t_bath(iex)
913 remd_ene(0,i)=ene_i_iex
914 remd_ene(0,iex)=ene_iex_i
920 ehighi(i)=ehighi(iex)
927 nupa(k,i)=nupa(k,iex)
930 ndowna(k,i)=ndowna(k,iex)
934 if (ifirst(il).eq.i) ifirst(il)=iex
936 if (nupa(k,il).eq.i) then
938 elseif (nupa(k,il).eq.iex) then
943 if (ndowna(k,il).eq.i) then
945 elseif (ndowna(k,il).eq.iex) then
951 iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
953 i2rep(i-1)=i2rep(iex-1)
956 c write(iout,*) 'exchange',i,iex
957 c write (iout,'(a8,100i4)') "@ ifirst",
958 c & (ifirst(k),k=1,remd_m(1))
960 c write (iout,'(a8,i4,a1,100i4)') "@ nupa",il,":",
961 c & (nupa(k,il),k=1,nupa(0,il))
962 c write (iout,'(a8,i4,a1,100i4)') "@ ndowna",il,":",
963 c & (ndowna(k,il),k=1,ndowna(0,il))
968 remd_ene(0,iex)=ene_iex_iex
969 remd_ene(0,i)=ene_i_i
975 cd write (iout,*) "exchange completed"
979 cd write(iout,*) "########",ii
981 i_temp=iran_num(1,nrep)
982 i_mult=iran_num(1,remd_m(i_temp))
983 i_iset=iran_num(1,nset)
984 i_mset=iran_num(1,mset(i_iset))
985 i=i_index(i_temp,i_mult,i_iset,i_mset)
987 cd write(iout,*) "i=",i,i_temp,i_mult,i_iset,i_mset
989 if(t_exchange_only)then
994 cd write(iout,*) "i_dir=",i_dir
996 if(i_dir.eq.1 .and. remd_m(i_temp+1).gt.0 )then
999 i_mult1=iran_num(1,remd_m(i_temp1))
1001 i_mset1=iran_num(1,mset(i_iset1))
1002 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1004 elseif(i_dir.eq.2 .and. mset(i_iset+1).gt.0)then
1007 i_mult1=iran_num(1,remd_m(i_temp1))
1009 i_mset1=iran_num(1,mset(i_iset1))
1010 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1011 econstr_temp_i=remd_ene(20,i)
1012 econstr_temp_iex=remd_ene(20,iex)
1013 remd_ene(20,i)=remd_ene(n_ene+3,i)
1014 remd_ene(20,iex)=remd_ene(n_ene+4,iex)
1016 elseif(remd_m(i_temp+1).gt.0.and.mset(i_iset+1).gt.0)then
1019 i_mult1=iran_num(1,remd_m(i_temp1))
1021 i_mset1=iran_num(1,mset(i_iset1))
1022 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1023 econstr_temp_i=remd_ene(20,i)
1024 econstr_temp_iex=remd_ene(20,iex)
1025 remd_ene(20,i)=remd_ene(n_ene+3,i)
1026 remd_ene(20,iex)=remd_ene(n_ene+4,iex)
1032 cd write(iout,*) "iex=",iex,i_temp1,i_mult1,i_iset1,i_mset1
1033 ctime call flush(iout)
1035 c Swap temperatures between conformations i and iex with recalculating the free energies
1036 c following temperature changes.
1037 ene_iex_iex=remd_ene(0,iex)
1038 ene_i_i=remd_ene(0,i)
1039 co write (iout,*) "rescaling weights with temperature",
1041 call rescale_weights(remd_t_bath(i))
1043 call sum_energy(remd_ene(0,iex),.false.)
1044 ene_iex_i=remd_ene(0,iex)
1045 cd write (iout,*) "ene_iex_i",remd_ene(0,iex)
1046 c call sum_energy(remd_ene(0,i),.false.)
1047 cd write (iout,*) "ene_i_i",remd_ene(0,i)
1048 c write (iout,*) "rescaling weights with temperature",
1049 c & remd_t_bath(iex)
1050 c if (real(ene_i_i).ne.real(remd_ene(0,i))) then
1051 c write (iout,*) "ERROR: inconsistent energies:",i,
1052 c & ene_i_i,remd_ene(0,i)
1054 call rescale_weights(remd_t_bath(iex))
1055 call sum_energy(remd_ene(0,i),.false.)
1056 cd write (iout,*) "ene_i_iex",remd_ene(0,i)
1057 ene_i_iex=remd_ene(0,i)
1058 c call sum_energy(remd_ene(0,iex),.false.)
1059 c if (real(ene_iex_iex).ne.real(remd_ene(0,iex))) then
1060 c write (iout,*) "ERROR: inconsistent energies:",iex,
1061 c & ene_iex_iex,remd_ene(0,iex)
1063 cd write (iout,*) "ene_iex_iex",remd_ene(0,iex)
1064 c write (iout,*) "i",i," iex",iex
1065 cd write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
1066 cd & " ene_i_iex",ene_i_iex,
1067 cd & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
1068 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
1069 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
1071 cd write(iout,*) 'delta',delta
1072 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
1073 c & (remd_ene(i)-remd_ene(iex))/Rb/
1074 c & (remd_t_bath(i)*remd_t_bath(iex))
1075 if (delta .gt. 50.0d0) then
1080 if (i_dir.eq.1.or.i_dir.eq.3)
1081 & iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
1082 if (i_dir.eq.2.or.i_dir.eq.3)
1083 & iremd_tot_usa(int(i2set(i-1)))=
1084 & iremd_tot_usa(int(i2set(i-1)))+1
1085 xxx=ran_number(0.0d0,1.0d0)
1086 cd write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
1087 if (delta .gt. xxx) then
1089 remd_t_bath(i)=remd_t_bath(iex)
1090 remd_t_bath(iex)=tmp
1093 iremd_iset(i)=iremd_iset(iex)
1094 iremd_iset(iex)=itmp
1096 remd_ene(0,i)=ene_i_iex
1097 remd_ene(0,iex)=ene_iex_i
1099 if (i_dir.eq.1.or.i_dir.eq.3)
1100 & iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
1103 i2rep(i-1)=i2rep(iex-1)
1106 if (i_dir.eq.2.or.i_dir.eq.3)
1107 & iremd_acc_usa(int(i2set(i-1)))=
1108 & iremd_acc_usa(int(i2set(i-1)))+1
1111 i2set(i-1)=i2set(iex-1)
1114 itmp=i_index(i_temp,i_mult,i_iset,i_mset)
1115 i_index(i_temp,i_mult,i_iset,i_mset)=
1116 & i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1117 i_index(i_temp1,i_mult1,i_iset1,i_mset1)=itmp
1120 remd_ene(0,iex)=ene_iex_iex
1121 remd_ene(0,i)=ene_i_i
1122 remd_ene(20,iex)=econstr_temp_iex
1123 remd_ene(20,i)=econstr_temp_i
1127 cd do il1=1,mset(il)
1130 cd write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
1140 ELSEIF (hremd.gt.0) THEN
1142 cd write(iout,*) "########",ii
1144 i_temp=iran_num(1,nrep)
1145 i_mult=iran_num(1,remd_m(i_temp))
1146 i_iset=iran_num(1,nset)
1148 i=i_index(i_temp,i_mult,i_iset,i_mset)
1150 cd write(iout,*) "i=",i,i_temp,i_mult,i_iset,i_mset
1152 if(t_exchange_only)then
1158 cd write(iout,*) "i_dir=",i_dir
1160 if(i_dir.eq.1 .and. remd_m(i_temp+1).gt.0 )then
1163 i_mult1=iran_num(1,remd_m(i_temp1))
1166 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1168 elseif(i_dir.eq.2)then
1171 i_mult1=iran_num(1,remd_m(i_temp1))
1172 i_iset1=iran_num(1,hremd)
1173 do while(i_iset1.eq.i_iset)
1174 i_iset1=iran_num(1,hremd)
1177 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1179 elseif(remd_m(i_temp+1).gt.0)then
1182 i_mult1=iran_num(1,remd_m(i_temp1))
1183 i_iset1=iran_num(1,hremd)
1184 do while(i_iset1.eq.i_iset)
1185 i_iset1=iran_num(1,hremd)
1188 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1194 cd write(iout,*) "iex=",iex,i_temp1,i_mult1,i_iset1,i_mset1
1195 ctime call flush(iout)
1197 c Swap temperatures between conformations i and iex with recalculating the free energies
1198 c following temperature changes.
1199 ene_iex_iex=remd_ene(0,iex)
1200 ene_i_i=remd_ene(0,i)
1202 call set_hweights(i_iset)
1203 call rescale_weights(remd_t_bath(i))
1204 call sum_energy(remd_ene(0,iex),.false.)
1205 ene_iex_i=remd_ene(0,iex)
1207 call set_hweights(i_iset1)
1208 call rescale_weights(remd_t_bath(iex))
1209 call sum_energy(remd_ene(0,i),.false.)
1210 ene_i_iex=remd_ene(0,i)
1212 cd write(iout,*) ene_iex_iex,ene_i_i,ene_iex_i,ene_i_iex
1214 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
1215 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
1218 if (delta .gt. 50.0d0) then
1224 if (i_dir.eq.1.or.i_dir.eq.3)
1225 & iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
1226 if (i_dir.eq.2.or.i_dir.eq.3)
1227 & iremd_tot_usa(int(i2set(i-1)))=
1228 & iremd_tot_usa(int(i2set(i-1)))+1
1229 xxx=ran_number(0.0d0,1.0d0)
1230 cd write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
1231 if (delta .gt. xxx) then
1233 cd write (iout,*) "exchange"
1235 remd_t_bath(i)=remd_t_bath(iex)
1236 remd_t_bath(iex)=tmp
1239 iremd_iset(i)=iremd_iset(iex)
1240 iremd_iset(iex)=itmp
1242 remd_ene(0,i)=ene_i_iex
1243 remd_ene(0,iex)=ene_iex_i
1245 if (i_dir.eq.1.or.i_dir.eq.3)
1246 & iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
1249 i2rep(i-1)=i2rep(iex-1)
1252 if (i_dir.eq.2.or.i_dir.eq.3)
1253 & iremd_acc_usa(int(i2set(i-1)))=
1254 & iremd_acc_usa(int(i2set(i-1)))+1
1257 i2set(i-1)=i2set(iex-1)
1260 itmp=i_index(i_temp,i_mult,i_iset,i_mset)
1261 i_index(i_temp,i_mult,i_iset,i_mset)=
1262 & i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1263 i_index(i_temp1,i_mult1,i_iset1,i_mset1)=itmp
1266 cd do il1=1,mset(il)
1269 cd write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
1276 remd_ene(0,iex)=ene_iex_iex
1277 remd_ene(0,i)=ene_i_i
1288 c-------------------------------------
1289 write (iout,*) "NREP",nrep
1291 if(iremd_tot(i).ne.0)
1292 & write(iout,'(a3,i4,2f12.5,i5)') 'ACC',i,remd_t(i)
1293 & ,iremd_acc(i)/(1.0*iremd_tot(i)),iremd_tot(i)
1298 if(iremd_tot_usa(i).ne.0)
1299 & write(iout,'(a10,i4,f12.5,i8)') 'ACC_usampl',i,
1300 & iremd_acc_usa(i)/(1.0*iremd_tot_usa(i)),iremd_tot_usa(i)
1306 if(iremd_tot_usa(i).ne.0)
1307 & write(iout,'(a10,i4,f12.5,i8)') 'ACC_hremd',i,
1308 & iremd_acc_usa(i)/(1.0*iremd_tot_usa(i)),iremd_tot_usa(i)
1313 ctime call flush(iout)
1315 cd write (iout,'(a6,100i4)') "ifirst",
1316 cd & (ifirst(i),i=1,remd_m(1))
1318 cd write (iout,'(a5,i4,a1,100i4)') "nup",il,":",
1319 cd & (nupa(i,il),i=1,nupa(0,il))
1320 cd write (iout,'(a5,i4,a1,100i4)') "ndown",il,":",
1321 cd & (ndowna(i,il),i=1,ndowna(0,il))
1326 cd write (iout,*) "Before scatter"
1328 call mpi_scatter(remd_t_bath,1,mpi_double_precision,
1329 & t_bath,1,mpi_double_precision,king,
1331 cd write (iout,*) "After scatter"
1333 if(usampl.or.hremd.gt.0)
1334 & call mpi_scatter(iremd_iset,1,mpi_integer,
1335 & iset,1,mpi_integer,king,
1339 if (me.eq.king .or. .not. out1file) then
1340 write(iout,*) 'REMD scatter time=',time07-time06
1344 call mpi_scatter(elowi,1,mpi_double_precision,
1345 & elow,1,mpi_double_precision,king,
1347 call mpi_scatter(ehighi,1,mpi_double_precision,
1348 & ehigh,1,mpi_double_precision,king,
1352 if(hremd.gt.0) call set_hweights(iset)
1353 call rescale_weights(t_bath)
1354 co write (iout,*) "Processor",me,
1355 co & " rescaling weights with temperature",t_bath
1357 stdfp=dsqrt(2*Rb*t_bath/d_time)
1359 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
1363 stdforcp(i)=stdforcp(i)*sqrt(t_bath/t_bath_old)
1366 stdforcsc(i)=stdforcsc(i)*sqrt(t_bath/t_bath_old)
1369 cde write(iout,*) 'REMD after',me,t_bath
1371 if (me.eq.king .or. .not. out1file) then
1372 write(iout,*) 'REMD exchange time=',time08-time02
1373 ctime call flush(iout)
1378 if (restart1file) then
1379 if (me.eq.king .or. .not. out1file)
1380 & write(iout,*) 'writing restart at the end of run'
1381 call write1rst(i_index)
1384 if (traj1file) call write1traj
1386 cdeb call mpi_gather(ntwx_cache,1,mpi_integer,
1387 cdeb & icache_all,1,mpi_integer,king,
1388 cdeb & CG_COMM,ierr)
1389 cdeb write(iout,'(a40,8000i8)')
1390 cdeb & ' ntwx_cache after traj1file at the end',
1391 cdeb & (icache_all(i),i=1,nodes)
1396 t_MD=MPI_Wtime()-tt0
1400 if (me.eq.king .or. .not. out1file) then
1401 write (iout,'(//35(1h=),a10,35(1h=)/10(/a40,1pe15.5))')
1403 & 'MD calculations setup:',t_MDsetup,
1404 & 'Energy & gradient evaluation:',t_enegrad,
1405 & 'Stochastic MD setup:',t_langsetup,
1406 & 'Stochastic MD step setup:',t_sdsetup,
1408 write (iout,'(/28(1h=),a25,27(1h=))')
1409 & ' End of MD calculation '
1410 if(hmc.gt.0) write (iout,*) 'HMC acceptance ratio',
1411 & n_timestep*1.0d0/hmc/hmc_acc
1416 c-----------------------------------------------------------------------
1417 subroutine write1rst(i_index)
1418 implicit real*8 (a-h,o-z)
1419 include 'DIMENSIONS'
1422 include 'COMMON.IOUNITS'
1423 include 'COMMON.REMD'
1424 include 'COMMON.SETUP'
1425 include 'COMMON.CHAIN'
1426 include 'COMMON.SBRIDGE'
1427 include 'COMMON.INTERACT'
1429 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1430 & d_restart2(3,2*maxres*maxprocs)
1434 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
1435 common /przechowalnia/ d_restart1,d_restart2
1440 t5_restart1(4)=t_bath
1441 t5_restart1(5)=Uconst
1443 call mpi_gather(t5_restart1,5,mpi_real,
1444 & t_restart1,5,mpi_real,king,CG_COMM,ierr)
1452 call mpi_gather(r_d,3*2*nres,mpi_real,
1453 & d_restart1,3*2*nres,mpi_real,king,
1462 call mpi_gather(r_d,3*2*nres,mpi_real,
1463 & d_restart2,3*2*nres,mpi_real,king,
1468 call xdrfopen_(ixdrf,mremd_rst_name, "w", iret)
1470 call xdrfint_(ixdrf, i2rep(i), iret)
1473 call xdrfint_(ixdrf, ifirst(i), iret)
1477 call xdrfint_(ixdrf, nupa(i,il), iret)
1481 call xdrfint_(ixdrf, ndowna(i,il), iret)
1487 call xdrffloat_(ixdrf, t_restart1(j,il), iret)
1494 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1501 call xdrffloat_(ixdrf, d_restart2(j,i+2*nres*il), iret)
1507 call xdrfint_(ixdrf, nset, iret)
1509 call xdrfint_(ixdrf,mset(i), iret)
1512 call xdrfint_(ixdrf,i2set(i), iret)
1518 itmp=i_index(i,j,il,il1)
1519 call xdrfint_(ixdrf,itmp, iret)
1526 call xdrfclose_(ixdrf, iret)
1528 call xdrfopen(ixdrf,mremd_rst_name, "w", iret)
1530 call xdrfint(ixdrf, i2rep(i), iret)
1533 call xdrfint(ixdrf, ifirst(i), iret)
1537 call xdrfint(ixdrf, nupa(i,il), iret)
1541 call xdrfint(ixdrf, ndowna(i,il), iret)
1547 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1554 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1561 call xdrffloat(ixdrf, d_restart2(j,i+2*nres*il), iret)
1568 call xdrfint(ixdrf, nset, iret)
1570 call xdrfint(ixdrf,mset(i), iret)
1573 call xdrfint(ixdrf,i2set(i), iret)
1579 itmp=i_index(i,j,il,il1)
1580 call xdrfint(ixdrf,itmp, iret)
1587 call xdrfclose(ixdrf, iret)
1594 subroutine write1traj
1595 implicit real*8 (a-h,o-z)
1596 include 'DIMENSIONS'
1599 include 'COMMON.IOUNITS'
1600 include 'COMMON.REMD'
1601 include 'COMMON.SETUP'
1602 include 'COMMON.CHAIN'
1603 include 'COMMON.SBRIDGE'
1604 include 'COMMON.INTERACT'
1608 real xcoord(3,maxres2+2),prec
1609 real r_qfrag(50),r_qpair(100)
1610 real r_utheta(50),r_ugamma(100),r_uscdiff(100)
1611 real p_qfrag(50*maxprocs),p_qpair(100*maxprocs)
1612 real p_utheta(50*maxprocs),p_ugamma(100*maxprocs),
1613 & p_uscdiff(100*maxprocs)
1614 real p_c(3,(maxres2+2)*maxprocs),r_c(3,maxres2+2)
1615 common /przechowalnia/ p_c
1617 call mpi_bcast(ii_write,1,mpi_integer,
1618 & king,CG_COMM,ierr)
1621 print *,'traj1file',me,ii_write,ntwx_cache
1625 if(me.eq.king) call xdrfopen_(ixdrf,cartname, "a", iret)
1627 if(me.eq.king) call xdrfopen(ixdrf,cartname, "a", iret)
1630 t5_restart1(1)=totT_cache(ii)
1631 t5_restart1(2)=EK_cache(ii)
1632 t5_restart1(3)=potE_cache(ii)
1633 t5_restart1(4)=t_bath_cache(ii)
1634 t5_restart1(5)=Uconst_cache(ii)
1635 call mpi_gather(t5_restart1,5,mpi_real,
1636 & t_restart1,5,mpi_real,king,CG_COMM,ierr)
1638 call mpi_gather(iset_cache(ii),1,mpi_integer,
1639 & iset_restart1,1,mpi_integer,king,CG_COMM,ierr)
1642 r_qfrag(i)=qfrag_cache(i,ii)
1645 r_qpair(i)=qpair_cache(i,ii)
1648 r_utheta(i)=utheta_cache(i,ii)
1649 r_ugamma(i)=ugamma_cache(i,ii)
1650 r_uscdiff(i)=uscdiff_cache(i,ii)
1653 call mpi_gather(r_qfrag,nfrag,mpi_real,
1654 & p_qfrag,nfrag,mpi_real,king,
1656 call mpi_gather(r_qpair,npair,mpi_real,
1657 & p_qpair,npair,mpi_real,king,
1659 call mpi_gather(r_utheta,nfrag_back,mpi_real,
1660 & p_utheta,nfrag_back,mpi_real,king,
1662 call mpi_gather(r_ugamma,nfrag_back,mpi_real,
1663 & p_ugamma,nfrag_back,mpi_real,king,
1665 call mpi_gather(r_uscdiff,nfrag_back,mpi_real,
1666 & p_uscdiff,nfrag_back,mpi_real,king,
1670 write (iout,*) "p_qfrag"
1672 write (iout,*) i,(p_qfrag((i-1)*nfrag+j),j=1,nfrag)
1674 write (iout,*) "p_qpair"
1676 write (iout,*) i,(p_qpair((i-1)*npair+j),j=1,npair)
1678 ctime call flush(iout)
1682 r_c(j,i)=c_cache(j,i,ii)
1686 call mpi_gather(r_c,3*2*nres,mpi_real,
1687 & p_c,3*2*nres,mpi_real,king,
1693 call xdrffloat_(ixdrf, real(t_restart1(1,il)), iret)
1694 call xdrffloat_(ixdrf, real(t_restart1(3,il)), iret)
1695 call xdrffloat_(ixdrf, real(t_restart1(5,il)), iret)
1696 call xdrffloat_(ixdrf, real(t_restart1(4,il)), iret)
1697 call xdrfint_(ixdrf, nss, iret)
1699 call xdrfint_(ixdrf, ihpb(j), iret)
1700 call xdrfint_(ixdrf, jhpb(j), iret)
1702 call xdrfint_(ixdrf, nfrag+npair+3*nfrag_back, iret)
1703 call xdrfint_(ixdrf, iset_restart1(il), iret)
1705 call xdrffloat_(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
1708 call xdrffloat_(ixdrf, p_qpair(i+(il-1)*npair), iret)
1711 call xdrffloat_(ixdrf, p_utheta(i+(il-1)*nfrag_back), iret)
1712 call xdrffloat_(ixdrf, p_ugamma(i+(il-1)*nfrag_back), iret)
1713 call xdrffloat_(ixdrf, p_uscdiff(i+(il-1)*nfrag_back), iret)
1718 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
1723 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
1727 call xdrf3dfcoord_(ixdrf, xcoord, itmp, prec, iret)
1731 call xdrffloat(ixdrf, real(t_restart1(1,il)), iret)
1732 call xdrffloat(ixdrf, real(t_restart1(3,il)), iret)
1733 call xdrffloat(ixdrf, real(t_restart1(5,il)), iret)
1734 call xdrffloat(ixdrf, real(t_restart1(4,il)), iret)
1735 call xdrfint(ixdrf, nss, iret)
1737 call xdrfint(ixdrf, ihpb(j), iret)
1738 call xdrfint(ixdrf, jhpb(j), iret)
1740 call xdrfint(ixdrf, nfrag+npair+3*nfrag_back, iret)
1741 call xdrfint(ixdrf, iset_restart1(il), iret)
1743 call xdrffloat(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
1746 call xdrffloat(ixdrf, p_qpair(i+(il-1)*npair), iret)
1749 call xdrffloat(ixdrf, p_utheta(i+(il-1)*nfrag_back), iret)
1750 call xdrffloat(ixdrf, p_ugamma(i+(il-1)*nfrag_back), iret)
1751 call xdrffloat(ixdrf, p_uscdiff(i+(il-1)*nfrag_back), iret)
1756 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
1761 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
1765 call xdrf3dfcoord(ixdrf, xcoord, itmp, prec, iret)
1771 if(me.eq.king) call xdrfclose_(ixdrf, iret)
1773 if(me.eq.king) call xdrfclose(ixdrf, iret)
1775 do i=1,ntwx_cache-ii_write
1777 totT_cache(i)=totT_cache(ii_write+i)
1778 EK_cache(i)=EK_cache(ii_write+i)
1779 potE_cache(i)=potE_cache(ii_write+i)
1780 t_bath_cache(i)=t_bath_cache(ii_write+i)
1781 Uconst_cache(i)=Uconst_cache(ii_write+i)
1782 iset_cache(i)=iset_cache(ii_write+i)
1785 qfrag_cache(ii,i)=qfrag_cache(ii,ii_write+i)
1788 qpair_cache(ii,i)=qpair_cache(ii,ii_write+i)
1791 utheta_cache(ii,i)=utheta_cache(ii,ii_write+i)
1792 ugamma_cache(ii,i)=ugamma_cache(ii,ii_write+i)
1793 uscdiff_cache(ii,i)=uscdiff_cache(ii,ii_write+i)
1798 c_cache(j,ii,i)=c_cache(j,ii,ii_write+i)
1802 ntwx_cache=ntwx_cache-ii_write
1807 subroutine read1restart(i_index)
1808 implicit real*8 (a-h,o-z)
1809 include 'DIMENSIONS'
1812 include 'COMMON.IOUNITS'
1813 include 'COMMON.REMD'
1814 include 'COMMON.SETUP'
1815 include 'COMMON.CHAIN'
1816 include 'COMMON.SBRIDGE'
1817 include 'COMMON.INTERACT'
1818 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1821 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
1822 common /przechowalnia/ d_restart1
1823 write (*,*) "Processor",me," called read1restart"
1826 open(irest2,file=mremd_rst_name,status='unknown')
1827 read(irest2,*,err=334) i
1828 write(iout,*) "Reading old rst in ASCI format"
1830 call read1restart_old
1834 call xdrfopen_(ixdrf,mremd_rst_name, "r", iret)
1837 call xdrfint_(ixdrf, i2rep(i), iret)
1840 call xdrfint_(ixdrf, ifirst(i), iret)
1843 call xdrfint_(ixdrf, nupa(0,il), iret)
1845 call xdrfint_(ixdrf, nupa(i,il), iret)
1848 call xdrfint_(ixdrf, ndowna(0,il), iret)
1850 call xdrfint_(ixdrf, ndowna(i,il), iret)
1855 call xdrffloat_(ixdrf, t_restart1(j,il), iret)
1859 call xdrfopen(ixdrf,mremd_rst_name, "r", iret)
1862 call xdrfint(ixdrf, i2rep(i), iret)
1865 call xdrfint(ixdrf, ifirst(i), iret)
1868 call xdrfint(ixdrf, nupa(0,il), iret)
1870 call xdrfint(ixdrf, nupa(i,il), iret)
1873 call xdrfint(ixdrf, ndowna(0,il), iret)
1875 call xdrfint(ixdrf, ndowna(i,il), iret)
1880 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1885 call mpi_scatter(t_restart1,5,mpi_real,
1886 & t5_restart1,5,mpi_real,king,CG_COMM,ierr)
1890 t_bath=t5_restart1(4)
1895 c read(irest2,'(3e15.5)')
1896 c & (d_restart1(j,i+2*nres*il),j=1,3)
1899 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1901 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1907 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1908 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1918 c read(irest2,'(3e15.5)')
1919 c & (d_restart1(j,i+2*nres*il),j=1,3)
1922 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1924 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1930 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1931 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1942 call xdrfint_(ixdrf, nset, iret)
1944 call xdrfint_(ixdrf,mset(i), iret)
1947 call xdrfint_(ixdrf,i2set(i), iret)
1953 call xdrfint_(ixdrf,itmp, iret)
1954 i_index(i,j,il,il1)=itmp
1962 call xdrfint(ixdrf, nset, iret)
1964 call xdrfint(ixdrf,mset(i), iret)
1967 call xdrfint(ixdrf,i2set(i), iret)
1973 call xdrfint(ixdrf,itmp, iret)
1974 i_index(i,j,il,il1)=itmp
1981 call mpi_scatter(i2set,1,mpi_integer,
1982 & iset,1,mpi_integer,king,
1988 if(me.eq.king) close(irest2)
1992 subroutine read1restart_old
1993 implicit real*8 (a-h,o-z)
1994 include 'DIMENSIONS'
1997 include 'COMMON.IOUNITS'
1998 include 'COMMON.REMD'
1999 include 'COMMON.SETUP'
2000 include 'COMMON.CHAIN'
2001 include 'COMMON.SBRIDGE'
2002 include 'COMMON.INTERACT'
2003 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
2005 common /przechowalnia/ d_restart1
2007 open(irest2,file=mremd_rst_name,status='unknown')
2008 read (irest2,*) (i2rep(i),i=0,nodes-1)
2009 read (irest2,*) (ifirst(i),i=1,remd_m(1))
2011 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
2012 read (irest2,*) ndowna(0,il),
2013 & (ndowna(i,il),i=1,ndowna(0,il))
2016 read(irest2,*) (t_restart1(j,il),j=1,4)
2019 call mpi_scatter(t_restart1,5,mpi_real,
2020 & t5_restart1,5,mpi_real,king,CG_COMM,ierr)
2024 t_bath=t5_restart1(4)
2029 read(irest2,'(3e15.5)')
2030 & (d_restart1(j,i+2*nres*il),j=1,3)
2034 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
2035 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
2045 read(irest2,'(3e15.5)')
2046 & (d_restart1(j,i+2*nres*il),j=1,3)
2050 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
2051 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
2057 if(me.eq.king) close(irest2)
2060 c-------------------------------------------------------------------
2061 subroutine set_hweights(iiset)
2062 implicit real*8 (a-h,o-z)
2064 include 'DIMENSIONS'
2065 include 'COMMON.FFIELD'
2066 include 'COMMON.REMD'
2069 weights(i)=hweights(iiset,i)