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 double precision cm(3),L(3),vcm(3)
25 double precision energia(0:n_ene)
26 double precision remd_t_bath(maxprocs)
27 double precision remd_ene(0:n_ene+1,maxprocs)
28 integer iremd_acc(maxprocs),iremd_tot(maxprocs)
34 cold integer nup(0:maxprocs),ndown(0:maxprocs)
35 integer rep2i(0:maxprocs),ireqi(maxprocs)
36 integer itime_all(maxprocs)
37 integer status(MPI_STATUS_SIZE),statusi(MPI_STATUS_SIZE,maxprocs)
38 logical synflag,end_of_run,file_exist
41 if(me.eq.king.or..not.out1file)
42 & write (iout,*) 'MREMD',nodes,'time before',time00-walltime
45 mremd_rst_name=prefix(:ilen(prefix))//"_mremd.rst"
47 cd print *,'MREMD',nodes
49 cd print *,'mmm',me,remd_mlist,(remd_m(i),i=1,nrep)
51 cde write (iout,*) "Start MREMD: me",me," t_bath",t_bath
64 c print *,'i2rep',me,i2rep(me)
65 c print *,'rep2i',(rep2i(i),i=0,nrep)
67 cold if (i2rep(me).eq.nrep) then
70 cold nup(0)=remd_m(i2rep(me)+1)
71 cold k=rep2i(int(i2rep(me)))+1
78 cd print '(i4,a4,100i4)',me,' nup',(nup(i),i=0,nup(0))
80 cold if (i2rep(me).eq.1) then
83 cold ndown(0)=remd_m(i2rep(me)-1)
84 cold k=rep2i(i2rep(me)-2)+1
91 cd print '(i4,a6,100i4)',me,' ndown',(ndown(i),i=0,ndown(0))
94 if(rest.and.restart1file) then
95 inquire(file=mremd_rst_name,exist=file_exist)
96 if(file_exist) call read1restart
100 if (rest.and..not.restart1file)
101 & inquire(file=mremd_rst_name,exist=file_exist)
102 IF (rest.and.file_exist.and..not.restart1file) THEN
103 open(irest2,file=mremd_rst_name,status='unknown')
105 read (irest2,*) (i2rep(i),i=0,nodes-1)
107 read (irest2,*) (ifirst(i),i=1,remd_m(1))
110 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
112 read (irest2,*) ndowna(0,il),
113 & (ndowna(i,il),i=1,ndowna(0,il))
117 write (iout,'(a6,1000i5)') "i2rep",(i2rep(i),i=0,nodes-1)
118 write (iout,'(a6,1000i5)') "ifirst",
119 & (ifirst(i),i=1,remd_m(1))
121 write (iout,'(a6,i4,a1,100i4)') "nupa",il,":",
122 & (nupa(i,il),i=1,nupa(0,il))
123 write (iout,'(a6,i4,a1,100i4)') "ndowna",il,":",
124 & (ndowna(i,il),i=1,ndowna(0,il))
126 ELSE IF (.not.(rest.and.file_exist)) THEN
133 if (i2rep(il-1).eq.nrep) then
136 nupa(0,il)=remd_m(i2rep(il-1)+1)
137 k=rep2i(int(i2rep(il-1)))+1
144 if (i2rep(il-1).eq.1) then
147 ndowna(0,il)=remd_m(i2rep(il-1)-1)
148 k=rep2i(i2rep(il-1)-2)+1
157 c write (iout,'(a6,100i4)') "ifirst",
158 c & (ifirst(i),i=1,remd_m(1))
160 c write (iout,'(a6,i4,a1,100i4)') "nupa",il,":",
161 c & (nupa(i,il),i=1,nupa(0,il))
162 c write (iout,'(a6,i4,a1,100i4)') "ndowna",il,":",
163 c & (ndowna(i,il),i=1,ndowna(0,il))
169 c t_bath=retmin+(retmax-retmin)*me/(nodes-1)
170 if(.not.(rest.and.file_exist.and.restart1file)) then
171 if (me .eq. king) then
174 t_bath=retmin+(retmax-retmin)*exp(float(i2rep(me)-nrep))
176 cd print *,'ttt',me,remd_tlist,(remd_t(i),i=1,nrep)
177 if (remd_tlist) t_bath=remd_t(int(i2rep(me)))
180 stdfp=dsqrt(2*Rb*t_bath/d_time)
182 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
185 c print *,'irep',me,t_bath
187 if (me.eq.king .or. .not. out1file)
188 & write (iout,'(a60,f10.5)') "REMD Temperature:",t_bath
189 call rescale_weights(t_bath)
193 c------copy MD--------------
194 c The driver for molecular dynamics subroutines
195 c------------------------------------------------
201 if(me.eq.king.or..not.out1file)
202 & write (iout,'(20(1h=),a20,20(1h=))') "MD calculation started"
204 c Determine the inverse of the inertia matrix.
205 call setup_MD_matrices
209 if (me.eq.king .or. .not. out1file)
210 & write (iout,'(a60,f10.5)') "REMD restart Temperature:",t_bath
211 stdfp=dsqrt(2*Rb*t_bath/d_time)
213 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
215 call rescale_weights(t_bath)
218 t_MDsetup = tcpu()-tt0
220 c Entering the MD loop
222 if (lang.eq.2 .or. lang.eq.3) then
225 call sd_verlet_p_setup
227 call sd_verlet_ciccotti_setup
232 pfric0_mat(i,j,0)=pfric_mat(i,j)
233 afric0_mat(i,j,0)=afric_mat(i,j)
234 vfric0_mat(i,j,0)=vfric_mat(i,j)
235 prand0_mat(i,j,0)=prand_mat(i,j)
236 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
237 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
243 flag_stoch(i)=.false.
245 else if (lang.eq.1 .or. lang.eq.4) then
249 if (me.eq.king .or. .not. out1file)
250 & write(iout,*) 'Setup time',time00-walltime
252 t_langsetup=tcpu()-tt0
256 do while(.not.end_of_run)
258 if(itime.eq.n_timestep.and.me.eq.king) end_of_run=.true.
259 if(mremdsync.and.itime.eq.n_timestep) end_of_run=.true.
261 if (lang.gt.0 .and. surfarea .and.
262 & mod(itime,reset_fricmat).eq.0) then
263 if (lang.eq.2 .or. lang.eq.3) then
266 call sd_verlet_p_setup
268 call sd_verlet_ciccotti_setup
273 pfric0_mat(i,j,0)=pfric_mat(i,j)
274 afric0_mat(i,j,0)=afric_mat(i,j)
275 vfric0_mat(i,j,0)=vfric_mat(i,j)
276 prand0_mat(i,j,0)=prand_mat(i,j)
277 vrand0_mat1(i,j,0)=vrand_mat1(i,j)
278 vrand0_mat2(i,j,0)=vrand_mat2(i,j)
284 flag_stoch(i)=.false.
286 else if (lang.eq.1 .or. lang.eq.4) then
289 write (iout,'(a,i10)')
290 & "Friction matrix reset based on surface area, itime",itime
292 if (reset_vel .and. tbf .and. lang.eq.0
293 & .and. mod(itime,count_reset_vel).eq.0) then
295 if (me.eq.king .or. .not. out1file)
296 & write(iout,'(a,f20.2)')
297 & "Velocities reset to random values, time",totT
300 d_t_old(j,i)=d_t(j,i)
304 if (reset_moment .and. mod(itime,count_reset_moment).eq.0) then
308 d_t(j,0)=d_t(j,0)-vcm(j)
311 kinetic_T=2.0d0/(dimen*Rb)*EK
312 scalfac=dsqrt(T_bath/kinetic_T)
313 cd write(iout,'(a,f20.2)') "Momenta zeroed out, time",totT
316 d_t_old(j,i)=scalfac*d_t(j,i)
322 c Time-reversible RESPA algorithm
323 c (Tuckerman et al., J. Chem. Phys., 97, 1990, 1992)
324 call RESPA_step(itime)
326 c Variable time step algorithm.
327 call velverlet_step(itime)
330 call brown_step(itime)
333 if (mod(itime,ntwe).eq.0) call statout(itime)
335 if (mod(itime,ntwx).eq.0.and..not.traj1file) then
336 write (tytul,'("time",f8.2," temp",f8.1)') totT,t_bath
338 call pdbout(potE,tytul,ipdb)
343 if (mod(itime,ntwx).eq.0.and.traj1file) then
344 if(ntwx_cache.lt.max_cache_traj) then
345 ntwx_cache=ntwx_cache+1
347 totT_cache(ntwx_cache)=totT
348 EK_cache(ntwx_cache)=EK
349 potE_cache(ntwx_cache)=potE
350 t_bath_cache(ntwx_cache)=t_bath
351 Uconst_cache(ntwx_cache)=Uconst
354 qfrag_cache(i,ntwx_cache)=qfrag(i)
357 qpair_cache(i,ntwx_cache)=qpair(i)
362 c_cache(j,i,ntwx_cache)=c(j,i)
366 print *,itime,"processor ",me," over cache ",ntwx_cache
369 if ((rstcount.eq.1000.or.itime.eq.n_timestep)
370 & .and..not.restart1file) then
373 open(irest1,file=mremd_rst_name,status='unknown')
374 write (irest1,*) "i2rep"
375 write (irest1,*) (i2rep(i),i=0,nodes-1)
376 write (irest1,*) "ifirst"
377 write (irest1,*) (ifirst(i),i=1,remd_m(1))
379 write (irest1,*) "nupa",il
380 write (irest1,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
381 write (irest1,*) "ndowna",il
382 write (irest1,*) ndowna(0,il),
383 & (ndowna(i,il),i=1,ndowna(0,il))
387 open(irest2,file=rest2name,status='unknown')
388 write(irest2,*) totT,EK,potE,totE,t_bath
390 write (irest2,'(3e15.5)') (d_t(j,i),j=1,3)
393 write (irest2,'(3e15.5)') (dc(j,i),j=1,3)
400 c forced synchronization
401 if (mod(itime,i_sync_step).eq.0 .and. me.ne.king
402 & .and. .not. mremdsync) then
404 call mpi_iprobe(0,101,mpi_comm_world,synflag,status,ierr)
406 call mpi_recv(itime_master, 1, MPI_INTEGER,
407 & 0,101,mpi_comm_world, status, ierr)
408 call mpi_barrier(mpi_comm_world, ierr)
409 if (out1file.or.traj1file) then
410 call mpi_gather(itime,1,mpi_integer,
411 & itime_all,1,mpi_integer,king,
412 & mpi_comm_world,ierr)
415 & write(iout,*) 'REMD synchro at',itime_master,itime
416 if(itime_master.ge.n_timestep) end_of_run=.true.
417 ctime call flush(iout)
422 if ((mod(itime,nstex).eq.0.and.me.eq.king
423 & .or.end_of_run.and.me.eq.king )
424 & .and. .not. mremdsync ) then
428 call mpi_isend(itime,1,MPI_INTEGER,i,101,
429 & mpi_comm_world, ireqi(i), ierr)
430 cd write(iout,*) 'REMD synchro with',i
433 call mpi_waitall(nodes-1,ireqi,statusi,ierr)
434 call mpi_barrier(mpi_comm_world, ierr)
436 write(iout,*) 'REMD synchro at',itime,'time=',time01-time00
437 if (out1file.or.traj1file) then
438 call mpi_gather(itime,1,mpi_integer,
439 & itime_all,1,mpi_integer,king,
440 & mpi_comm_world,ierr)
441 ctime write(iout,'(a19,8000i8)') ' REMD synchro itime',
442 ctime & (itime_all(i),i=1,nodes)
444 imin_itime=itime_all(1)
446 if(itime_all(i).lt.imin_itime) imin_itime=itime_all(i)
448 ii_write=(imin_itime-imin_itime_old)/ntwx
449 imin_itime_old=int(imin_itime/ntwx)*ntwx
450 write(iout,*) imin_itime,imin_itime_old,ii_write
453 ctime call flush(iout)
455 if(mremdsync .and. mod(itime,nstex).eq.0) then
457 if (me.eq.king .or. .not. out1file)
458 & write(iout,*) 'REMD synchro at',itime
461 if(synflag.and..not.end_of_run) then
465 cd write(iout,*) 'REMD before',me,t_bath
467 c call mpi_gather(t_bath,1,mpi_double_precision,
468 c & remd_t_bath,1,mpi_double_precision,king,
469 c & mpi_comm_world,ierr)
470 potEcomp(n_ene+1)=t_bath
471 potEcomp(n_ene+2)=iset
472 call mpi_gather(potEcomp(0),n_ene+3,mpi_double_precision,
473 & remd_ene(0,1),n_ene+3,mpi_double_precision,king,
474 & mpi_comm_world,ierr)
476 call mpi_gather(elow,1,mpi_double_precision,
477 & elowi,1,mpi_double_precision,king,
478 & mpi_comm_world,ierr)
479 call mpi_gather(ehigh,1,mpi_double_precision,
480 & ehighi,1,mpi_double_precision,king,
481 & mpi_comm_world,ierr)
485 if (me.eq.king .or. .not. out1file) then
486 write(iout,*) 'REMD gather times=',time03-time01
490 if (restart1file) call write1rst
493 if (me.eq.king .or. .not. out1file) then
494 write(iout,*) 'REMD writing rst time=',time04-time03
497 if (traj1file) call write1traj
500 if (me.eq.king .or. .not. out1file) then
501 write(iout,*) 'REMD writing traj time=',time05-time04
507 remd_t_bath(i)=remd_ene(n_ene+1,i)
510 co write(iout,*) 'REMD exchange temp,ene,elow,ehigh'
512 write(iout,'(i4,4f12.5)') i,remd_t_bath(i),remd_ene(0,i),
516 cd write(iout,*) 'REMD exchange temp,ene'
518 co write(iout,'(i4,2f12.5)') i,remd_t_bath(i),remd_ene(0,i)
519 c write(iout,'(6f12.5)') (remd_ene(j,i),j=1,n_ene)
522 c-------------------------------------
524 i=ifirst(iran_num(1,remd_m(1)))
527 if(i.gt.0.and.nupa(0,i).gt.0) then
528 iex=nupa(iran_num(1,int(nupa(0,i))),i)
530 call muca_delta(remd_t_bath,remd_ene,i,iex,delta)
532 c Swap temperatures between conformations i and iex with recalculating the free energies
533 c following temperature changes.
534 ene_iex_iex=remd_ene(0,iex)
535 ene_i_i=remd_ene(0,i)
536 co write (iout,*) "rescaling weights with temperature",
538 call rescale_weights(remd_t_bath(i))
539 call sum_energy(remd_ene(0,iex))
540 ene_iex_i=remd_ene(0,iex)
541 cd write (iout,*) "ene_iex_i",remd_ene(0,iex)
542 call sum_energy(remd_ene(0,i))
543 cd write (iout,*) "ene_i_i",remd_ene(0,i)
544 c write (iout,*) "rescaling weights with temperature",
546 if (real(ene_i_i).ne.real(remd_ene(0,i))) then
547 write (iout,*) "ERROR: inconsistent energies:",i,
548 & ene_i_i,remd_ene(0,i)
550 call rescale_weights(remd_t_bath(iex))
551 call sum_energy(remd_ene(0,i))
552 c write (iout,*) "ene_i_iex",remd_ene(0,i)
553 ene_i_iex=remd_ene(0,i)
554 call sum_energy(remd_ene(0,iex))
555 if (real(ene_iex_iex).ne.real(remd_ene(0,iex))) then
556 write (iout,*) "ERROR: inconsistent energies:",iex,
557 & ene_iex_iex,remd_ene(0,iex)
559 c write (iout,*) "ene_iex_iex",remd_ene(0,iex)
560 c write (iout,*) "i",i," iex",iex
561 co write (iout,'(4(a,e15.5))') "ene_i_i",ene_i_i,
562 co & " ene_i_iex",ene_i_iex,
563 co & " ene_iex_i",ene_iex_i," ene_iex_iex",ene_iex_iex
564 delta=(ene_iex_iex-ene_i_iex)/(Rb*remd_t_bath(iex))-
565 & (ene_iex_i-ene_i_i)/(Rb*remd_t_bath(i))
567 c write(iout,*) 'delta',delta
568 c delta=(remd_t_bath(i)-remd_t_bath(iex))*
569 c & (remd_ene(i)-remd_ene(iex))/Rb/
570 c & (remd_t_bath(i)*remd_t_bath(iex))
572 if (delta .gt. 50.0d0) then
578 else if (delta.lt.-50.0d0) then
587 iremd_tot(int(i2rep(i-1)))=iremd_tot(int(i2rep(i-1)))+1
588 xxx=ran_number(0.0d0,1.0d0)
589 co write(iout,'(2i4,a6,2f12.5)') i,iex,' delta',delta,xxx
590 if (delta .gt. xxx) then
592 remd_t_bath(i)=remd_t_bath(iex)
594 remd_ene(0,i)=ene_i_iex
595 remd_ene(0,iex)=ene_iex_i
601 ehighi(i)=ehighi(iex)
608 nupa(k,i)=nupa(k,iex)
611 ndowna(k,i)=ndowna(k,iex)
615 if (ifirst(il).eq.i) ifirst(il)=iex
617 if (nupa(k,il).eq.i) then
619 elseif (nupa(k,il).eq.iex) then
624 if (ndowna(k,il).eq.i) then
626 elseif (ndowna(k,il).eq.iex) then
632 iremd_acc(int(i2rep(i-1)))=iremd_acc(int(i2rep(i-1)))+1
634 i2rep(i-1)=i2rep(iex-1)
637 cd write(iout,*) 'exchange',i,iex
638 cd write (iout,'(a8,100i4)') "@ ifirst",
639 cd & (ifirst(k),k=1,remd_m(1))
641 cd write (iout,'(a8,i4,a1,100i4)') "@ nupa",il,":",
642 cd & (nupa(k,il),k=1,nupa(0,il))
643 cd write (iout,'(a8,i4,a1,100i4)') "@ ndowna",il,":",
644 cd & (ndowna(k,il),k=1,ndowna(0,il))
648 remd_ene(0,iex)=ene_iex_iex
649 remd_ene(0,i)=ene_i_i
655 c-------------------------------------
657 if(iremd_tot(i).ne.0)
658 & write(iout,'(a3,i4,2f12.5)') 'ACC',i,remd_t(i)
659 & ,iremd_acc(i)/(1.0*iremd_tot(i))
662 cd write (iout,'(a6,100i4)') "ifirst",
663 cd & (ifirst(i),i=1,remd_m(1))
665 cd write (iout,'(a5,i4,a1,100i4)') "nup",il,":",
666 cd & (nupa(i,il),i=1,nupa(0,il))
667 cd write (iout,'(a5,i4,a1,100i4)') "ndown",il,":",
668 cd & (ndowna(i,il),i=1,ndowna(0,il))
673 call mpi_scatter(remd_t_bath,1,mpi_double_precision,
674 & t_bath,1,mpi_double_precision,king,
675 & mpi_comm_world,ierr)
677 if (me.eq.king .or. .not. out1file) then
678 write(iout,*) 'REMD scatter time=',time07-time06
682 call mpi_scatter(elowi,1,mpi_double_precision,
683 & elow,1,mpi_double_precision,king,
684 & mpi_comm_world,ierr)
685 call mpi_scatter(ehighi,1,mpi_double_precision,
686 & ehigh,1,mpi_double_precision,king,
687 & mpi_comm_world,ierr)
689 call rescale_weights(t_bath)
690 co write (iout,*) "Processor",me,
691 co & " rescaling weights with temperature",t_bath
693 stdfp=dsqrt(2*Rb*t_bath/d_time)
695 stdfsc(i)=dsqrt(2*Rb*t_bath/d_time)
698 cde write(iout,*) 'REMD after',me,t_bath
700 if (me.eq.king .or. .not. out1file) then
701 write(iout,*) 'REMD exchange time=',time08-time00
707 if (restart1file) then
708 if (me.eq.king .or. .not. out1file)
709 & write(iout,*) 'writing restart at the end of run'
713 if (traj1file) call write1traj
717 if (me.eq.king .or. .not. out1file) then
718 write (iout,'(//35(1h=),a10,35(1h=)/10(/a40,1pe15.5))')
720 & 'MD calculations setup:',t_MDsetup,
721 & 'Energy & gradient evaluation:',t_enegrad,
722 & 'Stochastic MD setup:',t_langsetup,
723 & 'Stochastic MD step setup:',t_sdsetup,
725 write (iout,'(/28(1h=),a25,27(1h=))')
726 & ' End of MD calculation '
731 subroutine write1rst_
732 implicit real*8 (a-h,o-z)
736 include 'COMMON.IOUNITS'
737 include 'COMMON.REMD'
738 include 'COMMON.SETUP'
739 include 'COMMON.CHAIN'
740 include 'COMMON.SBRIDGE'
741 include 'COMMON.INTERACT'
743 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
744 & d_restart2(3,2*maxres*maxprocs)
752 t5_restart1(4)=t_bath
753 t5_restart1(5)=Uconst
755 call mpi_gather(t5_restart1,5,mpi_real,
756 & t_restart1,5,mpi_real,king,mpi_comm_world,ierr)
764 call mpi_gather(r_d,3*2*nres,mpi_real,
765 & d_restart1,3*2*nres,mpi_real,king,
766 & mpi_comm_world,ierr)
774 call mpi_gather(r_d,3*2*nres,mpi_real,
775 & d_restart2,3*2*nres,mpi_real,king,
776 & mpi_comm_world,ierr)
779 open(irest1,file=mremd_rst_name,status='unknown')
780 write (irest1,*) (i2rep(i),i=0,nodes-1)
781 write (irest1,*) (ifirst(i),i=1,remd_m(1))
783 write (irest1,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
784 write (irest1,*) ndowna(0,il),
785 & (ndowna(i,il),i=1,ndowna(0,il))
789 write(irest1,*) (t_restart1(j,il),j=1,4)
794 write(irest1,'(3e15.5)') (d_restart1(j,i+2*nres*il),j=1,3)
799 write(irest1,'(3e15.5)') (d_restart2(j,i+2*nres*il),j=1,3)
809 implicit real*8 (a-h,o-z)
813 include 'COMMON.IOUNITS'
814 include 'COMMON.REMD'
815 include 'COMMON.SETUP'
816 include 'COMMON.CHAIN'
817 include 'COMMON.SBRIDGE'
818 include 'COMMON.INTERACT'
820 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
821 & d_restart2(3,2*maxres*maxprocs)
829 t5_restart1(4)=t_bath
830 t5_restart1(5)=Uconst
832 call mpi_gather(t5_restart1,5,mpi_real,
833 & t_restart1,5,mpi_real,king,mpi_comm_world,ierr)
841 call mpi_gather(r_d,3*2*nres,mpi_real,
842 & d_restart1,3*2*nres,mpi_real,king,
843 & mpi_comm_world,ierr)
851 call mpi_gather(r_d,3*2*nres,mpi_real,
852 & d_restart2,3*2*nres,mpi_real,king,
853 & mpi_comm_world,ierr)
856 c open(irest1,file=mremd_rst_name,status='unknown')
857 call xdrfopen(ixdrf,mremd_rst_name, "w", iret)
858 c write (irest1,*) (i2rep(i),i=0,nodes-1)
860 call xdrfint(ixdrf, i2rep(i), iret)
862 c write (irest1,*) (ifirst(i),i=1,remd_m(1))
864 call xdrfint(ixdrf, ifirst(i), iret)
867 c write (irest1,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
869 call xdrfint(ixdrf, nupa(i,il), iret)
872 c write (irest1,*) ndowna(0,il),
873 c & (ndowna(i,il),i=1,ndowna(0,il))
875 call xdrfint(ixdrf, ndowna(i,il), iret)
880 c write(irest1,*) (t_restart1(j,il),j=1,4)
882 call xdrffloat(ixdrf, t_restart1(j,il), iret)
888 c write(irest1,'(3e15.5)') (d_restart1(j,i+2*nres*il),j=1,3)
890 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
896 c write(irest1,'(3e15.5)') (d_restart2(j,i+2*nres*il),j=1,3)
898 call xdrffloat(ixdrf, d_restart2(j,i+2*nres*il), iret)
903 call xdrfclose(ixdrf, iret)
910 subroutine write1traj
911 implicit real*8 (a-h,o-z)
915 include 'COMMON.IOUNITS'
916 include 'COMMON.REMD'
917 include 'COMMON.SETUP'
918 include 'COMMON.CHAIN'
919 include 'COMMON.SBRIDGE'
920 include 'COMMON.INTERACT'
924 real xcoord(3,maxres2+2),prec
925 real r_qfrag(50),r_qpair(100)
926 real p_qfrag(50*maxprocs),p_qpair(100*maxprocs)
927 real p_c(3,(maxres2+2)*maxprocs),r_c(3,maxres2+2)
929 call mpi_bcast(ii_write,1,mpi_integer,
930 & king,mpi_comm_world,ierr)
932 print *,'traj1file',me,ii_write,ntwx_cache
934 if(me.eq.king) call xdrfopen(ixdrf,cartname, "a", iret)
936 t5_restart1(1)=totT_cache(ii)
937 t5_restart1(2)=EK_cache(ii)
938 t5_restart1(3)=potE_cache(ii)
939 t5_restart1(4)=t_bath_cache(ii)
940 t5_restart1(5)=Uconst_cache(ii)
941 call mpi_gather(t5_restart1,5,mpi_real,
942 & t_restart1,5,mpi_real,king,mpi_comm_world,ierr)
945 r_qfrag(i)=qfrag_cache(i,ii)
948 r_qpair(i)=qpair_cache(i,ii)
951 call mpi_gather(r_qfrag,nfrag,mpi_real,
952 & p_qfrag,nfrag,mpi_real,king,
953 & mpi_comm_world,ierr)
954 call mpi_gather(r_qpair,npair,mpi_real,
955 & p_qpair,npair,mpi_real,king,
956 & mpi_comm_world,ierr)
960 r_c(j,i)=c_cache(j,i,ii)
964 call mpi_gather(r_c,3*2*nres,mpi_real,
965 & p_c,3*2*nres,mpi_real,king,
966 & mpi_comm_world,ierr)
971 call xdrffloat(ixdrf, real(t_restart1(1,il)), iret)
972 call xdrffloat(ixdrf, real(t_restart1(3,il)), iret)
973 call xdrffloat(ixdrf, real(t_restart1(5,il)), iret)
974 call xdrffloat(ixdrf, real(t_restart1(4,il)), iret)
975 call xdrfint(ixdrf, nss, iret)
977 call xdrfint(ixdrf, ihpb(j), iret)
978 call xdrfint(ixdrf, jhpb(j), iret)
980 call xdrfint(ixdrf, nfrag+npair, iret)
982 call xdrffloat(ixdrf, p_qfrag(i+(il-1)*nfrag), iret)
985 call xdrffloat(ixdrf, p_qpair(i+(il-1)*npair), iret)
990 xcoord(j,i)=p_c(j,i+(il-1)*nres*2)
995 xcoord(j,nres+i-nnt+1)=p_c(j,i+nres+(il-1)*nres*2)
999 call xdrf3dfcoord(ixdrf, xcoord, itmp, prec, iret)
1003 if(me.eq.king) call xdrfclose(ixdrf, iret)
1004 do i=1,ntwx_cache-ii_write
1006 totT_cache(i)=totT_cache(ii_write+i)
1007 EK_cache(i)=EK_cache(ii_write+i)
1008 potE_cache(i)=potE_cache(ii_write+i)
1009 t_bath_cache(i)=t_bath_cache(ii_write+i)
1010 Uconst_cache(i)=Uconst_cache(ii_write+i)
1013 qfrag_cache(ii,i)=qfrag_cache(ii,ii_write+i)
1016 qpair_cache(ii,i)=qpair_cache(ii,ii_write+i)
1021 c_cache(j,ii,i)=c_cache(j,ii,ii_write+i)
1025 ntwx_cache=ntwx_cache-ii_write
1030 subroutine read1restart
1031 implicit real*8 (a-h,o-z)
1032 include 'DIMENSIONS'
1035 include 'COMMON.IOUNITS'
1036 include 'COMMON.REMD'
1037 include 'COMMON.SETUP'
1038 include 'COMMON.CHAIN'
1039 include 'COMMON.SBRIDGE'
1040 include 'COMMON.INTERACT'
1041 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1045 open(irest2,file=mremd_rst_name,status='unknown')
1046 read(irest2,*,err=334) i
1047 write(iout,*) "Reading old rst in ASCI format"
1049 call read1restart_old
1052 call xdrfopen(ixdrf,mremd_rst_name, "r", iret)
1054 c read (irest2,*) (i2rep(i),i=0,nodes-1)
1056 call xdrfint(ixdrf, i2rep(i), iret)
1058 c read (irest2,*) (ifirst(i),i=1,remd_m(1))
1060 call xdrfint(ixdrf, ifirst(i), iret)
1063 c read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
1064 call xdrfint(ixdrf, nupa(0,il), iret)
1066 call xdrfint(ixdrf, nupa(i,il), iret)
1069 c read (irest2,*) ndowna(0,il),
1070 c & (ndowna(i,il),i=1,ndowna(0,il))
1071 call xdrfint(ixdrf, ndowna(0,il), iret)
1073 call xdrfint(ixdrf, ndowna(i,il), iret)
1077 c read(irest2,*) (t_restart1(j,il),j=1,4)
1079 call xdrffloat(ixdrf, t_restart1(j,il), iret)
1083 call mpi_scatter(t_restart1,5,mpi_real,
1084 & t5_restart1,5,mpi_real,king,mpi_comm_world,ierr)
1088 t_bath=t5_restart1(4)
1093 c read(irest2,'(3e15.5)')
1094 c & (d_restart1(j,i+2*nres*il),j=1,3)
1096 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1101 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1102 & r_d,3*2*nres,mpi_real,king,mpi_comm_world,ierr)
1112 c read(irest2,'(3e15.5)')
1113 c & (d_restart1(j,i+2*nres*il),j=1,3)
1115 call xdrffloat(ixdrf, d_restart1(j,i+2*nres*il), iret)
1120 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1121 & r_d,3*2*nres,mpi_real,king,mpi_comm_world,ierr)
1127 if(me.eq.king) close(irest2)
1131 subroutine read1restart_old
1132 implicit real*8 (a-h,o-z)
1133 include 'DIMENSIONS'
1136 include 'COMMON.IOUNITS'
1137 include 'COMMON.REMD'
1138 include 'COMMON.SETUP'
1139 include 'COMMON.CHAIN'
1140 include 'COMMON.SBRIDGE'
1141 include 'COMMON.INTERACT'
1142 real d_restart1(3,2*maxres*maxprocs),r_d(3,2*maxres),
1146 open(irest2,file=mremd_rst_name,status='unknown')
1147 read (irest2,*) (i2rep(i),i=0,nodes-1)
1148 read (irest2,*) (ifirst(i),i=1,remd_m(1))
1150 read (irest2,*) nupa(0,il),(nupa(i,il),i=1,nupa(0,il))
1151 read (irest2,*) ndowna(0,il),
1152 & (ndowna(i,il),i=1,ndowna(0,il))
1155 read(irest2,*) (t_restart1(j,il),j=1,4)
1158 call mpi_scatter(t_restart1,5,mpi_real,
1159 & t5_restart1,5,mpi_real,king,mpi_comm_world,ierr)
1163 t_bath=t5_restart1(4)
1168 read(irest2,'(3e15.5)')
1169 & (d_restart1(j,i+2*nres*il),j=1,3)
1173 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1174 & r_d,3*2*nres,mpi_real,king,mpi_comm_world,ierr)
1184 read(irest2,'(3e15.5)')
1185 & (d_restart1(j,i+2*nres*il),j=1,3)
1189 call mpi_scatter(d_restart1,3*2*nres,mpi_real,
1190 & r_d,3*2*nres,mpi_real,king,mpi_comm_world,ierr)
1196 if(me.eq.king) close(irest2)