added source code
[unres.git] / source / cluster / wham / src-M / convert.f
1       subroutine geom_to_var(n,x)
2 C
3 C Transfer the geometry parameters to the variable array.
4 C The positions of variables are as follows:
5 C 1. Virtual-bond torsional angles: 1 thru nres-3
6 C 2. Virtual-bond valence angles: nres-2 thru 2*nres-5
7 C 3. The polar angles alpha of local SC orientation: 2*nres-4 thru 
8 C    2*nres-4+nside
9 C 4. The torsional angles omega of SC orientation: 2*nres-4+nside+1
10 C    thru 2*nre-4+2*nside 
11 C
12       include 'DIMENSIONS'
13       include 'COMMON.VAR'
14       include 'COMMON.GEO'
15       include 'COMMON.CHAIN'
16       double precision x(n)
17 cd    print *,'nres',nres,' nphi',nphi,' ntheta',ntheta,' nvar',nvar
18       do i=4,nres
19         x(i-3)=phi(i)
20 cd      print *,i,i-3,phi(i)
21       enddo
22       if (n.eq.nphi) return
23       do i=3,nres
24         x(i-2+nphi)=theta(i)
25 cd      print *,i,i-2+nphi,theta(i)
26       enddo
27       if (n.eq.nphi+ntheta) return
28       do i=2,nres-1
29         if (ialph(i,1).gt.0) then
30           x(ialph(i,1))=alph(i)
31           x(ialph(i,1)+nside)=omeg(i)
32 cd        print *,i,ialph(i,1),ialph(i,1)+nside,alph(i),omeg(i)
33         endif
34       enddo      
35       return
36       end
37 C--------------------------------------------------------------------
38       subroutine var_to_geom(n,x)
39 C
40 C Update geometry parameters according to the variable array.
41 C
42       include 'DIMENSIONS'
43       include 'COMMON.VAR'
44       include 'COMMON.CHAIN'
45       dimension x(n)
46       do i=4,nres
47         phi(i)=pinorm(x(i-3))
48       enddo
49       if (n.eq.nphi) return
50       do i=3,nres
51         theta(i)=x(i-2+nphi)
52       enddo
53       if (n.eq.nphi+ntheta) return
54       do i=1,nside
55         alph(ialph(i,2))=x(nphi+ntheta+i)
56         omeg(ialph(i,2))=pinorm(x(nphi+ntheta+nside+i))
57       enddo      
58       return
59       end