*deck,userfd       USERDISTRIB  parallel                                pck
      subroutine userfd (nr,kcbrm,kpfor,ktrsur,isur,
     x cb,do,doext,aread,alenv,denswat,faclen,conac,fluidt,visc,
     x watbas,watcur,watwav,xyzup,tr,accel,puvel,u,zass,
     x forl,zsc,zsc2,pdyn,holdwv)
c *** primary function:  compute complex load vector for frequency domain logic
c                        for pipe59
c *** secondary functions: none
c     -- accessed with keyopt(12) = 2
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c  input arguments:
c     nr       (int,sc,in)       - matrix size
c     kcbrm    (int,sc,in)       - key for reduced matrices/cable option
c     kpfor    (int,sc,in)       - keyopt for hydrodynamic printout
c     ktrsur   (int,sc,in)       - keyopt for surface treatment(unfinished)
c     isur     (int,sc,in)       - surface flag
c     cb       (dp,sc,in)        - buoyancy coefficient (real constant)
c     do       (dp,sc,in)        - outside diameter of pipe
c     doext    (dp,sc,in)        - outside diameter of insulation
c     aread    (dp,sc,in)        - area of displaced water
c     alenv    (dp,sc,in)        - length of element
c     denswat  (dp,sc,in)        - water density
c     faclen   (dp,sc,in)        - wetted fraction of pipe
c     conac    (dp,sc,in)        - added mass per unit length
c     fluidt   (dp,sc,in)        - fluid temperature
c     visc     (dp,sc,in)        - viscosity
c     watbas   (dp,ar(*),in      - water basic table
c     watcur   (dp,ar(*),in      - water current table
c     watwav   (dp,ar(*),in      - water wave table
c     xyzup    (dp,ar(3,2),in)   - updated coordinates
c     tr       (dp,ar(3,3),in)   - local to global transformation matrix
c     accel    (dp,ar(3),in)     - acceleration vector
c     puvel    (int,sc,in)       - index for velocities in u matrix
c     u        (dp,ar(nr,5),in   - displacements and velocities
c     zass     (dp,ar(nr,nr),in) - mass matrix
c     forl     (dp,ar(12),inout) - force vector in element coordinates
c     zsc      (dp,ar(nr),inout) - real load vector for frequency domain
c     zsc2     (dp,ar(nr),inout) - complex load vector for frequency domain
c
c  output arguments:
c     forl     (dp,ar(12),inout) - force vector in element coordinates
c     zsc      (dp,ar(nr),inout) - real load vector for frequency domain
c     zsc2     (dp,ar(nr),inout) - complex load vector for frequency domain
c     pdyn     (dp,ar(2),out)    - dynamic pressure
c     holdwv   (dp,ar(60),out)   - wave information held for printout
c
#include "impcom.inc"
c
      external TrackBegin, TrackEnd, erhandler, vamb, matxv, vmove
c
      integer
     x nr,kcbrm,kpfor,ktrsur,isur,      puvel,kcrc,nw,ncm,i
      double precision
     x cb,do,doext,aread,alenv,denswat,faclen,conac,fluidt,visc,
     x watbas(*),watcur(*),watwav(*),xyzup(3,2),tr(3,3),accel(3),
     x u(nr,5),zass(nr,nr),forl(12),zsc(nr),zsc2(nr),pdyn(2),holdwv(60),
     x forl2(12),depth,dxyz(3)
c
c     ---          accel(3) (in acelcm) is the vertical acceleration
c     ---          puvel (in elucom) is the second subscript of the u matrix
c     ---           to be used for the velocities
c
      call TrackBegin ('userfd')
c   *** customer should remove the below warning when making any changes ***
c
      call erhandler('userfd',5000,2,
     x 'ANSYS,INC.-supplied version of coding for USERFD has been used.'
     x ,0.0d0,' ')
c

c
      call vamb (xyzup(1,2),xyzup(1,1),dxyz(1),3)
      depth =       watbas( 1)
      ncm   = nint (watcur( 6))
      kcrc  = nint (watwav( 2))
      nw    = nint (watwav(17))
c
c
c     no demo logic provided
c
c
c     --- dummy logic to keep analyzer happy - to be removed by programmer
      i = nw + ncm + kcrc + kcbrm + kpfor + ktrsur + isur + puvel
      holdwv(1) =  dxyz(1) + cb + do + doext + aread + alenv + 
     x watbas(1) + watcur(1) + watwav(1) + faclen + conac + fluidt + 
     x visc + u(1,1) + depth + denswat + accel(3) + zass(1,1)
      pdyn(1) = 0.0d0
      forl2(1) = 0.0d0
c     --- end of dummy logic
c
      if (nr .eq. 6) then
         call vmove (forl (7),forl (4),3)
         call vmove (forl2(7),forl2(4),3)
      endif
      do i = 1,nr-2,3
         call matxv (tr(1,1),forl (i),zsc (i), 3,3)
         call matxv (tr(1,1),forl2(i),zsc2(i), 3,3)
      enddo
      call TrackEnd ('userfd')
      return
      end
