2 implicit real*8 (a-h,o-z)
5 include 'COMMON.CONTROL'
9 include 'COMMON.LANGEVIN'
11 include 'COMMON.LANGEVIN.lang0'
13 include 'COMMON.CHAIN'
14 include 'COMMON.DERIV'
16 include 'COMMON.LOCAL'
17 include 'COMMON.INTERACT'
18 include 'COMMON.IOUNITS'
19 include 'COMMON.NAMES'
20 include 'COMMON.TIME1'
22 include 'COMMON.SETUP'
24 include 'COMMON.HAIRPIN'
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)
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
50 if(me.eq.king.or..not.out1file) then
51 write (iout,*) 'MREMD',nodes,'time before',time00-walltime
52 write (iout,*) "NREP=",nrep
56 if (ilen(tmpdir).gt.0 .and. (me.eq.king)) then
57 call copy_to_tmp(pref_orig(:ilen(pref_orig))//"_mremd.rst")
59 mremd_rst_name=prefix(:ilen(prefix))//"_mremd.rst"
61 cd print *,'MREMD',nodes
62 cd print *,'mmm',me,remd_mlist,(remd_m(i),i=1,nrep)
63 cde write (iout,*) "Start MREMD: me",me," t_bath",t_bath
67 do il1=1,max0(mset(il),1)
83 if(me.eq.king.or..not.out1file) then
84 write(iout,*) (i2rep(i),i=0,nodes-1)
85 write(iout,*) (i2set(i),i=0,nodes-1)
90 write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
97 c print *,'i2rep',me,i2rep(me)
98 c print *,'rep2i',(rep2i(i),i=0,nrep)
100 cold if (i2rep(me).eq.nrep) then
103 cold nup(0)=remd_m(i2rep(me)+1)
104 cold k=rep2i(int(i2rep(me)))+1
111 cd print '(i4,a4,100i4)',me,' nup',(nup(i),i=0,nup(0))
113 cold if (i2rep(me).eq.1) then
116 cold ndown(0)=remd_m(i2rep(me)-1)
117 cold k=rep2i(i2rep(me)-2)+1
124 cd print '(i4,a6,100i4)',me,' ndown',(ndown(i),i=0,ndown(0))
127 write (*,*) "Processor",me," rest",rest,"
128 & restart1fie",restart1file
129 if(rest.and.restart1file) then
131 & inquire(file=mremd_rst_name,exist=file_exist)
132 cd write (*,*) me," Before broadcast: file_exist",file_exist
133 call MPI_Bcast(file_exist,1,MPI_LOGICAL,king,CG_COMM,
135 cd write (*,*) me," After broadcast: file_exist",file_exist
137 if(me.eq.king.or..not.out1file)
138 & write (iout,*) 'Master is reading restart1file'
139 call read1restart(i_index)
141 if(me.eq.king.or..not.out1file)
142 & write (iout,*) 'WARNING : no restart1file'
145 if(me.eq.king.or..not.out1file) then
146 write(iout,*) "i2set",(i2set(i),i=0,nodes-1)
147 write(iout,*) "i_index"
152 write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
161 if (rest.and..not.restart1file)
162 & inquire(file=mremd_rst_name,exist=file_exist)
163 if(.not.file_exist.and.rest.and..not.restart1file)
164 & write(iout,*) 'WARNING : no restart file',mremd_rst_name
165 IF (rest.and.file_exist.and..not.restart1file) THEN
166 write (iout,*) 'Master is reading restart file',
168 open(irest2,file=mremd_rst_name,status='unknown')
170 read (irest2,*) (i2rep(i),i=0,nodes-1)
172 read (irest2,*) (ifirst(i),i=1,remd_m(1))
175 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
177 read (irest2,*) ndowna(0,il),
178 & (ndowna(i,il),i=1,ndowna(0,il))
184 read (irest2,*) (mset(i),i=1,nset)
186 read (irest2,*) (i2set(i),i=0,nodes-1)
191 read(irest2,*) (i_index(i,j,il,il1),j=1,remd_m(i))
196 write(iout,*) "i2set",(i2set(i),i=0,nodes-1)
197 write(iout,*) "i_index"
202 write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
211 write (iout,'(a6,1000i5)') "i2rep",(i2rep(i),i=0,nodes-1)
212 write (iout,'(a6,1000i5)') "ifirst",
213 & (ifirst(i),i=1,remd_m(1))
215 write (iout,'(a6,i4,a1,100i4)') "nupa",il,":",
216 & (nupa(i,il),i=1,nupa(0,il))
217 write (iout,'(a6,i4,a1,100i4)') "ndowna",il,":",
218 & (ndowna(i,il),i=1,ndowna(0,il))
220 ELSE IF (.not.(rest.and.file_exist)) THEN
226 if (i2rep(il-1).eq.nrep) then
229 nupa(0,il)=remd_m(i2rep(il-1)+1)
230 k=rep2i(int(i2rep(il-1)))+1
236 if (i2rep(il-1).eq.1) then
239 ndowna(0,il)=remd_m(i2rep(il-1)-1)
240 k=rep2i(i2rep(il-1)-2)+1
248 write (iout,'(a6,100i4)') "ifirst",
249 & (ifirst(i),i=1,remd_m(1))
251 write (iout,'(a6,i4,a1,100i4)') "nupa",il,":",
252 & (nupa(i,il),i=1,nupa(0,il))
253 write (iout,'(a6,i4,a1,100i4)') "ndowna",il,":",
254 & (ndowna(i,il),i=1,ndowna(0,il))
260 c t_bath=retmin+(retmax-retmin)*me/(nodes-1)
261 if(.not.(rest.and.file_exist.and.restart1file)) then
262 if (me .eq. king) then
265 t_bath=retmin+(retmax-retmin)*exp(float(i2rep(me)-nrep))
267 cd print *,'ttt',me,remd_tlist,(remd_t(i),i=1,nrep)
268 if (remd_tlist) t_bath=remd_t(int(i2rep(me)))
273 if(me.eq.king.or..not.out1file)
274 & write(iout,*) me,"iset=",iset,"t_bath=",t_bath
277 stdfp=dsqrt(2*Rb*t_bath/d_time)
279 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
282 c print *,'irep',me,t_bath
284 if (me.eq.king .or. .not. out1file)
285 & write (iout,'(a60,f10.5)') "REMD Temperature:",t_bath
286 call rescale_weights(t_bath)
290 c------copy MD--------------
291 c The driver for molecular dynamics subroutines
292 c------------------------------------------------
298 if(me.eq.king.or..not.out1file)
299 & write (iout,'(20(1h=),a20,20(1h=))') "MD calculation started"
305 c Determine the inverse of the inertia matrix.
306 call setup_MD_matrices
310 if (me.eq.king .or. .not. out1file)
311 & write (iout,'(a60,f10.5)') "REMD restart Temperature:",t_bath
312 stdfp=dsqrt(2*Rb*t_bath/d_time)
314 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
316 call rescale_weights(t_bath)
320 t_MDsetup = MPI_Wtime()-tt0
322 t_MDsetup = tcpu()-tt0
325 c Entering the MD loop
331 if (lang.eq.2 .or. lang.eq.3) then
335 call sd_verlet_p_setup
337 call sd_verlet_ciccotti_setup
341 pfric0_mat(i,j,0)=pfric_mat(i,j)
342 afric0_mat(i,j,0)=afric_mat(i,j)
343 vfric0_mat(i,j,0)=vfric_mat(i,j)
344 prand0_mat(i,j,0)=prand_mat(i,j)
345 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
346 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
351 flag_stoch(i)=.false.
355 & "LANG=2 or 3 NOT SUPPORTED. Recompile without -DLANG0"
357 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
361 else if (lang.eq.1 .or. lang.eq.4) then
365 if (me.eq.king .or. .not. out1file)
366 & write(iout,*) 'Setup time',time00-walltime
369 t_langsetup=MPI_Wtime()-tt0
372 t_langsetup=tcpu()-tt0
377 do while(.not.end_of_run)
379 if(itime.eq.n_timestep.and.me.eq.king) end_of_run=.true.
380 if(mremdsync.and.itime.eq.n_timestep) end_of_run=.true.
382 if (lang.gt.0 .and. surfarea .and.
383 & mod(itime,reset_fricmat).eq.0) then
384 if (lang.eq.2 .or. lang.eq.3) then
388 call sd_verlet_p_setup
390 call sd_verlet_ciccotti_setup
394 pfric0_mat(i,j,0)=pfric_mat(i,j)
395 afric0_mat(i,j,0)=afric_mat(i,j)
396 vfric0_mat(i,j,0)=vfric_mat(i,j)
397 prand0_mat(i,j,0)=prand_mat(i,j)
398 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
399 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
404 flag_stoch(i)=.false.
407 else if (lang.eq.1 .or. lang.eq.4) then
410 write (iout,'(a,i10)')
411 & "Friction matrix reset based on surface area, itime",itime
413 if (reset_vel .and. tbf .and. lang.eq.0
414 & .and. mod(itime,count_reset_vel).eq.0) then
416 if (me.eq.king .or. .not. out1file)
417 & write(iout,'(a,f20.2)')
418 & "Velocities reset to random values, time",totT
421 d_t_old(j,i)=d_t(j,i)
425 if (reset_moment .and. mod(itime,count_reset_moment).eq.0) then
429 d_t(j,0)=d_t(j,0)-vcm(j)
432 kinetic_T=2.0d0/(dimen3*Rb)*EK
433 scalfac=dsqrt(T_bath/kinetic_T)
434 cd write(iout,'(a,f20.2)') "Momenta zeroed out, time",totT
437 d_t_old(j,i)=scalfac*d_t(j,i)
443 c Time-reversible RESPA algorithm
444 c (Tuckerman et al., J. Chem. Phys., 97, 1990, 1992)
445 call RESPA_step(itime)
447 c Variable time step algorithm.
448 call velverlet_step(itime)
452 call brown_step(itime)
454 print *,"Brown dynamics not here!"
456 call MPI_Abort(MPI_COMM_WORLD,IERROR,ERRCODE)
462 if (mod(itime,ntwe).eq.0) call statout(itime)
464 if (mod(itime,ntwx).eq.0.and..not.traj1file) then
465 write (tytul,'("time",f8.2," temp",f8.1)') totT,t_bath
467 call hairpin(.true.,nharp,iharp)
468 call secondary2(.true.)
469 call pdbout(potE,tytul,ipdb)
474 if (mod(itime,ntwx).eq.0.and.traj1file) then
475 if(ntwx_cache.lt.max_cache_traj_use) then
476 ntwx_cache=ntwx_cache+1
478 if (max_cache_traj_use.ne.1)
479 & print *,itime,"processor ",me," over cache ",ntwx_cache
482 totT_cache(i)=totT_cache(i+1)
483 EK_cache(i)=EK_cache(i+1)
484 potE_cache(i)=potE_cache(i+1)
485 t_bath_cache(i)=t_bath_cache(i+1)
486 Uconst_cache(i)=Uconst_cache(i+1)
487 iset_cache(i)=iset_cache(i+1)
490 qfrag_cache(ii,i)=qfrag_cache(ii,i+1)
493 qpair_cache(ii,i)=qpair_cache(ii,i+1)
496 utheta_cache(ii,i)=utheta_cache(ii,i+1)
497 ugamma_cache(ii,i)=ugamma_cache(ii,i+1)
498 uscdiff_cache(ii,i)=uscdiff_cache(ii,i+1)
504 c_cache(j,ii,i)=c_cache(j,ii,i+1)
510 totT_cache(ntwx_cache)=totT
511 EK_cache(ntwx_cache)=EK
512 potE_cache(ntwx_cache)=potE
513 t_bath_cache(ntwx_cache)=t_bath
514 Uconst_cache(ntwx_cache)=Uconst
515 iset_cache(ntwx_cache)=iset
518 qfrag_cache(i,ntwx_cache)=qfrag(i)
521 qpair_cache(i,ntwx_cache)=qpair(i)
524 utheta_cache(i,ntwx_cache)=utheta(i)
525 ugamma_cache(i,ntwx_cache)=ugamma(i)
526 uscdiff_cache(i,ntwx_cache)=uscdiff(i)
531 c_cache(j,i,ntwx_cache)=c(j,i)
536 if ((rstcount.eq.1000.or.itime.eq.n_timestep)
537 & .and..not.restart1file) then
540 open(irest1,file=mremd_rst_name,status='unknown')
541 write (irest1,*) "i2rep"
542 write (irest1,*) (i2rep(i),i=0,nodes-1)
543 write (irest1,*) "ifirst"
544 write (irest1,*) (ifirst(i),i=1,remd_m(1))
546 write (irest1,*) "nupa",il
547 write (irest1,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
548 write (irest1,*) "ndowna",il
549 write (irest1,*) ndowna(0,il),
550 & (ndowna(i,il),i=1,ndowna(0,il))
553 write (irest1,*) "nset"
554 write (irest1,*) nset
555 write (irest1,*) "mset"
556 write (irest1,*) (mset(i),i=1,nset)
557 write (irest1,*) "i2set"
558 write (irest1,*) (i2set(i),i=0,nodes-1)
559 write (irest1,*) "i_index"
563 write(irest1,*) (i_index(i,j,il,il1),j=1,remd_m(i))
571 open(irest2,file=rest2name,status='unknown')
572 write(irest2,*) totT,EK,potE,totE,t_bath
574 write (irest2,'(3e15.5)') (d_t(j,i),j=1,3)
577 write (irest2,'(3e15.5)') (dc(j,i),j=1,3)
580 write (irest2,*) iset
587 c forced synchronization
588 if (mod(itime,i_sync_step).eq.0 .and. me.ne.king
589 & .and. .not. mremdsync) then
591 call mpi_iprobe(0,101,CG_COMM,synflag,status,ierr)
593 call mpi_recv(itime_master, 1, MPI_INTEGER,
594 & 0,101,CG_COMM, status, ierr)
595 call mpi_barrier(CG_COMM, ierr)
596 cdeb if (out1file.or.traj1file) then
597 cdeb call mpi_gather(itime,1,mpi_integer,
598 cdeb & icache_all,1,mpi_integer,king,
601 & call mpi_gather(ntwx_cache,1,mpi_integer,
602 & icache_all,1,mpi_integer,king,
605 & write(iout,*) 'REMD synchro at',itime_master,itime
606 if (itime_master.ge.n_timestep .or. ovrtim())
608 ctime call flush(iout)
613 if ((mod(itime,nstex).eq.0.and.me.eq.king
614 & .or.end_of_run.and.me.eq.king )
615 & .and. .not. mremdsync ) then
618 call mpi_isend(itime,1,MPI_INTEGER,i,101,
619 & CG_COMM, ireqi(i), ierr)
620 cd write(iout,*) 'REMD synchro with',i
623 call mpi_waitall(nodes-1,ireqi,statusi,ierr)
624 call mpi_barrier(CG_COMM, ierr)
626 write(iout,*) 'REMD synchro at',itime,'time=',time01-time00
627 if (out1file.or.traj1file) then
628 cdeb call mpi_gather(itime,1,mpi_integer,
629 cdeb & itime_all,1,mpi_integer,king,
631 cdeb write(iout,'(a19,8000i8)') ' REMD synchro itime',
632 cdeb & (itime_all(i),i=1,nodes)
634 cdeb imin_itime=itime_all(1)
636 cdeb if(itime_all(i).lt.imin_itime) imin_itime=itime_all(i)
638 cdeb ii_write=(imin_itime-imin_itime_old)/ntwx
639 cdeb imin_itime_old=int(imin_itime/ntwx)*ntwx
640 cdeb write(iout,*) imin_itime,imin_itime_old,ii_write
641 call mpi_gather(ntwx_cache,1,mpi_integer,
642 & icache_all,1,mpi_integer,king,
644 c write(iout,'(a19,8000i8)') ' ntwx_cache',
645 c & (icache_all(i),i=1,nodes)
646 ii_write=icache_all(1)
648 if(icache_all(i).lt.ii_write) ii_write=icache_all(i)
650 c write(iout,*) "MIN ii_write=",ii_write
653 ctime call flush(iout)
655 if(mremdsync .and. mod(itime,nstex).eq.0) then
657 if (me.eq.king .or. .not. out1file)
658 & write(iout,*) 'REMD synchro at',itime
661 call mpi_gather(ntwx_cache,1,mpi_integer,
662 & icache_all,1,mpi_integer,king,
665 write(iout,'(a19,8000i8)') ' ntwx_cache',
666 & (icache_all(i),i=1,nodes)
667 ii_write=icache_all(1)
669 if(icache_all(i).lt.ii_write) ii_write=icache_all(i)
671 write(iout,*) "MIN ii_write=",ii_write
677 c Update the time safety limiy
678 if (time001-time00.gt.safety) then
679 safety=time001-time00+600
680 write (iout,*) "****** SAFETY increased to",safety," s"
682 if (ovrtim()) end_of_run=.true.
684 if(synflag.and..not.end_of_run) then
688 write(iout,*) 'REMD before',me,t_bath
690 c call mpi_gather(t_bath,1,mpi_double_precision,
691 c & remd_t_bath,1,mpi_double_precision,king,
693 potEcomp(n_ene+1)=t_bath
695 potEcomp(n_ene+2)=iset
696 if (iset.lt.nset) then
700 potEcomp(n_ene+3)=Uconst
707 potEcomp(n_ene+4)=Uconst
711 call mpi_gather(potEcomp(0),n_ene+5,mpi_double_precision,
712 & remd_ene(0,1),n_ene+5,mpi_double_precision,king,
715 call mpi_gather(elow,1,mpi_double_precision,
716 & elowi,1,mpi_double_precision,king,
718 call mpi_gather(ehigh,1,mpi_double_precision,
719 & ehighi,1,mpi_double_precision,king,
724 if (me.eq.king .or. .not. out1file) then
725 write(iout,*) 'REMD gather times=',time03-time01
729 if (restart1file) call write1rst(i_index)
732 if (me.eq.king .or. .not. out1file) then
733 write(iout,*) 'REMD writing rst time=',time04-time03
736 if (traj1file) call write1traj
738 cdeb call mpi_gather(ntwx_cache,1,mpi_integer,
739 cdeb & icache_all,1,mpi_integer,king,
741 cdeb write(iout,'(a19,8000i8)') ' ntwx_cache after traj1file',
742 cdeb & (icache_all(i),i=1,nodes)
747 if (me.eq.king .or. .not. out1file) then
748 write(iout,*) 'REMD writing traj time=',time05-time04
755 remd_t_bath(i)=remd_ene(n_ene+1,i)
756 iremd_iset(i)=remd_ene(n_ene+2,i)
759 co write(iout,*) 'REMD exchange temp,ene,elow,ehigh'
761 write(iout,'(i4,4f12.5)') i,remd_t_bath(i),remd_ene(0,i),
765 write(iout,*) 'REMD exchange temp,ene'
767 write(iout,'(i4,2f12.5)') i,remd_t_bath(i),remd_ene(0,i)
768 write(iout,'(6f12.5)') (remd_ene(j,i),j=1,n_ene)
771 c-------------------------------------
773 write (iout,*) "Enter exchnge, remd_m",remd_m(1),
776 write (iout,*) "remd_m(1)",remd_m(1)
778 i=ifirst(iran_num(1,remd_m(1)))
784 write (iout,*) "i",i," nupa(0,i)",int(nupa(0,i))
785 if(i.gt.0.and.nupa(0,i).gt.0) then
787 c if (i.eq.1 .and. int(nupa(0,i)).eq.1) then
789 c & "CHUJ ABSOLUTNY!!! No way to sample a distinct replica in MREMD"
791 c call MPI_Abort(MPI_COMM_WORLD,ERRCODE,ierr)
793 c do while (iex.eq.i)
794 c write (iout,*) "upper",nupa(int(nupa(0,i)),i)
795 iex=nupa(iran_num(1,int(nupa(0,i))),i)
797 c write (iout,*) "nupa(0,i)",nupa(0,i)," iex",iex
799 call muca_delta(remd_t_bath,remd_ene,i,iex,delta)
801 c Swap temperatures between conformations i and iex with recalculating the free energies
802 c following temperature changes.
803 ene_iex_iex=remd_ene(0,iex)
804 ene_i_i=remd_ene(0,i)
805 c write (iout,*) "i",i," ene_i_i",ene_i_i,
806 c & " iex",iex," ene_iex_iex",ene_iex_iex
807 c write (iout,*) "rescaling weights with temperature",
810 call rescale_weights(remd_t_bath(i))
812 c write (iout,*) "0,iex",remd_t_bath(i)
813 c call enerprint(remd_ene(0,iex))
815 call sum_energy(remd_ene(0,iex),.false.)
816 ene_iex_i=remd_ene(0,iex)
817 c write (iout,*) "ene_iex_i",remd_ene(0,iex)
819 c write (iout,*) "0,i",remd_t_bath(i)
820 c call enerprint(remd_ene(0,i))
822 call sum_energy(remd_ene(0,i),.false.)
823 c write (iout,*) "ene_i_i",remd_ene(0,i)
825 c write (iout,*) "rescaling weights with temperature",
827 if (real(ene_i_i).ne.real(remd_ene(0,i))) then
828 write (iout,*) "ERROR: inconsistent energies:",i,
829 & ene_i_i,remd_ene(0,i)
831 call rescale_weights(remd_t_bath(iex))
833 c write (iout,*) "0,i",remd_t_bath(iex)
834 c call enerprint(remd_ene(0,i))
836 call sum_energy(remd_ene(0,i),.false.)
837 c write (iout,*) "ene_i_iex",remd_ene(0,i)
839 ene_i_iex=remd_ene(0,i)
841 c write (iout,*) "0,iex",remd_t_bath(iex)
842 c call enerprint(remd_ene(0,iex))
844 call sum_energy(remd_ene(0,iex),.false.)
845 if (real(ene_iex_iex).ne.real(remd_ene(0,iex))) then
846 write (iout,*) "ERROR: inconsistent energies:",iex,
847 & ene_iex_iex,remd_ene(0,iex)
849 c write (iout,*) "ene_iex_iex",remd_ene(0,iex)
850 c write (iout,*) "i",i," iex",iex
851 c write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
852 c & " ene_i_iex",ene_i_iex,
853 c & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
855 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
856 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
858 c write(iout,*) 'delta',delta
859 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
860 c & (remd_ene(i)-remd_ene(iex))/Rb/
861 c & (remd_t_bath(i)*remd_t_bath(iex))
863 if (delta .gt. 50.0d0) then
869 else if (delta.lt.-50.0d0) then
878 iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
879 xxx=ran_number(0.0d0,1.0d0)
880 c write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
882 if (delta .gt. xxx) then
884 remd_t_bath(i)=remd_t_bath(iex)
886 remd_ene(0,i)=ene_i_iex
887 remd_ene(0,iex)=ene_iex_i
893 ehighi(i)=ehighi(iex)
900 nupa(k,i)=nupa(k,iex)
903 ndowna(k,i)=ndowna(k,iex)
907 if (ifirst(il).eq.i) ifirst(il)=iex
909 if (nupa(k,il).eq.i) then
911 elseif (nupa(k,il).eq.iex) then
916 if (ndowna(k,il).eq.i) then
918 elseif (ndowna(k,il).eq.iex) then
924 iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
926 i2rep(i-1)=i2rep(iex-1)
929 c write(iout,*) 'exchange',i,iex
930 c write (iout,'(a8,100i4)') "@ ifirst",
931 c & (ifirst(k),k=1,remd_m(1))
933 c write (iout,'(a8,i4,a1,100i4)') "@ nupa",il,":",
934 c & (nupa(k,il),k=1,nupa(0,il))
935 c write (iout,'(a8,i4,a1,100i4)') "@ ndowna",il,":",
936 c & (ndowna(k,il),k=1,ndowna(0,il))
941 remd_ene(0,iex)=ene_iex_iex
942 remd_ene(0,i)=ene_i_i
948 cd write (iout,*) "exchange completed"
952 cd write(iout,*) "########",ii
954 i_temp=iran_num(1,nrep)
955 i_mult=iran_num(1,remd_m(i_temp))
956 i_iset=iran_num(1,nset)
957 i_mset=iran_num(1,mset(i_iset))
958 i=i_index(i_temp,i_mult,i_iset,i_mset)
960 cd write(iout,*) "i=",i,i_temp,i_mult,i_iset,i_mset
963 cd write(iout,*) "i_dir=",i_dir
965 if(i_dir.eq.1 .and. remd_m(i_temp+1).gt.0 )then
968 i_mult1=iran_num(1,remd_m(i_temp1))
970 i_mset1=iran_num(1,mset(i_iset1))
971 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
973 elseif(i_dir.eq.2 .and. mset(i_iset+1).gt.0)then
976 i_mult1=iran_num(1,remd_m(i_temp1))
978 i_mset1=iran_num(1,mset(i_iset1))
979 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
980 econstr_temp_i=remd_ene(20,i)
981 econstr_temp_iex=remd_ene(20,iex)
982 remd_ene(20,i)=remd_ene(n_ene+3,i)
983 remd_ene(20,iex)=remd_ene(n_ene+4,iex)
985 elseif(remd_m(i_temp+1).gt.0.and.mset(i_iset+1).gt.0)then
988 i_mult1=iran_num(1,remd_m(i_temp1))
990 i_mset1=iran_num(1,mset(i_iset1))
991 iex=i_index(i_temp1,i_mult1,i_iset1,i_mset1)
992 econstr_temp_i=remd_ene(20,i)
993 econstr_temp_iex=remd_ene(20,iex)
994 remd_ene(20,i)=remd_ene(n_ene+3,i)
995 remd_ene(20,iex)=remd_ene(n_ene+4,iex)
1001 cd write(iout,*) "iex=",iex,i_temp1,i_mult1,i_iset1,i_mset1
1004 c Swap temperatures between conformations i and iex with recalculating the free energies
1005 c following temperature changes.
1006 ene_iex_iex=remd_ene(0,iex)
1007 ene_i_i=remd_ene(0,i)
1008 co write (iout,*) "rescaling weights with temperature",
1010 call rescale_weights(remd_t_bath(i))
1012 call sum_energy(remd_ene(0,iex),.false.)
1013 ene_iex_i=remd_ene(0,iex)
1014 cd write (iout,*) "ene_iex_i",remd_ene(0,iex)
1015 c call sum_energy(remd_ene(0,i),.false.)
1016 cd write (iout,*) "ene_i_i",remd_ene(0,i)
1017 c write (iout,*) "rescaling weights with temperature",
1018 c & remd_t_bath(iex)
1019 c if (real(ene_i_i).ne.real(remd_ene(0,i))) then
1020 c write (iout,*) "ERROR: inconsistent energies:",i,
1021 c & ene_i_i,remd_ene(0,i)
1023 call rescale_weights(remd_t_bath(iex))
1024 call sum_energy(remd_ene(0,i),.false.)
1025 cd write (iout,*) "ene_i_iex",remd_ene(0,i)
1026 ene_i_iex=remd_ene(0,i)
1027 c call sum_energy(remd_ene(0,iex),.false.)
1028 c if (real(ene_iex_iex).ne.real(remd_ene(0,iex))) then
1029 c write (iout,*) "ERROR: inconsistent energies:",iex,
1030 c & ene_iex_iex,remd_ene(0,iex)
1032 cd write (iout,*) "ene_iex_iex",remd_ene(0,iex)
1033 c write (iout,*) "i",i," iex",iex
1034 cd write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
1035 cd & " ene_i_iex",ene_i_iex,
1036 cd & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
1037 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
1038 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
1040 cd write(iout,*) 'delta',delta
1041 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
1042 c & (remd_ene(i)-remd_ene(iex))/Rb/
1043 c & (remd_t_bath(i)*remd_t_bath(iex))
1044 if (delta .gt. 50.0d0) then
1049 if (i_dir.eq.1.or.i_dir.eq.3)
1050 & iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
1051 if (i_dir.eq.2.or.i_dir.eq.3)
1052 & iremd_tot_usa(int(i2set(i-1)))=
1053 & iremd_tot_usa(int(i2set(i-1)))+1
1054 xxx=ran_number(0.0d0,1.0d0)
1055 cd write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
1056 if (delta .gt. xxx) then
1058 remd_t_bath(i)=remd_t_bath(iex)
1059 remd_t_bath(iex)=tmp
1062 iremd_iset(i)=iremd_iset(iex)
1063 iremd_iset(iex)=itmp
1065 remd_ene(0,i)=ene_i_iex
1066 remd_ene(0,iex)=ene_iex_i
1068 if (i_dir.eq.1.or.i_dir.eq.3)
1069 & iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
1072 i2rep(i-1)=i2rep(iex-1)
1075 if (i_dir.eq.2.or.i_dir.eq.3)
1076 & iremd_acc_usa(int(i2set(i-1)))=
1077 & iremd_acc_usa(int(i2set(i-1)))+1
1080 i2set(i-1)=i2set(iex-1)
1083 itmp=i_index(i_temp,i_mult,i_iset,i_mset)
1084 i_index(i_temp,i_mult,i_iset,i_mset)=
1085 & i_index(i_temp1,i_mult1,i_iset1,i_mset1)
1086 i_index(i_temp1,i_mult1,i_iset1,i_mset1)=itmp
1089 remd_ene(0,iex)=ene_iex_iex
1090 remd_ene(0,i)=ene_i_i
1091 remd_ene(20,iex)=econstr_temp_iex
1092 remd_ene(20,i)=econstr_temp_i
1096 cd do il1=1,mset(il)
1099 cd write(iout,*) i,j,il,il1,i_index(i,j,il,il1)
1112 c-------------------------------------
1113 write (iout,*) "NREP",nrep
1115 if(iremd_tot(i).ne.0)
1116 & write(iout,'(a3,i4,2f12.5,i5)') 'ACC',i,remd_t(i)
1117 & ,iremd_acc(i)/(1.0*iremd_tot(i)),iremd_tot(i)
1122 if(iremd_tot_usa(i).ne.0)
1123 & write(iout,'(a10,i4,f12.5,i8)') 'ACC_usampl',i,
1124 & iremd_acc_usa(i)/(1.0*iremd_tot_usa(i)),iremd_tot_usa(i)
1130 cd write (iout,'(a6,100i4)') "ifirst",
1131 cd & (ifirst(i),i=1,remd_m(1))
1133 cd write (iout,'(a5,i4,a1,100i4)') "nup",il,":",
1134 cd & (nupa(i,il),i=1,nupa(0,il))
1135 cd write (iout,'(a5,i4,a1,100i4)') "ndown",il,":",
1136 cd & (ndowna(i,il),i=1,ndowna(0,il))
1141 cd write (iout,*) "Before scatter"
1143 call mpi_scatter(remd_t_bath,1,mpi_double_precision,
1144 & t_bath,1,mpi_double_precision,king,
1146 cd write (iout,*) "After scatter"
1149 & call mpi_scatter(iremd_iset,1,mpi_integer,
1150 & iset,1,mpi_integer,king,
1154 if (me.eq.king .or. .not. out1file) then
1155 write(iout,*) 'REMD scatter time=',time07-time06
1159 call mpi_scatter(elowi,1,mpi_double_precision,
1160 & elow,1,mpi_double_precision,king,
1162 call mpi_scatter(ehighi,1,mpi_double_precision,
1163 & ehigh,1,mpi_double_precision,king,
1166 call rescale_weights(t_bath)
1167 co write (iout,*) "Processor",me,
1168 co & " rescaling weights with temperature",t_bath
1170 stdfp=dsqrt(2*Rb*t_bath/d_time)
1172 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
1175 cde write(iout,*) 'REMD after',me,t_bath
1177 if (me.eq.king .or. .not. out1file) then
1178 write(iout,*) 'REMD exchange time=',time08-time00
1184 if (restart1file) then
1185 if (me.eq.king .or. .not. out1file)
1186 & write(iout,*) 'writing restart at the end of run'
1187 call write1rst(i_index)
1190 if (traj1file) call write1traj
1192 cdeb call mpi_gather(ntwx_cache,1,mpi_integer,
1193 cdeb & icache_all,1,mpi_integer,king,
1194 cdeb & CG_COMM,ierr)
1195 cdeb write(iout,'(a40,8000i8)')
1196 cdeb & ' ntwx_cache after traj1file at the end',
1197 cdeb & (icache_all(i),i=1,nodes)
1202 t_MD=MPI_Wtime()-tt0
1206 if (me.eq.king .or. .not. out1file) then
1207 write (iout,'(//35(1h=),a10,35(1h=)/10(/a40,1pe15.5))')
1209 & 'MD calculations setup:',t_MDsetup,
1210 & 'Energy & gradient evaluation:',t_enegrad,
1211 & 'Stochastic MD setup:',t_langsetup,
1212 & 'Stochastic MD step setup:',t_sdsetup,
1214 write (iout,'(/28(1h=),a25,27(1h=))')
1215 & ' End of MD calculation '
1220 c-----------------------------------------------------------------------
1221 subroutine write1rst(i_index)
1222 implicit real*8 (a-h,o-z)
1223 include 'DIMENSIONS'
1226 include 'COMMON.IOUNITS'
1227 include 'COMMON.REMD'
1228 include 'COMMON.SETUP'
1229 include 'COMMON.CHAIN'
1230 include 'COMMON.SBRIDGE'
1231 include 'COMMON.INTERACT'
1233 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1234 & d_restart2(3,2*maxres*maxprocs)
1238 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
1239 common /przechowalnia/ d_restart1,d_restart2
1244 t5_restart1(4)=t_bath
1245 t5_restart1(5)=Uconst
1247 call mpi_gather(t5_restart1,5,mpi_real,
1248 & t_restart1,5,mpi_real,king,CG_COMM,ierr)
1256 call mpi_gather(r_d,3*2*nres,mpi_real,
1257 & d_restart1,3*2*nres,mpi_real,king,
1266 call mpi_gather(r_d,3*2*nres,mpi_real,
1267 & d_restart2,3*2*nres,mpi_real,king,
1272 call xdrfopen_(ixdrf,mremd_rst_name, "w", iret)
1274 call xdrfint_(ixdrf, i2rep(i), iret)
1277 call xdrfint_(ixdrf, ifirst(i), iret)
1281 call xdrfint_(ixdrf, nupa(i,il), iret)
1285 call xdrfint_(ixdrf, ndowna(i,il), iret)
1291 call xdrffloat_(ixdrf, t_restart1(j,il), iret)
1298 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1305 call xdrffloat_(ixdrf, d_restart2(j,i+2*nres*il), iret)
1311 call xdrfint_(ixdrf, nset, iret)
1313 call xdrfint_(ixdrf,mset(i), iret)
1316 call xdrfint_(ixdrf,i2set(i), iret)
1322 itmp=i_index(i,j,il,il1)
1323 call xdrfint_(ixdrf,itmp, iret)
1330 call xdrfclose_(ixdrf, iret)
1332 call xdrfopen(ixdrf,mremd_rst_name, "w", iret)
1334 call xdrfint(ixdrf, i2rep(i), iret)
1337 call xdrfint(ixdrf, ifirst(i), iret)
1341 call xdrfint(ixdrf, nupa(i,il), iret)
1345 call xdrfint(ixdrf, ndowna(i,il), iret)
1351 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1358 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1365 call xdrffloat(ixdrf, d_restart2(j,i+2*nres*il), iret)
1372 call xdrfint(ixdrf, nset, iret)
1374 call xdrfint(ixdrf,mset(i), iret)
1377 call xdrfint(ixdrf,i2set(i), iret)
1383 itmp=i_index(i,j,il,il1)
1384 call xdrfint(ixdrf,itmp, iret)
1391 call xdrfclose(ixdrf, iret)
1398 subroutine write1traj
1399 implicit real*8 (a-h,o-z)
1400 include 'DIMENSIONS'
1403 include 'COMMON.IOUNITS'
1404 include 'COMMON.REMD'
1405 include 'COMMON.SETUP'
1406 include 'COMMON.CHAIN'
1407 include 'COMMON.SBRIDGE'
1408 include 'COMMON.INTERACT'
1412 real xcoord(3,maxres2+2),prec
1413 real r_qfrag(50),r_qpair(100)
1414 real r_utheta(50),r_ugamma(100),r_uscdiff(100)
1415 real p_qfrag(50*maxprocs),p_qpair(100*maxprocs)
1416 real p_utheta(50*maxprocs),p_ugamma(100*maxprocs),
1417 & p_uscdiff(100*maxprocs)
1418 real p_c(3,(maxres2+2)*maxprocs),r_c(3,maxres2+2)
1419 common /przechowalnia/ p_c
1421 call mpi_bcast(ii_write,1,mpi_integer,
1422 & king,CG_COMM,ierr)
1425 print *,'traj1file',me,ii_write,ntwx_cache
1429 if(me.eq.king) call xdrfopen_(ixdrf,cartname, "a", iret)
1431 if(me.eq.king) call xdrfopen(ixdrf,cartname, "a", iret)
1434 t5_restart1(1)=totT_cache(ii)
1435 t5_restart1(2)=EK_cache(ii)
1436 t5_restart1(3)=potE_cache(ii)
1437 t5_restart1(4)=t_bath_cache(ii)
1438 t5_restart1(5)=Uconst_cache(ii)
1439 call mpi_gather(t5_restart1,5,mpi_real,
1440 & t_restart1,5,mpi_real,king,CG_COMM,ierr)
1442 call mpi_gather(iset_cache(ii),1,mpi_integer,
1443 & iset_restart1,1,mpi_integer,king,CG_COMM,ierr)
1446 r_qfrag(i)=qfrag_cache(i,ii)
1449 r_qpair(i)=qpair_cache(i,ii)
1452 r_utheta(i)=utheta_cache(i,ii)
1453 r_ugamma(i)=ugamma_cache(i,ii)
1454 r_uscdiff(i)=uscdiff_cache(i,ii)
1457 call mpi_gather(r_qfrag,nfrag,mpi_real,
1458 & p_qfrag,nfrag,mpi_real,king,
1460 call mpi_gather(r_qpair,npair,mpi_real,
1461 & p_qpair,npair,mpi_real,king,
1463 call mpi_gather(r_utheta,nfrag_back,mpi_real,
1464 & p_utheta,nfrag_back,mpi_real,king,
1466 call mpi_gather(r_ugamma,nfrag_back,mpi_real,
1467 & p_ugamma,nfrag_back,mpi_real,king,
1469 call mpi_gather(r_uscdiff,nfrag_back,mpi_real,
1470 & p_uscdiff,nfrag_back,mpi_real,king,
1474 write (iout,*) "p_qfrag"
1476 write (iout,*) i,(p_qfrag((i-1)*nfrag+j),j=1,nfrag)
1478 write (iout,*) "p_qpair"
1480 write (iout,*) i,(p_qpair((i-1)*npair+j),j=1,npair)
1486 r_c(j,i)=c_cache(j,i,ii)
1490 call mpi_gather(r_c,3*2*nres,mpi_real,
1491 & p_c,3*2*nres,mpi_real,king,
1497 call xdrffloat_(ixdrf, real(t_restart1(1,il)), iret)
1498 call xdrffloat_(ixdrf, real(t_restart1(3,il)), iret)
1499 call xdrffloat_(ixdrf, real(t_restart1(5,il)), iret)
1500 call xdrffloat_(ixdrf, real(t_restart1(4,il)), iret)
1501 call xdrfint_(ixdrf, nss, iret)
1503 call xdrfint_(ixdrf, ihpb(j), iret)
1504 call xdrfint_(ixdrf, jhpb(j), iret)
1506 call xdrfint_(ixdrf, nfrag+npair+3*nfrag_back, iret)
1507 call xdrfint_(ixdrf, iset_restart1(il), iret)
1509 call xdrffloat_(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
1512 call xdrffloat_(ixdrf, p_qpair(i+(il-1)*npair), iret)
1515 call xdrffloat_(ixdrf, p_utheta(i+(il-1)*nfrag_back), iret)
1516 call xdrffloat_(ixdrf, p_ugamma(i+(il-1)*nfrag_back), iret)
1517 call xdrffloat_(ixdrf, p_uscdiff(i+(il-1)*nfrag_back), iret)
1522 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
1527 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
1531 call xdrf3dfcoord_(ixdrf, xcoord, itmp, prec, iret)
1535 call xdrffloat(ixdrf, real(t_restart1(1,il)), iret)
1536 call xdrffloat(ixdrf, real(t_restart1(3,il)), iret)
1537 call xdrffloat(ixdrf, real(t_restart1(5,il)), iret)
1538 call xdrffloat(ixdrf, real(t_restart1(4,il)), iret)
1539 call xdrfint(ixdrf, nss, iret)
1541 call xdrfint(ixdrf, ihpb(j), iret)
1542 call xdrfint(ixdrf, jhpb(j), iret)
1544 call xdrfint(ixdrf, nfrag+npair+3*nfrag_back, iret)
1545 call xdrfint(ixdrf, iset_restart1(il), iret)
1547 call xdrffloat(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
1550 call xdrffloat(ixdrf, p_qpair(i+(il-1)*npair), iret)
1553 call xdrffloat(ixdrf, p_utheta(i+(il-1)*nfrag_back), iret)
1554 call xdrffloat(ixdrf, p_ugamma(i+(il-1)*nfrag_back), iret)
1555 call xdrffloat(ixdrf, p_uscdiff(i+(il-1)*nfrag_back), iret)
1560 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
1565 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
1569 call xdrf3dfcoord(ixdrf, xcoord, itmp, prec, iret)
1575 if(me.eq.king) call xdrfclose_(ixdrf, iret)
1577 if(me.eq.king) call xdrfclose(ixdrf, iret)
1579 do i=1,ntwx_cache-ii_write
1581 totT_cache(i)=totT_cache(ii_write+i)
1582 EK_cache(i)=EK_cache(ii_write+i)
1583 potE_cache(i)=potE_cache(ii_write+i)
1584 t_bath_cache(i)=t_bath_cache(ii_write+i)
1585 Uconst_cache(i)=Uconst_cache(ii_write+i)
1586 iset_cache(i)=iset_cache(ii_write+i)
1589 qfrag_cache(ii,i)=qfrag_cache(ii,ii_write+i)
1592 qpair_cache(ii,i)=qpair_cache(ii,ii_write+i)
1595 utheta_cache(ii,i)=utheta_cache(ii,ii_write+i)
1596 ugamma_cache(ii,i)=ugamma_cache(ii,ii_write+i)
1597 uscdiff_cache(ii,i)=uscdiff_cache(ii,ii_write+i)
1602 c_cache(j,ii,i)=c_cache(j,ii,ii_write+i)
1606 ntwx_cache=ntwx_cache-ii_write
1611 subroutine read1restart(i_index)
1612 implicit real*8 (a-h,o-z)
1613 include 'DIMENSIONS'
1616 include 'COMMON.IOUNITS'
1617 include 'COMMON.REMD'
1618 include 'COMMON.SETUP'
1619 include 'COMMON.CHAIN'
1620 include 'COMMON.SBRIDGE'
1621 include 'COMMON.INTERACT'
1622 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1625 & (maxprocs/4,maxprocs/20,maxprocs/200,maxprocs/200)
1626 common /przechowalnia/ d_restart1
1627 write (*,*) "Processor",me," called read1restart"
1630 open(irest2,file=mremd_rst_name,status='unknown')
1631 read(irest2,*,err=334) i
1632 write(iout,*) "Reading old rst in ASCI format"
1634 call read1restart_old
1638 call xdrfopen_(ixdrf,mremd_rst_name, "r", iret)
1641 call xdrfint_(ixdrf, i2rep(i), iret)
1644 call xdrfint_(ixdrf, ifirst(i), iret)
1647 call xdrfint_(ixdrf, nupa(0,il), iret)
1649 call xdrfint_(ixdrf, nupa(i,il), iret)
1652 call xdrfint_(ixdrf, ndowna(0,il), iret)
1654 call xdrfint_(ixdrf, ndowna(i,il), iret)
1659 call xdrffloat_(ixdrf, t_restart1(j,il), iret)
1663 call xdrfopen(ixdrf,mremd_rst_name, "r", iret)
1666 call xdrfint(ixdrf, i2rep(i), iret)
1669 call xdrfint(ixdrf, ifirst(i), iret)
1672 call xdrfint(ixdrf, nupa(0,il), iret)
1674 call xdrfint(ixdrf, nupa(i,il), iret)
1677 call xdrfint(ixdrf, ndowna(0,il), iret)
1679 call xdrfint(ixdrf, ndowna(i,il), iret)
1684 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1689 call mpi_scatter(t_restart1,5,mpi_real,
1690 & t5_restart1,5,mpi_real,king,CG_COMM,ierr)
1694 t_bath=t5_restart1(4)
1699 c read(irest2,'(3e15.5)')
1700 c & (d_restart1(j,i+2*nres*il),j=1,3)
1703 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1705 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1711 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1712 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1722 c read(irest2,'(3e15.5)')
1723 c & (d_restart1(j,i+2*nres*il),j=1,3)
1726 call xdrffloat_(ixdrf, d_restart1(j,i+2*nres*il), iret)
1728 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1734 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1735 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1746 call xdrfint_(ixdrf, nset, iret)
1748 call xdrfint_(ixdrf,mset(i), iret)
1751 call xdrfint_(ixdrf,i2set(i), iret)
1757 call xdrfint_(ixdrf,itmp, iret)
1758 i_index(i,j,il,il1)=itmp
1766 call xdrfint(ixdrf, nset, iret)
1768 call xdrfint(ixdrf,mset(i), iret)
1771 call xdrfint(ixdrf,i2set(i), iret)
1777 call xdrfint(ixdrf,itmp, iret)
1778 i_index(i,j,il,il1)=itmp
1785 call mpi_scatter(i2set,1,mpi_integer,
1786 & iset,1,mpi_integer,king,
1792 if(me.eq.king) close(irest2)
1796 subroutine read1restart_old
1797 implicit real*8 (a-h,o-z)
1798 include 'DIMENSIONS'
1801 include 'COMMON.IOUNITS'
1802 include 'COMMON.REMD'
1803 include 'COMMON.SETUP'
1804 include 'COMMON.CHAIN'
1805 include 'COMMON.SBRIDGE'
1806 include 'COMMON.INTERACT'
1807 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1809 common /przechowalnia/ d_restart1
1811 open(irest2,file=mremd_rst_name,status='unknown')
1812 read (irest2,*) (i2rep(i),i=0,nodes-1)
1813 read (irest2,*) (ifirst(i),i=1,remd_m(1))
1815 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
1816 read (irest2,*) ndowna(0,il),
1817 & (ndowna(i,il),i=1,ndowna(0,il))
1820 read(irest2,*) (t_restart1(j,il),j=1,4)
1823 call mpi_scatter(t_restart1,5,mpi_real,
1824 & t5_restart1,5,mpi_real,king,CG_COMM,ierr)
1828 t_bath=t5_restart1(4)
1833 read(irest2,'(3e15.5)')
1834 & (d_restart1(j,i+2*nres*il),j=1,3)
1838 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1839 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1849 read(irest2,'(3e15.5)')
1850 & (d_restart1(j,i+2*nres*il),j=1,3)
1854 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1855 & r_d,3*2*nres,mpi_real,king,CG_COMM,ierr)
1861 if(me.eq.king) close(irest2)