c
c User subroutine VDISP to prescribe boundary conditions
c     
      subroutine vdisp(
c Read only -
     *   nblock, nDof, nCoord, kstep, kinc, 
     *   stepTime, totalTime, dtNext, dt, 
     *   cbname, jBCType, jDof, jNodeUid, amp,
     *   coordNp, u, v, a, rf, rmass, rotaryI, 
c Write only -
     *   rval )
c
      include 'vaba_param.inc'
      parameter( zero = 0.d0, half = 0.5d0 )
      dimension jDof(nDof), jNodeUid(nblock), 
     *   amp(nblock), coordNp(nCoord, nblock), 
     *   u(nDof,nblock), v(nDof,nblock), a(nDof,nblock), 
     *   rf(nDof,nblock), rmass(nblock), rotaryI(3,3,nblock), 
     *   rval(nDof,nblock)
c      
      character*80 cbname
c
      A1 = 0.5
      B1 = 1.5
      omega = .3141593
      if( jBCType .eq. 0 ) then
c
c     Impose displacement
c
         if( stepTime .lt. zero ) then
            v0 = B1*omega
            do 101 k=1, nblock
            do 101 j=1, nDof
               if ( jDof(j) .gt. 0 ) then
                 rval(j,k) = -v0*dt
               end if
101         continue      
         else if( stepTime .eq. zero ) then
            time = dt
            do 102 k=1, nblock
            do 102 j=1, nDof
               if ( jDof(j) .gt. 0 ) then
                 rval(j,k) = B1*sin( omega*time )
               end if
102         continue      
         else
            time = stepTime + dtNext
            do 103 k=1, nblock
            do 103 j=1, nDof
               if ( jDof(j) .gt. 0 ) then
                 rval(j,k) = B1*sin( omega*time )
               end if
103         continue      
         end if
c
c      
      else if( jBCType .eq. 1 ) then
c
c     Impose velocity
c
         if( stepTime .lt. zero ) then
            time = -dt*half
         else if( stepTime .eq. zero ) then
            time = dt*half
         else
            time = stepTime + dtNext*half
         end if
c
         do 200 k=1, nblock
         do 200 j=1, nDof
            if ( jDof(j) .gt. 0 ) then
               rval(j,k) = A1*cos( omega*time ) + B1*sin( omega*time )
            end if
200      continue      
c
      else if( jBCType .eq. 2 ) then
c
c     Impose acceleration
c
         if( stepTime .lt. zero ) then
            time = -dt
         else if( stepTime .eq. zero ) then
            time = zero
         else
            time = stepTime
         end if
c
         do 300 k=1, nblock
         do 300 j=1, nDof
            if ( jDof(j) .gt. 0 ) then
               rval(j,k) = A1*cos( omega*time ) + B1*sin( omega*time )
            end if
300      continue      
c
      end if
c
      return
      end
