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)
787 co write(iout,*) 'REMD exchange temp,ene,elow,ehigh'
789 write(iout,'(i4,4f12.5)') i,remd_t_bath(i),remd_ene(0,i),
793 write(iout,*) 'REMD exchange temp,ene'
795 write(iout,'(i4,2f12.5)') i,remd_t_bath(i),remd_ene(0,i)
796 write(iout,'(6f12.5)') (remd_ene(j,i),j=1,n_ene)
800 c-------------------------------------
801 IF(.not.usampl.and.hremd.eq.0) THEN
803 write (iout,*) "Enter exchnge, remd_m",remd_m(1),
805 ctime call flush(iout)
806 write (iout,*) "remd_m(1)",remd_m(1)
809 i=ifirst(iran_num(1,remd_m(1)))
813 ctime call flush(iout)
818 write (iout,*) "i",i," nupa(0,i)",int(nupa(0,i))
820 if(i.gt.0.and.nupa(0,i).gt.0) then
822 c if (i.eq.1 .and. int(nupa(0,i)).eq.1) then
824 c & "CHUJ ABSOLUTNY!!! No way to sample a distinct replica in MREMD"
826 c call MPI_Abort(MPI_COMM_WORLD,ERRCODE,ierr)
828 c do while (iex.eq.i)
829 c write (iout,*) "upper",nupa(int(nupa(0,i)),i)
830 iex=nupa(iran_num(1,int(nupa(0,i))),i)
832 c write (iout,*) "nupa(0,i)",nupa(0,i)," iex",iex
834 call muca_delta(remd_t_bath,remd_ene,i,iex,delta)
836 c Swap temperatures between conformations i and iex with recalculating the free energies
837 c following temperature changes.
838 ene_iex_iex=remd_ene(0,iex)
839 ene_i_i=remd_ene(0,i)
840 c write (iout,*) "i",i," ene_i_i",ene_i_i,
841 c & " iex",iex," ene_iex_iex",ene_iex_iex
842 c write (iout,*) "rescaling weights with temperature",
845 call rescale_weights(remd_t_bath(i))
847 c write (iout,*) "0,iex",remd_t_bath(i)
848 c call enerprint(remd_ene(0,iex))
850 call sum_energy(remd_ene(0,iex),.false.)
851 ene_iex_i=remd_ene(0,iex)
852 c write (iout,*) "ene_iex_i",remd_ene(0,iex)
854 c write (iout,*) "0,i",remd_t_bath(i)
855 c call enerprint(remd_ene(0,i))
857 call sum_energy(remd_ene(0,i),.false.)
858 c write (iout,*) "ene_i_i",remd_ene(0,i)
860 c write (iout,*) "rescaling weights with temperature",
862 if (abs(ene_i_i-remd_ene(0,i)).gt.ene_tol) then
863 write (iout,*) "ERROR: inconsistent energies:",i,
864 & ene_i_i,remd_ene(0,i)
866 call rescale_weights(remd_t_bath(iex))
868 c write (iout,*) "0,i",remd_t_bath(iex)
869 c call enerprint(remd_ene(0,i))
871 call sum_energy(remd_ene(0,i),.false.)
872 c write (iout,*) "ene_i_iex",remd_ene(0,i)
874 ene_i_iex=remd_ene(0,i)
876 c write (iout,*) "0,iex",remd_t_bath(iex)
877 c call enerprint(remd_ene(0,iex))
879 call sum_energy(remd_ene(0,iex),.false.)
880 if (abs(ene_iex_iex-remd_ene(0,iex)).gt.ene_tol) then
881 write (iout,*) "ERROR: inconsistent energies:",iex,
882 & ene_iex_iex,remd_ene(0,iex)
884 c write (iout,*) "ene_iex_iex",remd_ene(0,iex)
885 c write (iout,*) "i",i," iex",iex
886 c write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
887 c & " ene_i_iex",ene_i_iex,
888 c & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
890 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
891 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
893 c write(iout,*) 'delta',delta
894 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
895 c & (remd_ene(i)-remd_ene(iex))/Rb/
896 c & (remd_t_bath(i)*remd_t_bath(iex))
898 if (delta .gt. 50.0d0) then
904 else if (delta.lt.-50.0d0) then
913 iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
914 xxx=ran_number(0.0d0,1.0d0)
915 c write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
917 if (delta .gt. xxx) then
919 remd_t_bath(i)=remd_t_bath(iex)
921 remd_ene(0,i)=ene_i_iex
922 remd_ene(0,iex)=ene_iex_i
928 ehighi(i)=ehighi(iex)
935 nupa(k,i)=nupa(k,iex)
938 ndowna(k,i)=ndowna(k,iex)
942 if (ifirst(il).eq.i) ifirst(il)=iex
944 if (nupa(k,il).eq.i) then
946 elseif (nupa(k,il).eq.iex) then
951 if (ndowna(k,il).eq.i) then
953 elseif (ndowna(k,il).eq.iex) then
959 iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
961 i2rep(i-1)=i2rep(iex-1)
964 c write(iout,*) 'exchange',i,iex
965 c write (iout,'(a8,100i4)') "@ ifirst",
966 c & (ifirst(k),k=1,remd_m(1))
968 c write (iout,'(a8,i4,a1,100i4)') "@ nupa",il,":",
969 c & (nupa(k,il),k=1,nupa(0,il))
970 c write (iout,'(a8,i4,a1,100i4)') "@ ndowna",il,":",
971 c & (ndowna(k,il),k=1,ndowna(0,il))
976 remd_ene(0,iex)=ene_iex_iex
977 remd_ene(0,i)=ene_i_i
983 cd write (iout,*) "exchange completed"
987 cd write(iout,*) "########",ii
989 i_temp=iran_num(1,nrep)
990 i_mult=iran_num(1,remd_m(i_temp))
991 i_iset=iran_num(1,nset)
992 i_mset=iran_num(1,mset(i_iset))
993 i=i_index(i_temp,i_mult,i_iset,i_mset)
995 cd write(iout,*) "i=",i,i_temp,i_mult,i_iset,i_mset
997 if(t_exchange_only)then
1002 cd write(iout,*) "i_dir=",i_dir
1004 if(i_dir.eq.1 .and. remd_m(i_temp+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)
1012 elseif(i_dir.eq.2 .and. mset(i_iset+1).gt.0)then
1015 i_mult1=iran_num(1,remd_m(i_temp1))
1017 i_mset1=iran_num(1,mset(i_iset1))
1018 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1019 econstr_temp_i=remd_ene(20,i)
1020 econstr_temp_iex=remd_ene(20,iex)
1021 remd_ene(20,i)=remd_ene(n_ene+3,i)
1022 remd_ene(20,iex)=remd_ene(n_ene+4,iex)
1024 elseif(remd_m(i_temp+1).gt.0.and.mset(i_iset+1).gt.0)then
1027 i_mult1=iran_num(1,remd_m(i_temp1))
1029 i_mset1=iran_num(1,mset(i_iset1))
1030 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1031 econstr_temp_i=remd_ene(20,i)
1032 econstr_temp_iex=remd_ene(20,iex)
1033 remd_ene(20,i)=remd_ene(n_ene+3,i)
1034 remd_ene(20,iex)=remd_ene(n_ene+4,iex)
1040 cd write(iout,*) "iex=",iex,i_temp1,i_mult1,i_iset1,i_mset1
1041 ctime call flush(iout)
1043 c Swap temperatures between conformations i and iex with recalculating the free energies
1044 c following temperature changes.
1045 ene_iex_iex=remd_ene(0,iex)
1046 ene_i_i=remd_ene(0,i)
1047 co write (iout,*) "rescaling weights with temperature",
1049 call rescale_weights(remd_t_bath(i))
1051 call sum_energy(remd_ene(0,iex),.false.)
1052 ene_iex_i=remd_ene(0,iex)
1053 cd write (iout,*) "ene_iex_i",remd_ene(0,iex)
1054 c call sum_energy(remd_ene(0,i),.false.)
1055 cd write (iout,*) "ene_i_i",remd_ene(0,i)
1056 c write (iout,*) "rescaling weights with temperature",
1057 c & remd_t_bath(iex)
1058 c if (real(ene_i_i).ne.real(remd_ene(0,i))) then
1059 c write (iout,*) "ERROR: inconsistent energies:",i,
1060 c & ene_i_i,remd_ene(0,i)
1062 call rescale_weights(remd_t_bath(iex))
1063 call sum_energy(remd_ene(0,i),.false.)
1064 cd write (iout,*) "ene_i_iex",remd_ene(0,i)
1065 ene_i_iex=remd_ene(0,i)
1066 c call sum_energy(remd_ene(0,iex),.false.)
1067 c if (real(ene_iex_iex).ne.real(remd_ene(0,iex))) then
1068 c write (iout,*) "ERROR: inconsistent energies:",iex,
1069 c & ene_iex_iex,remd_ene(0,iex)
1071 cd write (iout,*) "ene_iex_iex",remd_ene(0,iex)
1072 c write (iout,*) "i",i," iex",iex
1073 cd write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
1074 cd & " ene_i_iex",ene_i_iex,
1075 cd & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
1076 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
1077 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
1079 cd write(iout,*) 'delta',delta
1080 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
1081 c & (remd_ene(i)-remd_ene(iex))/Rb/
1082 c & (remd_t_bath(i)*remd_t_bath(iex))
1083 if (delta .gt. 50.0d0) then
1088 if (i_dir.eq.1.or.i_dir.eq.3)
1089 & iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
1090 if (i_dir.eq.2.or.i_dir.eq.3)
1091 & iremd_tot_usa(int(i2set(i-1)))=
1092 & iremd_tot_usa(int(i2set(i-1)))+1
1093 xxx=ran_number(0.0d0,1.0d0)
1094 cd write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
1095 if (delta .gt. xxx) then
1097 remd_t_bath(i)=remd_t_bath(iex)
1098 remd_t_bath(iex)=tmp
1101 iremd_iset(i)=iremd_iset(iex)
1102 iremd_iset(iex)=itmp
1104 remd_ene(0,i)=ene_i_iex
1105 remd_ene(0,iex)=ene_iex_i
1107 if (i_dir.eq.1.or.i_dir.eq.3)
1108 & iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
1111 i2rep(i-1)=i2rep(iex-1)
1114 if (i_dir.eq.2.or.i_dir.eq.3)
1115 & iremd_acc_usa(int(i2set(i-1)))=
1116 & iremd_acc_usa(int(i2set(i-1)))+1
1119 i2set(i-1)=i2set(iex-1)
1122 itmp=i_index(i_temp,i_mult,i_iset,i_mset)
1123 i_index(i_temp,i_mult,i_iset,i_mset)=
1124 & i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1125 i_index(i_temp1,i_mult1,i_iset1,i_mset1)=itmp
1128 remd_ene(0,iex)=ene_iex_iex
1129 remd_ene(0,i)=ene_i_i
1130 remd_ene(20,iex)=econstr_temp_iex
1131 remd_ene(20,i)=econstr_temp_i
1135 cd do il1=1,mset(il)
1138 cd write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
1148 ELSEIF (hremd.gt.0) THEN
1150 cd write(iout,*) "########",ii
1152 i_temp=iran_num(1,nrep)
1153 i_mult=iran_num(1,remd_m(i_temp))
1154 i_iset=iran_num(1,nset)
1156 i=i_index(i_temp,i_mult,i_iset,i_mset)
1158 cd write(iout,*) "i=",i,i_temp,i_mult,i_iset,i_mset
1160 if(t_exchange_only)then
1166 cd write(iout,*) "i_dir=",i_dir
1168 if(i_dir.eq.1 .and. remd_m(i_temp+1).gt.0 )then
1171 i_mult1=iran_num(1,remd_m(i_temp1))
1174 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1176 elseif(i_dir.eq.2)then
1179 i_mult1=iran_num(1,remd_m(i_temp1))
1180 i_iset1=iran_num(1,hremd)
1181 do while(i_iset1.eq.i_iset)
1182 i_iset1=iran_num(1,hremd)
1185 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1187 elseif(remd_m(i_temp+1).gt.0)then
1190 i_mult1=iran_num(1,remd_m(i_temp1))
1191 i_iset1=iran_num(1,hremd)
1192 do while(i_iset1.eq.i_iset)
1193 i_iset1=iran_num(1,hremd)
1196 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1202 cd write(iout,*) "iex=",iex,i_temp1,i_mult1,i_iset1,i_mset1
1203 ctime call flush(iout)
1205 c Swap temperatures between conformations i and iex with recalculating the free energies
1206 c following temperature changes.
1207 ene_iex_iex=remd_ene(0,iex)
1208 ene_i_i=remd_ene(0,i)
1210 call set_hweights(i_iset)
1211 call rescale_weights(remd_t_bath(i))
1212 call sum_energy(remd_ene(0,iex),.false.)
1213 ene_iex_i=remd_ene(0,iex)
1215 call set_hweights(i_iset1)
1216 call rescale_weights(remd_t_bath(iex))
1217 call sum_energy(remd_ene(0,i),.false.)
1218 ene_i_iex=remd_ene(0,i)
1220 cd write(iout,*) ene_iex_iex,ene_i_i,ene_iex_i,ene_i_iex
1222 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
1223 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
1226 if (delta .gt. 50.0d0) then
1232 if (i_dir.eq.1.or.i_dir.eq.3)
1233 & iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
1234 if (i_dir.eq.2.or.i_dir.eq.3)
1235 & iremd_tot_usa(int(i2set(i-1)))=
1236 & iremd_tot_usa(int(i2set(i-1)))+1
1237 xxx=ran_number(0.0d0,1.0d0)
1238 cd write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
1239 if (delta .gt. xxx) then
1241 cd write (iout,*) "exchange"
1243 remd_t_bath(i)=remd_t_bath(iex)
1244 remd_t_bath(iex)=tmp
1247 iremd_iset(i)=iremd_iset(iex)
1248 iremd_iset(iex)=itmp
1250 remd_ene(0,i)=ene_i_iex
1251 remd_ene(0,iex)=ene_iex_i
1253 if (i_dir.eq.1.or.i_dir.eq.3)
1254 & iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
1257 i2rep(i-1)=i2rep(iex-1)
1260 if (i_dir.eq.2.or.i_dir.eq.3)
1261 & iremd_acc_usa(int(i2set(i-1)))=
1262 & iremd_acc_usa(int(i2set(i-1)))+1
1265 i2set(i-1)=i2set(iex-1)
1268 itmp=i_index(i_temp,i_mult,i_iset,i_mset)
1269 i_index(i_temp,i_mult,i_iset,i_mset)=
1270 & i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1271 i_index(i_temp1,i_mult1,i_iset1,i_mset1)=itmp
1274 cd do il1=1,mset(il)
1277 cd write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
1284 remd_ene(0,iex)=ene_iex_iex
1285 remd_ene(0,i)=ene_i_i
1296 c-------------------------------------
1297 write (iout,*) "NREP",nrep
1299 if(iremd_tot(i).ne.0)
1300 & write(iout,'(a3,i4,2f12.5,i5)') 'ACC',i,remd_t(i)
1301 & ,iremd_acc(i)/(1.0*iremd_tot(i)),iremd_tot(i)
1306 if(iremd_tot_usa(i).ne.0)
1307 & write(iout,'(a10,i4,f12.5,i8)') 'ACC_usampl',i,
1308 & iremd_acc_usa(i)/(1.0*iremd_tot_usa(i)),iremd_tot_usa(i)
1314 if(iremd_tot_usa(i).ne.0)
1315 & write(iout,'(a10,i4,f12.5,i8)') 'ACC_hremd',i,
1316 & iremd_acc_usa(i)/(1.0*iremd_tot_usa(i)),iremd_tot_usa(i)
1321 ctime call flush(iout)
1323 cd write (iout,'(a6,100i4)') "ifirst",
1324 cd & (ifirst(i),i=1,remd_m(1))
1326 cd write (iout,'(a5,i4,a1,100i4)') "nup",il,":",
1327 cd & (nupa(i,il),i=1,nupa(0,il))
1328 cd write (iout,'(a5,i4,a1,100i4)') "ndown",il,":",
1329 cd & (ndowna(i,il),i=1,ndowna(0,il))
1334 cd write (iout,*) "Before scatter"
1336 call mpi_scatter(remd_t_bath,1,mpi_double_precision,
1337 & t_bath,1,mpi_double_precision,king,
1339 cd write (iout,*) "After scatter"
1341 if(usampl.or.hremd.gt.0)
1342 & call mpi_scatter(iremd_iset,1,mpi_integer,
1343 & iset,1,mpi_integer,king,
1347 if (me.eq.king .or. .not. out1file) then
1348 write(iout,*) 'REMD scatter time=',time07-time06
1352 call mpi_scatter(elowi,1,mpi_double_precision,
1353 & elow,1,mpi_double_precision,king,
1355 call mpi_scatter(ehighi,1,mpi_double_precision,
1356 & ehigh,1,mpi_double_precision,king,
1360 if(hremd.gt.0) call set_hweights(iset)
1361 call rescale_weights(t_bath)
1362 co write (iout,*) "Processor",me,
1363 co & " rescaling weights with temperature",t_bath
1365 stdfp=dsqrt(2*Rb*t_bath/d_time)
1367 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
1371 stdforcp(i)=stdforcp(i)*sqrt(t_bath/t_bath_old)
1374 stdforcsc(i)=stdforcsc(i)*sqrt(t_bath/t_bath_old)
1377 cde write(iout,*) 'REMD after',me,t_bath
1379 if (me.eq.king .or. .not. out1file) then
1380 write(iout,*) 'REMD exchange time=',time08-time02
1381 ctime call flush(iout)
1386 if (restart1file) then
1387 if (me.eq.king .or. .not. out1file)
1388 & write(iout,*) 'writing restart at the end of run'
1389 call write1rst(i_index)
1392 if (traj1file) call write1traj
1394 cdeb call mpi_gather(ntwx_cache,1,mpi_integer,
1395 cdeb & icache_all,1,mpi_integer,king,
1396 cdeb & CG_COMM,ierr)
1397 cdeb write(iout,'(a40,8000i8)')
1398 cdeb & ' ntwx_cache after traj1file at the end',
1399 cdeb & (icache_all(i),i=1,nodes)
1404 t_MD=MPI_Wtime()-tt0
1408 if (me.eq.king .or. .not. out1file) then
1409 write (iout,'(//35(1h=),a10,35(1h=)/10(/a40,1pe15.5))')
1411 & 'MD calculations setup:',t_MDsetup,
1412 & 'Energy & gradient evaluation:',t_enegrad,
1413 & 'Stochastic MD setup:',t_langsetup,
1414 & 'Stochastic MD step setup:',t_sdsetup,
1416 write (iout,'(/28(1h=),a25,27(1h=))')
1417 & ' End of MD calculation '
1418 if(hmc.gt.0) write (iout,*) 'HMC acceptance ratio',
1419 & n_timestep*1.0d0/hmc/hmc_acc
1424 c-----------------------------------------------------------------------
1425 subroutine write1rst(i_index)
1426 implicit real*8 (a-h,o-z)
1427 include 'DIMENSIONS'
1430 include 'COMMON.IOUNITS'
1431 include 'COMMON.REMD'
1432 include 'COMMON.SETUP'
1433 include 'COMMON.CHAIN'
1434 include 'COMMON.SBRIDGE'
1435 include 'COMMON.INTERACT'
1437 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1438 & d_restart2(3,2*maxres*maxprocs)
1442 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
1443 common /przechowalnia/ d_restart1,d_restart2
1448 t5_restart1(4)=t_bath
1449 t5_restart1(5)=Uconst
1451 call mpi_gather(t5_restart1,5,mpi_real,
1452 & t_restart1,5,mpi_real,king,CG_COMM,ierr)
1460 call mpi_gather(r_d,3*2*nres,mpi_real,
1461 & d_restart1,3*2*nres,mpi_real,king,
1470 call mpi_gather(r_d,3*2*nres,mpi_real,
1471 & d_restart2,3*2*nres,mpi_real,king,
1476 call xdrfopen_(ixdrf,mremd_rst_name, "w", iret)
1478 call xdrfint_(ixdrf, i2rep(i), iret)
1481 call xdrfint_(ixdrf, ifirst(i), iret)
1485 call xdrfint_(ixdrf, nupa(i,il), iret)
1489 call xdrfint_(ixdrf, ndowna(i,il), iret)
1495 call xdrffloat_(ixdrf, t_restart1(j,il), iret)
1502 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1509 call xdrffloat_(ixdrf, d_restart2(j,i+2*nres*il), iret)
1515 call xdrfint_(ixdrf, nset, iret)
1517 call xdrfint_(ixdrf,mset(i), iret)
1520 call xdrfint_(ixdrf,i2set(i), iret)
1526 itmp=i_index(i,j,il,il1)
1527 call xdrfint_(ixdrf,itmp, iret)
1534 call xdrfclose_(ixdrf, iret)
1536 call xdrfopen(ixdrf,mremd_rst_name, "w", iret)
1538 call xdrfint(ixdrf, i2rep(i), iret)
1541 call xdrfint(ixdrf, ifirst(i), iret)
1545 call xdrfint(ixdrf, nupa(i,il), iret)
1549 call xdrfint(ixdrf, ndowna(i,il), iret)
1555 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1562 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1569 call xdrffloat(ixdrf, d_restart2(j,i+2*nres*il), iret)
1576 call xdrfint(ixdrf, nset, iret)
1578 call xdrfint(ixdrf,mset(i), iret)
1581 call xdrfint(ixdrf,i2set(i), iret)
1587 itmp=i_index(i,j,il,il1)
1588 call xdrfint(ixdrf,itmp, iret)
1595 call xdrfclose(ixdrf, iret)
1602 subroutine write1traj
1603 implicit real*8 (a-h,o-z)
1604 include 'DIMENSIONS'
1607 include 'COMMON.IOUNITS'
1608 include 'COMMON.REMD'
1609 include 'COMMON.SETUP'
1610 include 'COMMON.CHAIN'
1611 include 'COMMON.SBRIDGE'
1612 include 'COMMON.INTERACT'
1616 real xcoord(3,maxres2+2),prec
1617 real r_qfrag(50),r_qpair(100)
1618 real r_utheta(50),r_ugamma(100),r_uscdiff(100)
1619 real p_qfrag(50*maxprocs),p_qpair(100*maxprocs)
1620 real p_utheta(50*maxprocs),p_ugamma(100*maxprocs),
1621 & p_uscdiff(100*maxprocs)
1622 real p_c(3,(maxres2+2)*maxprocs),r_c(3,maxres2+2)
1623 common /przechowalnia/ p_c
1625 call mpi_bcast(ii_write,1,mpi_integer,
1626 & king,CG_COMM,ierr)
1629 print *,'traj1file',me,ii_write,ntwx_cache
1633 if(me.eq.king) call xdrfopen_(ixdrf,cartname, "a", iret)
1635 if(me.eq.king) call xdrfopen(ixdrf,cartname, "a", iret)
1638 t5_restart1(1)=totT_cache(ii)
1639 t5_restart1(2)=EK_cache(ii)
1640 t5_restart1(3)=potE_cache(ii)
1641 t5_restart1(4)=t_bath_cache(ii)
1642 t5_restart1(5)=Uconst_cache(ii)
1643 call mpi_gather(t5_restart1,5,mpi_real,
1644 & t_restart1,5,mpi_real,king,CG_COMM,ierr)
1646 call mpi_gather(iset_cache(ii),1,mpi_integer,
1647 & iset_restart1,1,mpi_integer,king,CG_COMM,ierr)
1650 r_qfrag(i)=qfrag_cache(i,ii)
1653 r_qpair(i)=qpair_cache(i,ii)
1656 r_utheta(i)=utheta_cache(i,ii)
1657 r_ugamma(i)=ugamma_cache(i,ii)
1658 r_uscdiff(i)=uscdiff_cache(i,ii)
1661 call mpi_gather(r_qfrag,nfrag,mpi_real,
1662 & p_qfrag,nfrag,mpi_real,king,
1664 call mpi_gather(r_qpair,npair,mpi_real,
1665 & p_qpair,npair,mpi_real,king,
1667 call mpi_gather(r_utheta,nfrag_back,mpi_real,
1668 & p_utheta,nfrag_back,mpi_real,king,
1670 call mpi_gather(r_ugamma,nfrag_back,mpi_real,
1671 & p_ugamma,nfrag_back,mpi_real,king,
1673 call mpi_gather(r_uscdiff,nfrag_back,mpi_real,
1674 & p_uscdiff,nfrag_back,mpi_real,king,
1678 write (iout,*) "p_qfrag"
1680 write (iout,*) i,(p_qfrag((i-1)*nfrag+j),j=1,nfrag)
1682 write (iout,*) "p_qpair"
1684 write (iout,*) i,(p_qpair((i-1)*npair+j),j=1,npair)
1686 ctime call flush(iout)
1690 r_c(j,i)=c_cache(j,i,ii)
1694 call mpi_gather(r_c,3*2*nres,mpi_real,
1695 & p_c,3*2*nres,mpi_real,king,
1701 call xdrffloat_(ixdrf, real(t_restart1(1,il)), iret)
1702 call xdrffloat_(ixdrf, real(t_restart1(3,il)), iret)
1703 call xdrffloat_(ixdrf, real(t_restart1(5,il)), iret)
1704 call xdrffloat_(ixdrf, real(t_restart1(4,il)), iret)
1705 call xdrfint_(ixdrf, nss, iret)
1707 call xdrfint_(ixdrf, ihpb(j), iret)
1708 call xdrfint_(ixdrf, jhpb(j), iret)
1710 call xdrfint_(ixdrf, nfrag+npair+3*nfrag_back, iret)
1711 call xdrfint_(ixdrf, iset_restart1(il), iret)
1713 call xdrffloat_(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
1716 call xdrffloat_(ixdrf, p_qpair(i+(il-1)*npair), iret)
1719 call xdrffloat_(ixdrf, p_utheta(i+(il-1)*nfrag_back), iret)
1720 call xdrffloat_(ixdrf, p_ugamma(i+(il-1)*nfrag_back), iret)
1721 call xdrffloat_(ixdrf, p_uscdiff(i+(il-1)*nfrag_back), iret)
1726 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
1731 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
1735 call xdrf3dfcoord_(ixdrf, xcoord, itmp, prec, iret)
1739 call xdrffloat(ixdrf, real(t_restart1(1,il)), iret)
1740 call xdrffloat(ixdrf, real(t_restart1(3,il)), iret)
1741 call xdrffloat(ixdrf, real(t_restart1(5,il)), iret)
1742 call xdrffloat(ixdrf, real(t_restart1(4,il)), iret)
1743 call xdrfint(ixdrf, nss, iret)
1745 call xdrfint(ixdrf, ihpb(j), iret)
1746 call xdrfint(ixdrf, jhpb(j), iret)
1748 call xdrfint(ixdrf, nfrag+npair+3*nfrag_back, iret)
1749 call xdrfint(ixdrf, iset_restart1(il), iret)
1751 call xdrffloat(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
1754 call xdrffloat(ixdrf, p_qpair(i+(il-1)*npair), iret)
1757 call xdrffloat(ixdrf, p_utheta(i+(il-1)*nfrag_back), iret)
1758 call xdrffloat(ixdrf, p_ugamma(i+(il-1)*nfrag_back), iret)
1759 call xdrffloat(ixdrf, p_uscdiff(i+(il-1)*nfrag_back), iret)
1764 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
1769 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
1773 call xdrf3dfcoord(ixdrf, xcoord, itmp, prec, iret)
1779 if(me.eq.king) call xdrfclose_(ixdrf, iret)
1781 if(me.eq.king) call xdrfclose(ixdrf, iret)
1783 do i=1,ntwx_cache-ii_write
1785 totT_cache(i)=totT_cache(ii_write+i)
1786 EK_cache(i)=EK_cache(ii_write+i)
1787 potE_cache(i)=potE_cache(ii_write+i)
1788 t_bath_cache(i)=t_bath_cache(ii_write+i)
1789 Uconst_cache(i)=Uconst_cache(ii_write+i)
1790 iset_cache(i)=iset_cache(ii_write+i)
1793 qfrag_cache(ii,i)=qfrag_cache(ii,ii_write+i)
1796 qpair_cache(ii,i)=qpair_cache(ii,ii_write+i)
1799 utheta_cache(ii,i)=utheta_cache(ii,ii_write+i)
1800 ugamma_cache(ii,i)=ugamma_cache(ii,ii_write+i)
1801 uscdiff_cache(ii,i)=uscdiff_cache(ii,ii_write+i)
1806 c_cache(j,ii,i)=c_cache(j,ii,ii_write+i)
1810 ntwx_cache=ntwx_cache-ii_write
1815 subroutine read1restart(i_index)
1816 implicit real*8 (a-h,o-z)
1817 include 'DIMENSIONS'
1820 include 'COMMON.IOUNITS'
1821 include 'COMMON.REMD'
1822 include 'COMMON.SETUP'
1823 include 'COMMON.CHAIN'
1824 include 'COMMON.SBRIDGE'
1825 include 'COMMON.INTERACT'
1826 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1829 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
1830 common /przechowalnia/ d_restart1
1831 write (*,*) "Processor",me," called read1restart"
1834 open(irest2,file=mremd_rst_name,status='unknown')
1835 read(irest2,*,err=334) i
1836 write(iout,*) "Reading old rst in ASCI format"
1838 call read1restart_old
1842 call xdrfopen_(ixdrf,mremd_rst_name, "r", iret)
1845 call xdrfint_(ixdrf, i2rep(i), iret)
1848 call xdrfint_(ixdrf, ifirst(i), iret)
1851 call xdrfint_(ixdrf, nupa(0,il), iret)
1853 call xdrfint_(ixdrf, nupa(i,il), iret)
1856 call xdrfint_(ixdrf, ndowna(0,il), iret)
1858 call xdrfint_(ixdrf, ndowna(i,il), iret)
1863 call xdrffloat_(ixdrf, t_restart1(j,il), iret)
1867 call xdrfopen(ixdrf,mremd_rst_name, "r", iret)
1870 call xdrfint(ixdrf, i2rep(i), iret)
1873 call xdrfint(ixdrf, ifirst(i), iret)
1876 call xdrfint(ixdrf, nupa(0,il), iret)
1878 call xdrfint(ixdrf, nupa(i,il), iret)
1881 call xdrfint(ixdrf, ndowna(0,il), iret)
1883 call xdrfint(ixdrf, ndowna(i,il), iret)
1888 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1893 call mpi_scatter(t_restart1,5,mpi_real,
1894 & t5_restart1,5,mpi_real,king,CG_COMM,ierr)
1898 t_bath=t5_restart1(4)
1903 c read(irest2,'(3e15.5)')
1904 c & (d_restart1(j,i+2*nres*il),j=1,3)
1907 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1909 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1915 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1916 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1926 c read(irest2,'(3e15.5)')
1927 c & (d_restart1(j,i+2*nres*il),j=1,3)
1930 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1932 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1938 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1939 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1950 call xdrfint_(ixdrf, nset, iret)
1952 call xdrfint_(ixdrf,mset(i), iret)
1955 call xdrfint_(ixdrf,i2set(i), iret)
1961 call xdrfint_(ixdrf,itmp, iret)
1962 i_index(i,j,il,il1)=itmp
1970 call xdrfint(ixdrf, nset, iret)
1972 call xdrfint(ixdrf,mset(i), iret)
1975 call xdrfint(ixdrf,i2set(i), iret)
1981 call xdrfint(ixdrf,itmp, iret)
1982 i_index(i,j,il,il1)=itmp
1989 call mpi_scatter(i2set,1,mpi_integer,
1990 & iset,1,mpi_integer,king,
1996 if(me.eq.king) close(irest2)
2000 subroutine read1restart_old
2001 implicit real*8 (a-h,o-z)
2002 include 'DIMENSIONS'
2005 include 'COMMON.IOUNITS'
2006 include 'COMMON.REMD'
2007 include 'COMMON.SETUP'
2008 include 'COMMON.CHAIN'
2009 include 'COMMON.SBRIDGE'
2010 include 'COMMON.INTERACT'
2011 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
2013 common /przechowalnia/ d_restart1
2015 open(irest2,file=mremd_rst_name,status='unknown')
2016 read (irest2,*) (i2rep(i),i=0,nodes-1)
2017 read (irest2,*) (ifirst(i),i=1,remd_m(1))
2019 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
2020 read (irest2,*) ndowna(0,il),
2021 & (ndowna(i,il),i=1,ndowna(0,il))
2024 read(irest2,*) (t_restart1(j,il),j=1,4)
2027 call mpi_scatter(t_restart1,5,mpi_real,
2028 & t5_restart1,5,mpi_real,king,CG_COMM,ierr)
2032 t_bath=t5_restart1(4)
2037 read(irest2,'(3e15.5)')
2038 & (d_restart1(j,i+2*nres*il),j=1,3)
2042 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
2043 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
2053 read(irest2,'(3e15.5)')
2054 & (d_restart1(j,i+2*nres*il),j=1,3)
2058 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
2059 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
2065 if(me.eq.king) close(irest2)
2068 c-------------------------------------------------------------------
2069 subroutine set_hweights(iiset)
2070 implicit real*8 (a-h,o-z)
2072 include 'DIMENSIONS'
2073 include 'COMMON.FFIELD'
2074 include 'COMMON.REMD'
2077 weights(i)=hweights(iiset,i)