2 !-----------------------------------------------------------------------------
9 !-----------------------------------------------------------------------------
12 !-----------------------------------------------------------------------------
14 !-----------------------------------------------------------------------------
16 !-----------------------------------------------------------------------------
18 !-------------------------------------------------------------------------
19 ! This subroutine contains the total lagrangain from which the accelerations
20 ! are obtained. For numerical gradient checking, the derivetive of the
21 ! lagrangian in the velocities and coordinates are calculated seperately
22 !-------------------------------------------------------------------------
23 ! implicit real*8 (a-h,o-z)
24 ! include 'DIMENSIONS'
27 use geometry_data, only: nres
28 use control_data !el, only: mucadyn,lmuca
31 real(kind=8) :: time00
33 ! include 'COMMON.VAR'
34 ! include 'COMMON.CHAIN'
35 ! include 'COMMON.DERIV'
36 ! include 'COMMON.GEO'
37 ! include 'COMMON.LOCAL'
38 ! include 'COMMON.INTERACT'
40 ! include 'COMMON.IOUNITS'
41 ! include 'COMMON.CONTROL'
42 ! include 'COMMON.MUCA'
43 ! include 'COMMON.TIME1'
44 integer ::i,j,ind,itime,mnum
45 real(kind=8) :: zapas(6*nres) !,muca_factor !maxres6=6*maxres
46 real(kind=8) :: rs(dimen),xsolv(dimen)
48 real(kind=8) :: rscheck(dimen),rsold(dimen)
50 logical :: lprn = .true.
51 !el common /cipiszcze/ itime
59 write (iout,*) "Potential forces backbone"
61 write (iout,'(i5,3e15.5,5x,3e15.5)')i,(-gcart(j,i),j=1,3)
63 write (iout,*) "Potential forces sidechain"
65 if (itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) &
66 write (iout,'(i5,3e15.5,5x,3e15.5)') i,(-gxcart(j,i),j=1,3)
72 if (itype(i,1).eq.10 .or. itype(i,1).eq.ntyp1)then
73 rs(ind)=-gcart(j,i)-gxcart(j,i)
77 rs(ind+1)=-gxcart(j,i)
85 write(iout,*) "RHS of the 5-diag equations system"
91 call FDISYS (dimen,DM,DU1,DU2,rs,xsolv)
93 write (iout,*) "Solution of the 5-diagonal equations system"
95 write (iout,'(i5,f10.5)') i,xsolv(i)
100 rscheck(1)=DMorig(1)*xsolv(1)+DU1orig(1)*xsolv(2)+&
102 rscheck(2)=DU1orig(1)*xsolv(1)+DMorig(2)*xsolv(2)+&
103 DU1orig(2)*xsolv(3)+DU2orig(2)*xsolv(4)
106 rscheck(i)=DU2orig(i-2)*xsolv(i-2)+DU1orig(i-1)*&
107 xsolv(i-1)+DMorig(i)*xsolv(i)+DU1orig(i)*&
108 xsolv(i+1)+DU2orig(i)*xsolv(i+2)
110 rscheck(dimen-1)=DU2orig(dimen-3)*xsolv(dimen-3)+&
111 DU1orig(dimen-2)*xsolv(dimen-2)+DMorig(dimen-1)*&
112 xsolv(dimen-1)+DU1orig(dimen-1)*&
114 rscheck(dimen)=DU2orig(dimen-2)*xsolv(dimen-2)+DU1orig(dimen-1)*&
115 xsolv(dimen-1)+DMorig(dimen)*xsolv(dimen)
118 write(iout,*) "i",i,"rsold",rsold(i),"rscheck",rscheck(i),&
119 "ratio",rscheck(i)/rsold(i)
126 if (itype(i,1).eq.10 .or. itype(i,mnum).eq.ntyp1_molec(mnum))then
131 d_a(j,i+nres)=xsolv(ind+1)
138 write (iout,'(i3,3f10.5)') i,(d_a(j,i),j=1,3)
141 write (iout,'(i3,3f10.5)') i,(d_a(j,i+nres),j=1,3)
149 ! if (itype(i,1).eq.10 .or. itype(i,1).eq.ntyp1) then
150 if (itype(i,1).eq.10 .or. itype(i,mnum).eq.ntyp1_molec(mnum))then
152 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
156 d_a(j,i+nres)=d_a(j,i+nres)-d_a(j,i)
157 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
165 write(iout,*) 'acceleration 3D FIVEDIAG'
166 write (iout,'(i3,3f10.5,3x,3f10.5)') 0,(d_a(j,0),j=1,3)
168 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3)
171 write (iout,'(i3,3f10.5,3x,3f10.5)') &
172 i+nres,(d_a(j,i+nres),j=1,3)
182 write (iout,*) "Potential forces backbone"
185 if (lprn) write (iout,'(i5,3e15.5,5x,3e15.5)') &
186 i,(-gcart(j,i),j=1,3)
189 zapas(ind)=-gcart(j,i)
192 if (lprn) write (iout,*) "Potential forces sidechain"
195 if (itype(i,1).ne.10 .and. itype(i,mnum).ne.ntyp1_molec(mnum)) then
196 if (lprn) write (iout,'(i5,3e15.5,5x,3e15.5)') &
197 i,(-gxcart(j,i),j=1,3)
200 zapas(ind)=-gxcart(j,i)
205 call ginv_mult(zapas,d_a_work)
214 d_a(j,i)=d_a_work(ind)
219 ! if (itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
220 if (itype(i,1).ne.10 .and. itype(i,mnum).ne.ntyp1_molec(mnum)) then
223 d_a(j,i+nres)=d_a_work(ind)
231 if(mucadyn.gt.0) call muca_update(potE)
232 factor=muca_factor(potE)*t_bath*Rb
234 !d print *,'lmuca ',factor,potE
236 d_a(j,0)=d_a(j,0)*factor
240 d_a(j,i)=d_a(j,i)*factor
245 d_a(j,i+nres)=d_a(j,i+nres)*factor
252 write(iout,*) 'acceleration 3D'
253 write (iout,'(i3,3f10.5,3x,3f10.5)') 0,(d_a(j,0),j=1,3)
255 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3)
258 write (iout,'(i3,3f10.5,3x,3f10.5)') &
259 i+nres,(d_a(j,i+nres),j=1,3)
263 time_lagrangian=time_lagrangian+MPI_Wtime()-time00
266 end subroutine lagrangian
267 !-----------------------------------------------------------------------------
268 subroutine setup_MD_matrices
270 use geometry_data, only: nres,nside
274 use geometry, only:int_bounds
276 ! implicit real*8 (a-h,o-z)
277 ! include 'DIMENSIONS'
281 real(kind=8) :: time00
282 real(kind=8) ,allocatable, dimension(:) :: DDM,DDU1,DDU2
284 ! include 'COMMON.SETUP'
285 ! include 'COMMON.VAR'
286 ! include 'COMMON.CHAIN'
287 ! include 'COMMON.DERIV'
288 ! include 'COMMON.GEO'
289 ! include 'COMMON.LOCAL'
290 ! include 'COMMON.INTERACT'
291 ! include 'COMMON.MD'
293 ! include 'COMMON.LANGEVIN'
295 ! include 'COMMON.LANGEVIN.lang0'
297 ! include 'COMMON.IOUNITS'
298 ! include 'COMMON.TIME1'
299 logical :: lprn = .true.
302 real(kind=8),dimension(2*nres,2*nres) :: Bmat,matmult
305 real(kind=8),dimension(2*nres) :: massvec,sqreig !(maxres2) maxres2=2*maxres
306 real(kind=8) :: relfeh,eps1,eps2
307 !el real(kind=8),dimension(:),allocatable :: Ghalf
308 !el real(kind=8),dimension(2*nres*(2*nres+1)/2) :: Ghalf !(mmaxres2) (mmaxres2=(maxres2*(maxres2+1)/2))
309 !el real(kind=8),dimension(2*nres,2*nres) :: Gcopy !(maxres2,maxres2)
310 !el real(kind=8),dimension(:,:),allocatable :: Gcopy
311 real(kind=8),dimension(8*6*nres) :: work !(8*maxres6)
312 integer,dimension(6*nres) :: iwork !(maxres6) maxres6=6*maxres
313 !el common /przechowalnia/ Gcopy,Ghalf
314 real(kind=8) :: coeff
315 integer :: i,j,ind,ind1,k,l,ii,jj,m,m1,ii1,iti,nres2,ierr,nind,mark
321 write (iout,*) "before FIVEDIAG"
323 write (iout,*) "ALLOCATE"
324 if(.not.allocated(Gcopy)) allocate(Gcopy(nres2,nres2)) !(maxres2,maxres2)
325 if(.not.allocated(Ghalf)) allocate(Ghalf(nres2*(nres2+1)/2)) !mmaxres2=(maxres2*(maxres+1)/2)
328 ! Set up the matrix of the (dC,dX)-->(C,X) transformation (A), the
329 ! inertia matrix (Gmat) and the inverse of the inertia matrix (Ginv)
331 ! Determine the number of degrees of freedom (dimen) and the number of
333 dimen=(nct-nnt+1)+nside
334 dimen1=(nct-nnt)+(nct-nnt+1)
336 write (iout,*) "nnt",nnt," nct",nct," nside",nside
340 if (iabs(itype(nnt)).eq.10) then
345 DM(1)=DM(1)+isc(iabs(itype(nnt)))
346 DM(2)=msc(iabs(itype(nnt)))+isc(iabs(itype(nnt)))
351 ! if (iabs(itype(i,1)).eq.ntyp1) cycle
353 if (iabs(itype(i,1)).eq.10 .or. iabs(itype(i,1)).eq.ntyp1) then
354 if (iabs(itype(i,1)).eq.10) DM(ind)=DM(ind)+msc(10)
357 DM(ind)=DM(ind)+isc(iabs(itype(i,1)))
358 DM(ind+1)=msc(iabs(itype(i,1)))+isc(iabs(itype(i,1)))
364 if (iabs(itype(nct)).eq.10) then
365 DM(ind)=DM(ind)+msc(10)
368 DM(ind)=DM(ind)+isc(iabs(itype(nct)))
369 DM(ind+1)=msc(iabs(itype(nct)))+isc(iabs(itype(nct)))
377 if (iabs(itype(i,1)).ne.10 .and.iabs(itype((i))).ne.ntyp1) then
378 DU1(ind)=-isc(iabs(itype(i,1)))
390 ! if (iabs(itype(i,1)).eq.ntyp1) cycle
391 write (iout,*) "i",i," itype",itype(i,1),ntyp1
392 if (iabs(itype(i,1)).ne.10 .and. &
393 iabs(itype(i,mnum)).ne.ntyp1_molec(mnum) .and. mnum.ne.5) then
406 write (iout,*) "nind",nind," dimen",dimen
407 if (nind.ne.dimen) then
408 write (iout,*) "ERROR, dimensions differ"
410 call MPI_Finalize(ierr)
414 write (iout,*) "The upper part of the five-diagonal inertia matrix"
416 if (i.lt.dimen-1) then
417 write (iout,'(i3,3f10.5)') i,DM(i),DU1(i),DU2(i)
418 else if (i.eq.dimen-1) then
419 write (iout,'(i3,3f10.5)') i,DM(i),DU1(i)
421 write (iout,'(i3,3f10.5)') i,DM(i)
425 call FDISYP (dimen, DM, DU1, DU2, MARK)
428 write (iout,*) "ERROR: the inertia matrix is not positive definite"
430 call MPI_Finalize(ierr)
433 else if (mark.eq.0) then
434 write (iout,*) "ERROR: the inertia matrix is singular"
436 call MPI_Finalize(ierr)
438 else if (mark.eq.1) then
439 write (iout,*) "The transformed inertia matrix"
441 if (i.lt.dimen-1) then
442 write (iout,'(i3,3f10.5)') i,DM(i),DU1(i),DU2(i)
443 else if (i.eq.dimen-1) then
444 write (iout,'(i3,3f10.5)') i,DM(i),DU1(i)
446 write (iout,'(i3,3f10.5)') i,DM(i)
450 ! Diagonalization of the pentadiagonal matrix
451 allocate(DDU1(2*nres))
452 allocate(DDU2(2*nres))
453 allocate(DDM(2*nres))
461 call quindibisect2(DDM,DDU1,DDU2,dimen,1,dimen,eps1,relfeh,eps2,iz,geigen)
464 "Eigenvalues of the five-diagonal inertia matrix"
466 write (iout,'(i5,f10.5)') i,geigen(i)
475 if (nfgtasks.gt.1) then
477 call MPI_Bcast(5,1,MPI_INTEGER,king,FG_COMM,IERROR)
478 time_Bcast=time_Bcast+MPI_Wtime()-time00
479 call int_bounds(dimen,igmult_start,igmult_end)
480 igmult_start=igmult_start-1
481 call MPI_Allgather(3*igmult_start,1,MPI_INTEGER,&
482 ng_start(0),1,MPI_INTEGER,FG_COMM,IERROR)
483 my_ng_count=igmult_end-igmult_start
484 call MPI_Allgather(3*my_ng_count,1,MPI_INTEGER,ng_counts(0),1,&
485 MPI_INTEGER,FG_COMM,IERROR)
486 write (iout,*) 'Processor:',fg_rank,' CG group',kolor,&
487 ' absolute rank',myrank,' igmult_start',igmult_start,&
488 ' igmult_end',igmult_end,' count',my_ng_count
489 write (iout,*) "ng_start",(ng_start(i),i=0,nfgtasks-1)
490 write (iout,*) "ng_counts",(ng_counts(i),i=0,nfgtasks-1)
500 ! write (iout,*) "dimen",dimen," dimen1",dimen1," dimen3",dimen3
501 ! Zeroing out A and fricmat
507 ! Diagonal elements of the dC part of A and the respective friction coefficients
510 print *,"TUTUTUT?!",nnt,nct-1
515 coeff=0.25d0*IP(mnum)
516 massvec(ind1)=mp(mnum)
522 ! Off-diagonal elements of the dC part of A
529 ! Diagonal elements of the dX part of A and the respective friction coefficients
535 msc(ntyp1_molec(i),i)=1.0d0
542 massvec(ii)=msc(iabs(iti),mnum)
543 if (iti.ne.10 .and. iti.ne.ntyp1_molec(mnum) .and. mnum.ne.5) then
547 Gmat(ii1,ii1)=ISC(iabs(iti),mnum)
550 ! Off-diagonal elements of the dX part of A
564 write (iout,*) "Vector massvec"
566 write (iout,*) i,massvec(i)
568 write (iout,'(//a)') "A"
569 call matout(dimen,dimen1,nres2,nres2,A)
572 ! Calculate the G matrix (store in Gmat)
577 dtdi=dtdi+A(j,k)*A(j,i)*massvec(j)
579 Gmat(k,i)=Gmat(k,i)+dtdi
584 write (iout,'(//a)') "Gmat"
585 call matout(dimen,dimen,nres2,nres2,Gmat)
594 ! Invert the G matrix
595 call MATINVERT(dimen,nres2,Gcopy,Ginv,osob)
597 write (iout,'(//a)') "Ginv"
598 call matout(dimen,dimen,nres2,nres2,Ginv)
606 if ((itype(i,1).eq.10).or.(itype(i,mnum).eq.ntyp1_molec(mnum))&
607 .or.(mnum.eq.5)) then
615 Bmat(i-nnt+1+(nct-nnt)+1,j-1)=-1
616 Bmat(i-nnt+1+(nct-nnt)+1,j)=1
619 Bmat(i-nnt+1+(nct-nnt)+1,j-1)=-1
620 Bmat(i-nnt+1+(nct-nnt)+1,j)=1
624 write (iout,*) "j",j," dimen",dimen
626 write (iout,'(//a)') "Bmat"
627 call matout(dimen,dimen,nres2,nres2,Bmat)
634 Gcopy(i,j)=Gcopy(i,j)+Bmat(k,i)*Gmat(k,l)*Bmat(l,j)
640 write (iout,'(//a)') "Gmat-transformed"
641 call matout(dimen,dimen,nres2,nres2,Gcopy)
644 if (nfgtasks.gt.1) then
645 myginv_ng_count=nres2*my_ng_count
646 call MPI_Allgather(nres2*igmult_start,1,MPI_INTEGER,&
647 nginv_start(0),1,MPI_INTEGER,FG_COMM,IERROR)
648 call MPI_Allgather(myginv_ng_count,1,MPI_INTEGER,&
649 nginv_counts(0),1,MPI_INTEGER,FG_COMM,IERROR)
650 write (iout,*) "nginv_start",(nginv_start(i),i=0,nfgtasks-1)
651 write (iout,*) "nginv_counts",(nginv_counts(i),i=0,nfgtasks-1)
653 ! call MPI_Scatterv(ginv(1,1),nginv_counts(0),
654 ! & nginv_start(0),MPI_DOUBLE_PRECISION,ginv,
655 ! & myginv_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
656 ! call MPI_Barrier(FG_COMM,IERR)
658 call MPI_Scatterv(ginv(1,1),nginv_counts(0),&
659 nginv_start(0),MPI_DOUBLE_PRECISION,gcopy(1,1),&
660 myginv_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
662 time_scatter_ginv=time_scatter_ginv+MPI_Wtime()-time00
669 ! write (iout,*) "Master's chunk of ginv"
670 ! call MATOUT2(my_ng_count,dimen,maxres2,maxres2,ginv)
674 write (iout,*) "The G matrix is singular."
677 ! Compute G**(-1/2) and G**(1/2)
685 call gldiag(nres2,dimen,dimen,Ghalf,work,Geigen,Gvec,&
688 write (iout,'(//a)') &
689 "Eigenvectors and eigenvalues of the G matrix"
690 call eigout(dimen,dimen,nres2,nres2,Gvec,Geigen)
693 sqreig(i)=dsqrt(Geigen(i))
701 Gsqrp(i,j)=Gsqrp(i,j)+Gvec(i,k)*Gvec(j,k)*sqreig(k)
702 Gsqrm(i,j)=Gsqrm(i,j)+Gvec(i,k)*Gvec(j,k)/sqreig(k)
703 Gcopy(i,j)=Gcopy(i,j)+Gvec(i,k)*Gvec(j,k)*Geigen(k)
708 write (iout,*) "Comparison of original and restored G"
711 write (iout,'(2i5,5f10.5)') i,j,Gmat(i,j),Gcopy(i,j),&
712 Gmat(i,j)-Gcopy(i,j),Gsqrp(i,j),Gsqrm(i,j)
719 end subroutine setup_MD_matrices
720 !-----------------------------------------------------------------------------
721 subroutine EIGOUT(NC,NR,LM2,LM3,A,B)
723 ! implicit real*8 (a-h,o-z)
724 ! include 'DIMENSIONS'
725 ! include 'COMMON.IOUNITS'
726 integer :: LM2,LM3,NC,NR,KA,KC,KB,I,J,N
727 real(kind=8) :: A(LM2,LM3),B(LM2)
731 WRITE(IOUT,600) (I,I=KA,KB)
732 WRITE(IOUT,601) (B(I),I=KA,KB)
736 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
742 4 IF (KB.EQ.NC) RETURN
746 600 FORMAT (// 9H ROOT NO.,I4,9I11)
747 601 FORMAT (/5X,10(1PE11.4))
749 603 FORMAT (I5,10F11.5)
751 end subroutine EIGOUT
752 !-----------------------------------------------------------------------------
753 subroutine MATOUT(NC,NR,LM2,LM3,A)
755 ! implicit real*8 (a-h,o-z)
756 ! include 'DIMENSIONS'
757 ! include 'COMMON.IOUNITS'
758 integer :: LM2,LM3,NC,NR,KA,KC,KB,I,J,N
759 real(kind=8) :: A(LM2,LM3)
763 WRITE(IOUT,600) (I,I=KA,KB)
767 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
773 4 IF (KB.EQ.NC) RETURN
777 600 FORMAT (//5x,9I11)
779 603 FORMAT (I5,10F11.3)
781 end subroutine MATOUT
782 !-----------------------------------------------------------------------------
783 subroutine MATOUT1(NC,NR,LM2,LM3,A)
785 ! implicit real*8 (a-h,o-z)
786 ! include 'DIMENSIONS'
787 ! include 'COMMON.IOUNITS'
788 integer :: LM2,LM3,NC,NR,KA,KC,KB,I,J,N
789 real(kind=8) :: A(LM2,LM3)
793 WRITE(IOUT,600) (I,I=KA,KB)
797 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
803 4 IF (KB.EQ.NC) RETURN
807 600 FORMAT (//5x,7(3I5,2x))
809 603 FORMAT (I5,7(3F5.1,2x))
811 end subroutine MATOUT1
812 !-----------------------------------------------------------------------------
813 subroutine MATOUT2(NC,NR,LM2,LM3,A)
815 ! implicit real*8 (a-h,o-z)
816 ! include 'DIMENSIONS'
817 ! include 'COMMON.IOUNITS'
818 integer :: I,J,KA,KC,KB,N
819 integer :: LM2,LM3,NC,NR
820 real(kind=8) :: A(LM2,LM3)
824 WRITE(IOUT,600) (I,I=KA,KB)
828 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
834 4 IF (KB.EQ.NC) RETURN
838 600 FORMAT (//5x,4(3I9,2x))
840 603 FORMAT (I5,4(3F9.3,2x))
842 end subroutine MATOUT2
843 !-----------------------------------------------------------------------------
844 subroutine ginv_mult(z,d_a_tmp)
846 use geometry_data, only: nres
849 ! implicit real*8 (a-h,o-z)
850 ! include 'DIMENSIONS'
853 integer :: ierr,ierror
855 ! include 'COMMON.SETUP'
856 ! include 'COMMON.TIME1'
857 ! include 'COMMON.MD'
858 real(kind=8),dimension(dimen3) :: z,z1,d_a_tmp
859 real(kind=8),dimension(6*nres) :: temp !(maxres6) maxres6=6*maxres
860 real(kind=8) :: time00,time01
863 if (nfgtasks.gt.1) then
864 if (fg_rank.eq.0) then
865 ! The matching BROADCAST for fg processors is called in ERGASTULUM
867 call MPI_Bcast(4,1,MPI_INTEGER,king,FG_COMM,IERROR)
868 time_Bcast=time_Bcast+MPI_Wtime()-time00
869 ! print *,"Processor",myrank," BROADCAST iorder in GINV_MULT"
871 ! write (2,*) "time00",time00
872 ! write (2,*) "Before Scatterv"
874 ! write (2,*) "Whole z (for FG master)"
878 ! call MPI_Barrier(FG_COMM,IERROR)
880 !elwrite(iout,*) "do tej pory jest OK, MPI_Scatterv w ginv_mult"
881 call MPI_Scatterv(z,ng_counts(0),ng_start(0),&
882 MPI_DOUBLE_PRECISION,&
883 z1,3*my_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
884 ! write (2,*) "My chunk of z"
885 ! do i=1,3*my_ng_count
888 ! write (2,*) "After SCATTERV"
890 ! write (2,*) "MPI_Wtime",MPI_Wtime()
891 time_scatter=time_scatter+MPI_Wtime()-time00
893 time_scatter_ginvmult=time_scatter_ginvmult+MPI_Wtime()-time00
895 ! write (2,*) "time_scatter",time_scatter
896 ! write (2,*) "dimen",dimen," dimen3",dimen3," my_ng_count",
905 ! write (2,*) "k,i,j,ind",k,i,j,ind,(j-1)*3+k+1,
906 ! & Ginv(i,j),z((j-1)*3+k+1),
907 ! & Ginv(i,j)*z((j-1)*3+k+1)
908 ! temp(ind)=temp(ind)+Ginv(i,j)*z((j-1)*3+k+1)
909 temp(ind)=temp(ind)+Ginv(j,i)*z1((j-1)*3+k+1)
913 time_ginvmult=time_ginvmult+MPI_Wtime()-time01
914 ! write (2,*) "Before REDUCE"
916 ! write (2,*) "z before reduce"
918 ! write (2,*) i,temp(i)
921 call MPI_Reduce(temp(1),d_a_tmp(1),dimen3,MPI_DOUBLE_PRECISION,&
922 MPI_SUM,king,FG_COMM,IERR)
923 time_reduce=time_reduce+MPI_Wtime()-time00
924 ! write (2,*) "After REDUCE"
936 ! write (2,*) "k,i,j,ind",k,i,j,ind,(j-1)*3+k+1
938 ! & Ginv(i,j),z((j-1)*3+k+1),
939 ! & Ginv(i,j)*z((j-1)*3+k+1)
940 d_a_tmp(ind)=d_a_tmp(ind) &
941 +Ginv(j,i)*z((j-1)*3+k+1)
942 ! d_a_tmp(ind)=d_a_tmp(ind)
943 ! & +Ginv(i,j)*z((j-1)*3+k+1)
948 time_ginvmult=time_ginvmult+MPI_Wtime()-time01
954 end subroutine ginv_mult
955 !-----------------------------------------------------------------------------
957 subroutine ginv_mult_test(z,d_a_tmp)
959 ! include 'DIMENSIONS'
961 ! include 'COMMON.MD'
962 real(kind=8),dimension(dimen) :: z,d_a_tmp
963 real(kind=8),dimension(dimen/3) :: ztmp,dtmp
968 ! d_a_tmp(i)=d_a_tmp(i)+Ginv(i,j)*z(j)
977 ztmp(j)=z((j-1)*3+k+1)
980 call alignx(16,ztmp(1))
981 call alignx(16,dtmp(1))
982 call alignx(16,Ginv(1,1))
987 dtmp(i)=dtmp(i)+Ginv(i,j)*ztmp(j)
996 end subroutine ginv_mult_test
998 !-----------------------------------------------------------------------------
999 subroutine fricmat_mult(z,d_a_tmp)
1001 use geometry_data, only: nres
1004 ! include 'DIMENSIONS'
1007 integer :: IERROR,ierr
1009 ! include 'COMMON.MD'
1010 ! include 'COMMON.IOUNITS'
1011 ! include 'COMMON.SETUP'
1012 ! include 'COMMON.TIME1'
1014 ! include 'COMMON.LANGEVIN'
1016 ! include 'COMMON.LANGEVIN.lang0'
1018 real(kind=8),dimension(dimen3) :: z,z1,d_a_tmp
1019 real(kind=8),dimension(6*nres) :: temp !(maxres6) maxres6=6*maxres
1020 real(kind=8) :: time00,time01
1021 integer :: i,j,k,ind,nres2
1023 !el if(.not.allocated(fricmat)) allocate(fricmat(nres2,nres2))
1026 if (nfgtasks.gt.1) then
1027 if (fg_rank.eq.0) then
1028 ! The matching BROADCAST for fg processors is called in ERGASTULUM
1030 call MPI_Bcast(9,1,MPI_INTEGER,king,FG_COMM,IERROR)
1031 time_Bcast=time_Bcast+MPI_Wtime()-time00
1032 ! print *,"Processor",myrank," BROADCAST iorder in FRICMAT_MULT"
1034 ! call MPI_Barrier(FG_COMM,IERROR)
1036 call MPI_Scatterv(z,ng_counts(0),ng_start(0),&
1037 MPI_DOUBLE_PRECISION,&
1038 z1,3*my_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
1039 ! write (2,*) "My chunk of z"
1040 ! do i=1,3*my_ng_count
1041 ! write (2,*) i,z(i)
1043 time_scatter=time_scatter+MPI_Wtime()-time00
1045 time_scatter_fmatmult=time_scatter_fmatmult+MPI_Wtime()-time00
1053 temp(ind)=temp(ind)-fricmat(j,i)*z1((j-1)*3+k+1)
1057 time_fricmatmult=time_fricmatmult+MPI_Wtime()-time01
1058 ! write (2,*) "Before REDUCE"
1059 ! write (2,*) "d_a_tmp before reduce"
1061 ! write (2,*) i,temp(i)
1065 call MPI_Reduce(temp(1),d_a_tmp(1),dimen3,MPI_DOUBLE_PRECISION,&
1066 MPI_SUM,king,FG_COMM,IERR)
1067 time_reduce=time_reduce+MPI_Wtime()-time00
1068 ! write (2,*) "After REDUCE"
1080 d_a_tmp(ind)=d_a_tmp(ind) &
1081 -fricmat(j,i)*z((j-1)*3+k+1)
1086 time_fricmatmult=time_fricmatmult+MPI_Wtime()-time01
1091 ! write (iout,*) "Vector d_a"
1093 ! write (2,*) i,d_a_tmp(i)
1096 end subroutine fricmat_mult
1097 !-----------------------------------------------------------------------------
1098 !-----------------------------------------------------------------------------