Because in general iturn3_start and iturn3_end are nnt and nct-3,
respectively, if the chain has a GLY as the first or last residues,
nnt=1 or nct=nres, the program ends up evaluating itype(0) or itype(nres+1).
The first case causes a segmentation fault, the second won't (if maxres is
bigger than nres), but it won't cycle the loop which is what was intended
do i=iturn3_start,iturn3_end
if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
& .or. itype(i+2).eq.ntyp1
do i=iturn3_start,iturn3_end
if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
& .or. itype(i+2).eq.ntyp1
- & .or. itype(i+3).eq.ntyp1
- & .or. itype(i-1).eq.ntyp1
- & .or. itype(i+4).eq.ntyp1
- & ) cycle
+ & .or. itype(i+3).eq.ntyp1) cycle
+ if(i.gt.1)then
+ if(itype(i-1).eq.ntyp1)cycle
+ end if
+ if(i.LT.nres-3)then
+ if (itype(i+4).eq.ntyp1) cycle
+ end if
dxi=dc(1,i)
dyi=dc(2,i)
dzi=dc(3,i)
dxi=dc(1,i)
dyi=dc(2,i)
dzi=dc(3,i)