double precision function funmin ( xmer, nmer ) implicit none integer nmer double precision xmer(nmer) include 'sizes.i' include 'files.i' include 'inform.i' include 'iounit.i' include 'math.i' include 'omega.i' include 'zcoord.i' include 'usage.i' integer mnat, i, ik, ixyz, nunit double precision energy, fl integer ifirst save ifirst data ifirst / 0 / mnat = (nmer+6)/3 if (ifirst.eq.0) then ifirst = 1 call initial call getint call mechanic cc call initrot nomega = 0 do i=4,mnat if (iz(4,i).eq.0) then nomega = nomega+1 iomega(1,nomega) = iz(1,i) iomega(2,nomega) = iz(2,i) dihed(nomega) = ztors(i)/radian zline(nomega) = i end if end do do i=1,mnat use(i) = .true. end do cc write (*,*) 'nomega=',nomega cc do i=1,nomega cc write (*,*) 'i iomega=',i,iomega(1,i),iomega(2,i) cc write (*,*) 'i zline ',i,zline(i),dihed(i) cc end do cc do i=1,mnat cc write (*,*) 'zbond ',i,zbond(i) cc write (*,*) 'zang ',i,zang(i) cc write (*,*) 'ztors ',i,ztors(i) cc end do ik = 0 do i=2,mnat ik = ik+1 call setx1(ik,zbond(i)) end do do i=3,mnat ik = ik+1 call setx1(ik,zang(i)) end do do i=4,mnat ik = ik+1 call setx1(ik,ztors(i)) end do end if zbond(1) = 0. zang(1) = 0. zang(2) = 0. ztors(1) = 0. ztors(2) = 0. ztors(3) = 0. ik = 0 do i=2,mnat ik = ik+1 zbond(i) = xmer(ik) end do do i=3,mnat ik = ik+1 zang(i) = xmer(ik) end do do i=4,mnat ik = ik+1 ztors(i) = xmer(ik) end do cc do i = 1, nomega cc dihed(i) = ztors(zline(i)) / radian cc end do call makexyz cc call gradrot(energy,derivs) funmin = energy() call getfla(1,fl) if (fl.ne.0.) then fl = 0. call setfla(1,fl) ixyz = nunit() if (ixyz.eq.-1) stop 'ERR: NO FREE UNIT' call prtxyz(ixyz) end if end subroutine granal ( nmer, xmer, gmer ) implicit none integer nmer double precision xmer(nmer), gmer(nmer) include 'sizes.i' include 'omega.i' include 'zcoord.i' integer mnat, i, ik, ioff double precision energy double precision derivs(maxrot), radian do i=1,nmer gmer(i) = 0. end do mnat = (nmer+6)/3 zbond(1) = 0. zang(1) = 0. zang(2) = 0. ztors(1) = 0. ztors(2) = 0. ztors(3) = 0. ik = 0 do i=2,mnat ik = ik+1 zbond(i) = xmer(ik) end do do i=3,mnat ik = ik+1 zang(i) = xmer(ik) end do do i=4,mnat ik = ik+1 ztors(i) = xmer(ik) end do cc do i = 1, nomega cc dihed(i) = ztors(zline(i)) / radian cc end do call makexyz call gradrot(energy,derivs) ioff = 2*mnat-6 radian = 57.29577951308232088d0 do i=1,nomega gmer(zline(i)+ioff) = derivs(i)/radian end do end