- gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+
- & gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
- if(itype(2).ne.10) then
- gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+
- & gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
- endif
- if(itype(3).ne.10) then
- gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+
- & gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
- endif
- if(nres.gt.4) then
- gcart(j,2)=gcart(j,2)+gloc(2,icg)*dphi(j,1,5)
- endif
- enddo
-c If there are only five residues
- if(nres.eq.5) then
- do j=1,3
- gcart(j,3)=gcart(j,3)+gloc(1,icg)*dphi(j,3,4)+gloc(2,icg)*
- & dphi(j,2,5)+gloc(nres-1,icg)*dtheta(j,2,4)+gloc(nres,icg)*
- & dtheta(j,1,5)
- if(itype(3).ne.10) then
- gcart(j,3)=gcart(j,3)+gloc(ialph(3,1),icg)*
- & dalpha(j,2,3)+gloc(ialph(3,1)+nside,icg)*domega(j,2,3)
+ if((itype(2).ne.10).and.(itype(2).ne.21)) then
+ if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
+ & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
+ if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.21)) then
+ gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
+cc the - above is due to different vector direction
+ gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
+ endif
+ if (nres.gt.3) then
+ gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
+cc the - above is due to different vector direction
+ gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
+c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
+c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
+ endif