2 c-------------------------------------------------------------------------
3 c This subroutine contains the total lagrangain from which the accelerations
4 c are obtained. For numerical gradient checking, the derivetive of the
5 c lagrangian in the velocities and coordinates are calculated seperately
6 c-------------------------------------------------------------------------
14 include 'COMMON.CHAIN'
15 include 'COMMON.DERIV'
17 include 'COMMON.LOCAL'
18 include 'COMMON.INTERACT'
21 include 'COMMON.LAGRANGE.5diag'
23 include 'COMMON.LAGRANGE'
27 include 'COMMON.LANGEVIN.lang0.5diag'
29 include 'COMMON.LANGEVIN.lang0'
32 include 'COMMON.LANGEVIN'
34 include 'COMMON.IOUNITS'
35 include 'COMMON.CONTROL'
37 include 'COMMON.TIME1'
40 double precision zapas(MAXRES6),muca_factor
41 logical lprn /.false./
43 common /cipiszcze/ itime
45 double precision rs(maxres2_chain),xsolv(maxres2_chain),ip4
46 double precision aaux(3)
47 integer nind,innt,inct,inct_prev,ichain,n,mark
49 double precision rscheck(maxres2_chain),rsold(maxres2_chain)
60 write (iout,*) "Potential forces backbone"
62 write (iout,'(i5,3e15.5,5x,3e15.5)')i,(-gcart(j,i),j=1,3)
64 write (iout,*) "Potential forces sidechain"
66 ! if (itype(i).ne.10 .and. itype(i).ne.ntyp1) &
67 write (iout,'(i5,3e15.5,5x,3e15.5)') i,(-gxcart(j,i),j=1,3)
72 innt=iposd_chain(ichain)
75 do i=chain_border(1,ichain),chain_border(2,ichain)
76 if (itype(i).eq.10)then
77 rs(ind)=-gcart(j,i)-gxcart(j,i)
81 rs(ind+1)=-gxcart(j,i)
90 & "RHS of the 5-diag equations system, chain",ichain," j",j
92 write(iout,'(i5,f10.5)') i,rs(i)
95 call FDISYS (n,DM(innt),DU1(innt),DU2(innt),rs,xsolv)
97 write (iout,*) "Solution of the 5-diagonal equations system"
99 write (iout,'(i5,f10.5)') i,xsolv(i)
104 call fivediagmult(n,DMorig(innt),DU1orig(innt),DU2orig(innt),
107 write(iout,*) "i",i,"rsold",rsold(i),"rscheck",rscheck(i),
108 & "ratio",rscheck(i)/rsold(i)
114 do i=chain_border(1,ichain),chain_border(2,ichain)
115 if (itype(i).eq.10) then
120 d_a(j,i+nres)=xsolv(ind+1)
127 write (iout,*) "Acceleration in CA and SC oordinates"
129 write (iout,'(i3,3f10.5)') i,(d_a(j,i),j=1,3)
132 write (iout,'(i3,3f10.5)') i,(d_a(j,i+nres),j=1,3)
135 C Conevert d_a to virtual-bon-vector basis
138 c write (iout,*) "WLOS"
143 if (itype(i).eq.10 .or. itype(i).eq.ntyp1) then
145 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
149 d_a(j,i+nres)=d_a(j,i+nres)-d_a(j,i)
150 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
159 c write (iout,*) "Shifting accelerations"
165 c write (iout,*) "ichain",chain_border1(1,ichain)-1,
166 c & chain_border1(1,ichain)
167 d_a(:,chain_border1(1,ichain)-1)=d_a(:,chain_border1(1,ichain))
168 d_a(:,chain_border1(1,ichain))=0.0d0
170 c write (iout,*) "Adding accelerations"
172 c write (iout,*) "chain",ichain,chain_border1(1,ichain)-1,
173 c & chain_border(2,ichain-1)
174 d_a(:,chain_border1(1,ichain)-1)=
175 & d_a(:,chain_border1(1,ichain)-1)+d_a(:,chain_border(2,ichain-1))
176 d_a(:,chain_border(2,ichain-1))=0.0d0
184 innt=chain_border(1,ichain)
185 inct=chain_border(2,ichain)
187 d_a(j,inct_prev)=d_a(j,innt)-aaux(j)
192 if (itype(i).eq.10 .or. itype(i).eq.ntyp1) then
194 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
198 d_a(j,i+nres)=d_a(j,i+nres)-d_a(j,i)
199 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
205 if (itype(i).ne.10) then
207 d_a(j,i+nres)=d_a(j,i+nres)-d_a(j,i)
216 d_a(j,i)=d_a(j,i+1)-d_a(j,i)
223 write(iout,*) 'acceleration 3D FIVEDIAG in dC and dX'
225 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3)
228 write (iout,'(i3,3f10.5,3x,3f10.5)')
229 & i+nres,(d_a(j,i+nres),j=1,3)
238 write (iout,*) "Potential forces backbone"
241 if (lprn) write (iout,'(i5,3e15.5,5x,3e15.5)')
242 & i,(-gcart(j,i),j=1,3)
245 zapas(ind)=-gcart(j,i)
248 if (lprn) write (iout,*) "Potential forces sidechain"
250 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
251 if (lprn) write (iout,'(i5,3e15.5,5x,3e15.5)')
252 & i,(-gcart(j,i),j=1,3)
255 zapas(ind)=-gxcart(j,i)
260 call ginv_mult(zapas,d_a_work)
269 d_a(j,i)=d_a_work(ind)
273 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
276 d_a(j,i+nres)=d_a_work(ind)
283 if(mucadyn.gt.0) call muca_update(potE)
284 factor=muca_factor(potE)*t_bath*Rb
286 cd print *,'lmuca ',factor,potE
288 d_a(j,0)=d_a(j,0)*factor
292 d_a(j,i)=d_a(j,i)*factor
297 d_a(j,i+nres)=d_a(j,i+nres)*factor
304 write(iout,*) 'acceleration 3D'
305 write (iout,'(i3,3f10.5,3x,3f10.5)') 0,(d_a(j,0),j=1,3)
307 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_a(j,i),j=1,3)
310 write (iout,'(i3,3f10.5,3x,3f10.5)')
311 & i+nres,(d_a(j,i+nres),j=1,3)
316 time_lagrangian=time_lagrangian+MPI_Wtime()-time00
320 c------------------------------------------------------------------
321 subroutine setup_MD_matrices
327 double precision time00
329 include 'COMMON.CONTROL'
330 include 'COMMON.SETUP'
332 include 'COMMON.CHAIN'
333 include 'COMMON.DERIV'
335 include 'COMMON.LOCAL'
336 include 'COMMON.INTERACT'
339 include 'COMMON.LAGRANGE.5diag'
341 include 'COMMON.LAGRANGE'
344 include 'COMMON.LANGEVIN'
347 include 'COMMON.LANGEVIN.lang0.5diag'
349 include 'COMMON.LANGEVIN.lang0'
352 include 'COMMON.IOUNITS'
353 include 'COMMON.TIME1'
354 integer i,j,k,m,m1,ind,ind1,ii,iti,ii1,jj
355 double precision coeff
356 logical lprn /.false./
358 double precision dtdi,massvec(maxres2)
360 integer ichain,innt,inct,nind,mark,n
363 double precision Gcopy(maxres2,maxres2),Ghalf(mmaxres2),
365 double precision work(8*maxres6)
366 integer iwork(maxres6)
367 common /przechowalnia/ Gcopy,Ghalf
370 c Set up the matrix of the (dC,dX)-->(C,X) transformation (A), the
371 c inertia matrix (Gmat) and the inverse of the inertia matrix (Ginv)
373 c Determine the number of degrees of freedom (dimen) and the number of
379 dimen=dimen+chain_length(ichain)
380 dimen1=dimen1+2*chain_length(ichain)-1
381 dimenp=dimenp+chain_length(ichain)-1
383 write (iout,*) "Number of Calphas",dimen
384 write (iout,*) "Number of sidechains",nside
385 write (iout,*) "Number of peptide groups",dimenp
386 dimen=dimen+nside ! number of centers
387 dimen3=3*dimen ! degrees of freedom
388 write (iout,*) "Number of centers",dimen
389 write (iout,*) "Degrees of freedom:",dimen3
393 iposd_chain(ichain)=ind
394 innt=chain_border(1,ichain)
395 inct=chain_border(2,ichain)
397 if (iabs(itype(innt)).eq.10) then
398 DM(ind)=DM(ind)+msc(10)
402 DM(ind)=DM(ind)+isc(iabs(itype(innt)))
403 DM(ind+1)=msc(iabs(itype(innt)))+isc(iabs(itype(innt)))
407 write (iout,*) "ind",ind," nind",nind
409 ! if (iabs(itype(i)).eq.ntyp1) cycle
411 if (iabs(itype(i)).eq.10) then
412 if (iabs(itype(i)).eq.10) DM(ind)=DM(ind)+msc(10)
416 DM(ind)=DM(ind)+isc(iabs(itype(i)))
417 DM(ind+1)=msc(iabs(itype(i)))+isc(iabs(itype(i)))
421 write (iout,*) "i",i," ind",ind," nind",nind
423 if (inct.gt.innt) then
425 if (iabs(itype(inct)).eq.10) then
426 DM(ind)=DM(ind)+msc(10)
430 DM(ind)=DM(ind)+isc(iabs(itype(inct)))
431 DM(ind+1)=msc(iabs(itype(inct)))+isc(iabs(itype(inct)))
436 write (iout,*) "ind",ind," nind",nind
437 dimen_chain(ichain)=nind
441 ind=iposd_chain(ichain)
442 innt=chain_border(1,ichain)
443 inct=chain_border(2,ichain)
445 if (iabs(itype(i)).ne.10 .and.iabs(itype((i))).ne.ntyp1) then
446 DU1(ind)=-isc(iabs(itype(i)))
457 ind=iposd_chain(ichain)
458 innt=chain_border(1,ichain)
459 inct=chain_border(2,ichain)
461 ! if (iabs(itype(i)).eq.ntyp1) cycle
462 c write (iout,*) "i",i," itype",itype(i),ntyp1
463 if (iabs(itype(i)).ne.10 .and. iabs(itype(i)).ne.ntyp1) then
478 write (iout,*)"The upper part of the five-diagonal inertia matrix"
481 if (gmatout) write (iout,'(a,i5)') 'Chain',ichain
482 n=dimen_chain(ichain)
483 innt=iposd_chain(ichain)
484 inct=iposd_chain(ichain)+dimen_chain(ichain)-1
487 if (i.lt.inct-1) then
488 write (iout,'(2i3,3f10.5)') i,i-innt+1,DM(i),DU1(i),DU2(i)
489 else if (i.eq.inct-1) then
490 write (iout,'(2i3,3f10.5)') i,i-innt+1,DM(i),DU1(i)
492 write (iout,'(2i3,3f10.5)') i,i-innt+1,DM(i)
496 call FDISYP (n, DM(innt:inct), DU1(innt:inct-1),
497 & DU2(innt:inct-1), MARK)
501 & "ERROR: the inertia matrix is not positive definite for chain",
504 call MPI_Finalize(ierr)
507 else if (mark.eq.0) then
509 & "ERROR: the inertia matrix is singular for chain",ichain
511 call MPI_Finalize(ierr)
513 else if (mark.eq.1) then
515 write (iout,*) "The transformed five-diagonal inertia matrix"
516 write (iout,'(a,i5)') 'Chain',ichain
518 if (i.lt.inct-1) then
519 write (iout,'(2i3,3f10.5)') i,i-innt+1,DM(i),DU1(i),DU2(i)
520 else if (i.eq.inct-1) then
521 write (iout,'(2i3,3f10.5)') i,i-innt+1,DM(i),DU1(i)
523 write (iout,'(2i3,3f10.5)') i,i-innt+1,DM(i)
529 ! Diagonalization of the pentadiagonal matrix
534 dimen=(nct-nnt+1)+nside
535 dimen1=(nct-nnt)+(nct-nnt+1)
537 write (iout,*) "Degrees_of_freedom",dimen3
539 if (nfgtasks.gt.1) then
541 call MPI_Bcast(5,1,MPI_INTEGER,king,FG_COMM,IERROR)
542 time_Bcast=time_Bcast+MPI_Wtime()-time00
543 call int_bounds(dimen,igmult_start,igmult_end)
544 igmult_start=igmult_start-1
545 call MPI_Allgather(3*igmult_start,1,MPI_INTEGER,
546 & ng_start(0),1,MPI_INTEGER,FG_COMM,IERROR)
547 my_ng_count=igmult_end-igmult_start
548 call MPI_Allgather(3*my_ng_count,1,MPI_INTEGER,ng_counts(0),1,
549 & MPI_INTEGER,FG_COMM,IERROR)
550 write (iout,*) 'Processor:',fg_rank,' CG group',kolor,
551 & ' absolute rank',myrank,' igmult_start',igmult_start,
552 & ' igmult_end',igmult_end,' count',my_ng_count
553 write (iout,*) "ng_start",(ng_start(i),i=0,nfgtasks-1)
554 write (iout,*) "ng_counts",(ng_counts(i),i=0,nfgtasks-1)
564 c write (iout,*) "dimen",dimen," dimen1",dimen1," dimen3",dimen3
565 c Zeroing out A and fricmat
571 c Diagonal elements of the dC part of A and the respective friction coefficients
583 c Off-diagonal elements of the dC part of A
590 c Diagonal elements of the dX part of A and the respective friction coefficients
600 massvec(ii)=msc(iabs(iti))
601 if (iti.ne.10 .and. iti.ne.ntyp1) then
605 Gmat(ii1,ii1)=ISC(iabs(iti))
608 c Off-diagonal elements of the dX part of A
622 write (iout,*) "Vector massvec"
624 write (iout,*) i,massvec(i)
626 write (iout,'(//a)') "A"
627 call matout(dimen,dimen1,maxres2,maxres2,A)
630 c Calculate the G matrix (store in Gmat)
635 dtdi=dtdi+A(j,k)*A(j,i)*massvec(j)
637 Gmat(k,i)=Gmat(k,i)+dtdi
642 write (iout,'(//a)') "Gmat"
643 call matout(dimen,dimen,maxres2,maxres2,Gmat)
652 c Invert the G matrix
653 call MATINVERT(dimen,maxres2,Gcopy,Ginv,osob)
655 write (iout,'(//a)') "Ginv"
656 call matout(dimen,dimen,maxres2,maxres2,Ginv)
659 if (nfgtasks.gt.1) then
660 myginv_ng_count=maxres2*my_ng_count
661 call MPI_Allgather(maxres2*igmult_start,1,MPI_INTEGER,
662 & nginv_start(0),1,MPI_INTEGER,FG_COMM,IERROR)
663 call MPI_Allgather(myginv_ng_count,1,MPI_INTEGER,
664 & nginv_counts(0),1,MPI_INTEGER,FG_COMM,IERROR)
665 write (iout,*) "nginv_start",(nginv_start(i),i=0,nfgtasks-1)
666 write (iout,*) "nginv_counts",(nginv_counts(i),i=0,nfgtasks-1)
668 c call MPI_Scatterv(ginv(1,1),nginv_counts(0),
669 c & nginv_start(0),MPI_DOUBLE_PRECISION,ginv,
670 c & myginv_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
671 c call MPI_Barrier(FG_COMM,IERR)
673 call MPI_Scatterv(ginv(1,1),nginv_counts(0),
674 & nginv_start(0),MPI_DOUBLE_PRECISION,gcopy(1,1),
675 & myginv_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
677 time_scatter_ginv=time_scatter_ginv+MPI_Wtime()-time00
684 c write (iout,*) "Master's chunk of ginv"
685 c call MATOUT2(my_ng_count,dimen,maxres2,maxres2,ginv)
689 write (iout,*) "The G matrix is singular."
692 c Compute G**(-1/2) and G**(1/2)
700 call gldiag(maxres2,dimen,dimen,Ghalf,work,Geigen,Gvec,
704 & "Eigenvectors and eigenvalues of the G matrix"
705 call eigout(dimen,dimen,maxres2,maxres2,Gvec,Geigen)
708 sqreig(i)=dsqrt(Geigen(i))
716 Gsqrp(i,j)=Gsqrp(i,j)+Gvec(i,k)*Gvec(j,k)*sqreig(k)
717 Gsqrm(i,j)=Gsqrm(i,j)+Gvec(i,k)*Gvec(j,k)/sqreig(k)
718 Gcopy(i,j)=Gcopy(i,j)+Gvec(i,k)*Gvec(j,k)*Geigen(k)
723 write (iout,*) "Comparison of original and restored G"
726 write (iout,'(2i5,5f10.5)') i,j,Gmat(i,j),Gcopy(i,j),
727 & Gmat(i,j)-Gcopy(i,j),Gsqrp(i,j),Gsqrm(i,j)
734 c-------------------------------------------------------------------------------
735 SUBROUTINE EIGOUT(NC,NR,LM2,LM3,A,B)
738 include 'COMMON.IOUNITS'
739 double precision A(LM2,LM3),B(LM2)
740 integer nc,nr,lm2,lm3,ka,kb,kc,n,i,j
744 WRITE(IOUT,600) (I,I=KA,KB)
745 WRITE(IOUT,601) (B(I),I=KA,KB)
749 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
755 4 IF (KB.EQ.NC) RETURN
759 600 FORMAT (// 9H ROOT NO.,I4,9I11)
760 601 FORMAT (/5X,10(1PE11.4))
762 603 FORMAT (I5,10F11.5)
765 c-------------------------------------------------------------------------------
766 SUBROUTINE MATOUT(NC,NR,LM2,LM3,A)
769 include 'COMMON.IOUNITS'
770 double precision A(LM2,LM3)
771 integer nc,nr,lm2,lm3,n,ka,kb,kc,i,j
775 WRITE(IOUT,600) (I,I=KA,KB)
779 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
785 4 IF (KB.EQ.NC) RETURN
789 600 FORMAT (//5x,9I11)
791 603 FORMAT (I5,10F11.3)
794 c-------------------------------------------------------------------------------
795 SUBROUTINE MATOUT1(NC,NR,LM2,LM3,A)
798 include 'COMMON.IOUNITS'
799 double precision A(LM2,LM3)
800 integer nc,nr,lm2,lm3,n,ka,kb,kc,i,j
804 WRITE(IOUT,600) (I,I=KA,KB)
808 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
814 4 IF (KB.EQ.NC) RETURN
818 600 FORMAT (//5x,7(3I5,2x))
820 603 FORMAT (I5,7(3F5.1,2x))
823 c-------------------------------------------------------------------------------
824 SUBROUTINE MATOUT2(NC,NR,LM2,LM3,A)
827 include 'COMMON.IOUNITS'
828 double precision A(LM2,LM3)
829 integer nc,nr,lm2,lm3,ka,kb,kc,i,j,n
833 WRITE(IOUT,600) (I,I=KA,KB)
837 WRITE(IOUT,603) I,(A(I,J),J=KA,KB)
843 4 IF (KB.EQ.NC) RETURN
847 600 FORMAT (//5x,4(3I9,2x))
849 603 FORMAT (I5,4(3F9.3,2x))
852 c-----------------------------------------------------------------------------
853 SUBROUTINE MATOUTR(N,A)
854 c Prints the lower fragment of a symmetric matix
857 double precision a(n*(n+1)/2)
858 integer i,j,k,nlim,jlim,jlim1
859 CHARACTER*6 LINE6 / '------' /
860 CHARACTER*12 LINE12 / '------------' /
861 double precision B(10)
862 include 'COMMON.IOUNITS'
865 WRITE (IOUT,1000) (K,K=I,NLIM)
866 WRITE (IOUT,1020) LINE6,(LINE12,K=I,NLIM)
867 1000 FORMAT (/7X,10(I5,2X))
868 1020 FORMAT (A6,10A7)
873 3 B(K-I+1)=A(J*(J-1)/2+K)
874 WRITE (IOUT,1010) J,(B(K),K=1,JLIM1)
877 1010 FORMAT (I3,3X,10(F7.2))
881 c---------------------------------------------------------------------------
882 subroutine fivediagmult(n,DM,DU1,DU2,x,y)
885 double precision DM(n),DU1(n),DU2(n),x(n),y(n)
887 y(1)=DM(1)*x(1)+DU1(1)*x(2)+DU2(1)*x(3)
888 y(2)=DU1(1)*x(1)+DM(2)*x(2)+DU1(2)*x(3)+DU2(2)*x(4)
890 y(i)=DU2(i-2)*x(i-2)+DU1(i-1)*x(i-1)+DM(i)*x(i)
891 & +DU1(i)*x(i+1)+DU2(i)*x(i+2)
893 y(n-1)=DU2(n-3)*x(n-3)+DU1(n-2)*x(n-2)+DM(n-1)*x(n-1)
895 y(n)=DU2(n-2)*x(n-2)+DU1(n-1)*x(n-1)+DM(n)*x(n)
898 c---------------------------------------------------------------------------
899 subroutine fivediaginv_mult(ndim,forces,d_a_vec)
902 include 'COMMON.CHAIN'
903 include 'COMMON.IOUNITS'
904 include 'COMMON.LAGRANGE.5diag'
905 include 'COMMON.INTERACT'
907 double precision forces(3*ndim),accel(3,0:maxres2),rs(ndim),
908 & xsolv(ndim),d_a_vec(6*nres)
909 integer i,j,ind,ichain,n,iposc,innt,inct,inct_prev
911 Compute accelerations in Calpha and SC
913 n=dimen_chain(ichain)
914 iposc=iposd_chain(ichain)
915 innt=chain_border(1,ichain)
916 inct=chain_border(2,ichain)
918 rs(i)=forces(3*(i-1)+j)
920 call FDISYS (n,DM(iposc),DU1(iposc),DU2(iposc),rs,xsolv)
923 if (itype(i).eq.10)then
924 accel(j,i)=xsolv(ind)
927 accel(j,i)=xsolv(ind)
928 accel(j,i+nres)=xsolv(ind+1)
934 C Conevert d_a to virtual-bon-vector basis
936 write (iout,*) "accel in CA-SC basis"
938 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(accel(j,i),j=1,3),
939 & (accel(j,i+nres),j=1,3)
941 write (iout,*) "nnt",nnt
944 accel(:,0)=accel(:,1)
947 if (itype(i).eq.10 .or. itype(i).eq.ntyp1) then
949 accel(j,i)=accel(j,i+1)-accel(j,i)
953 accel(j,i+nres)=accel(j,i+nres)-accel(j,i)
954 accel(j,i)=accel(j,i+1)-accel(j,i)
959 accel(:,2*nres)=0.0d0
961 accel(:,0)=accel(:,1)
965 accel(:,chain_border1(1,ichain)-1)=
966 & accel(:,chain_border1(1,ichain))
967 accel(:,chain_border1(1,ichain))=0.0d0
970 accel(:,chain_border1(1,ichain)-1)=
971 & accel(:,chain_border1(1,ichain)-1)
972 & +accel(:,chain_border(2,ichain-1))
973 accel(:,chain_border(2,ichain-1))=0.0d0
976 write (iout,*) "accel in fivediaginv_mult: 1"
978 write(iout,'(i5,3f10.5)') i,(accel(j,i),j=1,3)
982 d_a_vec(j)=accel(j,0)
987 d_a_vec(ind+j)=accel(j,i)
992 if (itype(i).ne.10 .and. itype(i).ne.ntyp1) then
994 d_a_vec(ind+j)=accel(j,i+nres)
1000 write (iout,*) "d_a_vec"
1001 write (iout,'(3f10.5)') (d_a_vec(j),j=1,dimen3)
1006 c---------------------------------------------------------------------------
1007 SUBROUTINE ginv_mult(z,d_a_tmp)
1009 include 'DIMENSIONS'
1014 include 'COMMON.SETUP'
1015 include 'COMMON.TIME1'
1017 include 'COMMON.LAGRANGE'
1018 double precision z(dimen3),d_a_tmp(dimen3),temp(maxres6),time00
1019 &,time01,zcopy(dimen3)
1022 if (nfgtasks.gt.1) then
1023 if (fg_rank.eq.0) then
1024 c The matching BROADCAST for fg processors is called in ERGASTULUM
1026 call MPI_Bcast(4,1,MPI_INTEGER,king,FG_COMM,IERROR)
1027 time_Bcast=time_Bcast+MPI_Wtime()-time00
1028 c print *,"Processor",myrank," BROADCAST iorder in GINV_MULT"
1030 c write (2,*) "time00",time00
1031 c write (2,*) "Before Scatterv"
1033 c write (2,*) "Whole z (for FG master)"
1035 c write (2,*) i,z(i)
1037 c call MPI_Barrier(FG_COMM,IERROR)
1039 call MPI_Scatterv(z,ng_counts(0),ng_start(0),
1040 & MPI_DOUBLE_PRECISION,
1041 & zcopy,3*my_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
1042 c write (2,*) "My chunk of z"
1043 do i=1,3*my_ng_count
1045 c write (2,*) i,z(i)
1047 c write (2,*) "After SCATTERV"
1049 c write (2,*) "MPI_Wtime",MPI_Wtime()
1050 time_scatter=time_scatter+MPI_Wtime()-time00
1052 time_scatter_ginvmult=time_scatter_ginvmult+MPI_Wtime()-time00
1054 c write (2,*) "time_scatter",time_scatter
1055 c write (2,*) "dimen",dimen," dimen3",dimen3," my_ng_count",
1064 c write (2,*) "k,i,j,ind",k,i,j,ind,(j-1)*3+k+1,
1065 c & Ginv(i,j),z((j-1)*3+k+1),
1066 c & Ginv(i,j)*z((j-1)*3+k+1)
1067 c temp(ind)=temp(ind)+Ginv(i,j)*z((j-1)*3+k+1)
1068 temp(ind)=temp(ind)+Ginv(j,i)*z((j-1)*3+k+1)
1072 time_ginvmult=time_ginvmult+MPI_Wtime()-time01
1073 c write (2,*) "Before REDUCE"
1075 c write (2,*) "z before reduce"
1077 c write (2,*) i,temp(i)
1080 call MPI_Reduce(temp(1),d_a_tmp(1),dimen3,MPI_DOUBLE_PRECISION,
1081 & MPI_SUM,king,FG_COMM,IERR)
1082 time_reduce=time_reduce+MPI_Wtime()-time00
1083 c write (2,*) "After REDUCE"
1095 c write (2,*) "k,i,j,ind",k,i,j,ind,(j-1)*3+k+1
1097 c & Ginv(i,j),z((j-1)*3+k+1),
1098 c & Ginv(i,j)*z((j-1)*3+k+1)
1099 d_a_tmp(ind)=d_a_tmp(ind)
1100 & +Ginv(j,i)*z((j-1)*3+k+1)
1101 c d_a_tmp(ind)=d_a_tmp(ind)
1102 c & +Ginv(i,j)*z((j-1)*3+k+1)
1107 time_ginvmult=time_ginvmult+MPI_Wtime()-time01
1114 c---------------------------------------------------------------------------
1116 SUBROUTINE ginv_mult_test(z,d_a_tmp)
1118 include 'DIMENSIONS'
1119 include 'COMMON.LAGRANGE'
1120 double precision z(dimen),d_a_tmp(dimen)
1121 double precision ztmp(dimen/3),dtmp(dimen/3)
1126 c d_a_tmp(i)=d_a_tmp(i)+Ginv(i,j)*z(j)
1135 ztmp(j)=z((j-1)*3+k+1)
1138 call alignx(16,ztmp(1))
1139 call alignx(16,dtmp(1))
1140 call alignx(16,Ginv(1,1))
1145 dtmp(i)=dtmp(i)+Ginv(i,j)*ztmp(j)
1150 d_a_tmp(ind)=dtmp(i)
1156 c---------------------------------------------------------------------------
1157 SUBROUTINE fricmat_mult(z,d_a_tmp)
1158 include 'DIMENSIONS'
1164 include 'COMMON.LAGRANGE'
1165 include 'COMMON.IOUNITS'
1166 include 'COMMON.SETUP'
1167 include 'COMMON.TIME1'
1169 include 'COMMON.LANGEVIN'
1171 include 'COMMON.LANGEVIN.lang0'
1173 double precision z(dimen3),d_a_tmp(dimen3),temp(maxres6),time00
1174 &,time01,zcopy(dimen3)
1176 if (nfgtasks.gt.1) then
1177 if (fg_rank.eq.0) then
1178 c The matching BROADCAST for fg processors is called in ERGASTULUM
1180 call MPI_Bcast(9,1,MPI_INTEGER,king,FG_COMM,IERROR)
1181 time_Bcast=time_Bcast+MPI_Wtime()-time00
1182 c print *,"Processor",myrank," BROADCAST iorder in FRICMAT_MULT"
1184 c call MPI_Barrier(FG_COMM,IERROR)
1186 call MPI_Scatterv(z,ng_counts(0),ng_start(0),
1187 & MPI_DOUBLE_PRECISION,
1188 & zcopy,3*my_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERR)
1189 c write (2,*) "My chunk of z"
1190 do i=1,3*my_ng_count
1192 c write (2,*) i,z(i)
1194 time_scatter=time_scatter+MPI_Wtime()-time00
1196 time_scatter_fmatmult=time_scatter_fmatmult+MPI_Wtime()-time00
1204 temp(ind)=temp(ind)-fricmat(j,i)*z((j-1)*3+k+1)
1208 time_fricmatmult=time_fricmatmult+MPI_Wtime()-time01
1209 c write (2,*) "Before REDUCE"
1210 c write (2,*) "d_a_tmp before reduce"
1212 c write (2,*) i,temp(i)
1216 call MPI_Reduce(temp(1),d_a_tmp(1),dimen3,MPI_DOUBLE_PRECISION,
1217 & MPI_SUM,king,FG_COMM,IERR)
1218 time_reduce=time_reduce+MPI_Wtime()-time00
1219 c write (2,*) "After REDUCE"
1231 d_a_tmp(ind)=d_a_tmp(ind)
1232 & -fricmat(j,i)*z((j-1)*3+k+1)
1237 time_fricmatmult=time_fricmatmult+MPI_Wtime()-time01
1242 c write (iout,*) "Vector d_a"
1244 c write (2,*) i,d_a_tmp(i)