      SUBROUTINE update(x,v,w2,gamma,omega,t,dt,dt2)
      IMPLICIT NONE
      REAL*8 a, amid, tmid, vmid, xmid, x, v, w2, gamma, omega, t, dt,
     +       dt2
      a = f(x,v,t,w2,gamma,omega)           ! external function
      vmid = v + a*dt2
      xmid = x + v*dt2
      tmid = t + dt2
      amid = f(xmid,vmid,tmid,w2,gamma,omega)
      v = v + amid*dt
      x = x + vmid*dt
      t = tmid + dt2
      END
C
      FUNCTION f(x,v,t,w2,gamma,omega)
      IMPLICIT NONE
      REAL*8 f, x, v, t, w2, gamma, omega
      f = -w2*x - gamma*v + cos(omega*t)
      END
