xdrf2pdb-M.F: corrected order of reading
[unres.git] / source / unres / src_MD / src / md-diff / mts / sd_verlet1.f
1 c-------------------------------------------------------------      
2       subroutine sd_verlet1
3 c Applying stochastic velocity Verlet algorithm - step 1 to velocities        
4       implicit real*8 (a-h,o-z)
5       include 'DIMENSIONS'
6       include 'COMMON.CONTROL'
7       include 'COMMON.VAR'
8       include 'COMMON.MD'
9 #ifndef LANG0
10       include 'COMMON.LANGEVIN'
11 #else
12       include 'COMMON.LANGEVIN.lang0'
13 #endif
14       include 'COMMON.CHAIN'
15       include 'COMMON.DERIV'
16       include 'COMMON.GEO'
17       include 'COMMON.LOCAL'
18       include 'COMMON.INTERACT'
19       include 'COMMON.IOUNITS'
20       include 'COMMON.NAMES'
21       double precision stochforcvec(MAXRES6)
22       common /stochcalc/ stochforcvec
23       logical lprn /.false./
24
25 c      write (iout,*) "dc_old"
26 c      do i=0,nres
27 c        write (iout,'(i5,3f10.5,5x,3f10.5)') 
28 c     &   i,(dc_old(j,i),j=1,3),(dc_old(j,i+nres),j=1,3)
29 c      enddo
30       do j=1,3
31         dc_work(j)=dc_old(j,0)
32         d_t_work(j)=d_t_old(j,0)
33         d_a_work(j)=d_a_old(j,0)
34       enddo
35       ind=3
36       do i=nnt,nct-1
37         do j=1,3
38           dc_work(ind+j)=dc_old(j,i)
39           d_t_work(ind+j)=d_t_old(j,i)
40           d_a_work(ind+j)=d_a_old(j,i)
41         enddo
42         ind=ind+3
43       enddo
44       do i=nnt,nct
45         if (itype(i).ne.10) then
46           do j=1,3
47             dc_work(ind+j)=dc_old(j,i+nres)
48             d_t_work(ind+j)=d_t_old(j,i+nres)
49             d_a_work(ind+j)=d_a_old(j,i+nres)
50           enddo
51           ind=ind+3
52         endif
53       enddo
54 #ifndef LANG0
55       if (lprn) then
56       write (iout,*) 
57      &  "pfric_mat, vfric_mat, afric_mat, prand_mat, vrand_mat1,",
58      &  " vrand_mat2"
59       do i=1,dimen
60         do j=1,dimen
61           write (iout,'(2i5,6e15.5)') i,j,pfric_mat(i,j),
62      &      vfric_mat(i,j),afric_mat(i,j),
63      &      prand_mat(i,j),vrand_mat1(i,j),vrand_mat2(i,j)
64         enddo
65       enddo
66       endif
67       do i=1,dimen
68         ddt1=0.0d0
69         ddt2=0.0d0
70         do j=1,dimen
71           dc_work(i)=dc_work(i)+vfric_mat(i,j)*d_t_work(j)
72      &      +afric_mat(i,j)*d_a_work(j)+prand_mat(i,j)*stochforcvec(j)
73           ddt1=ddt1+pfric_mat(i,j)*d_t_work(j)
74           ddt2=ddt2+vfric_mat(i,j)*d_a_work(j)
75         enddo
76         d_t_work_new(i)=ddt1+0.5d0*ddt2
77         d_t_work(i)=ddt1+ddt2
78       enddo
79 #endif
80       do j=1,3
81         dc(j,0)=dc_work(j)
82         d_t(j,0)=d_t_work(j)
83       enddo
84       ind=3     
85       do i=nnt,nct-1    
86         do j=1,3
87           dc(j,i)=dc_work(ind+j)
88           d_t(j,i)=d_t_work(ind+j)
89         enddo
90         ind=ind+3
91       enddo
92       do i=nnt,nct
93         if (itype(i).ne.10) then
94           inres=i+nres
95           do j=1,3
96             dc(j,inres)=dc_work(ind+j)
97             d_t(j,inres)=d_t_work(ind+j)
98           enddo
99           ind=ind+3
100         endif      
101       enddo 
102       return
103       end