
      subroutine uweldflux(f,temflu,mibody,welddim, time)
#ifdef _IMPLICITNONE
      implicit none
#else
      implicit logical (a-z)
#endif
c     ** Start of generated type statements **
      include "weld.cmn"
      include "pival.cmn"
	  include "hards.cmn"
	  include "concom.cmn"
      real*8 f
      integer mibody
      real*8 temflu, time, welddim
c     ** End of generated type statements **
      dimension mibody(*),temflu(*),welddim(*)
c* * * * * *
c
c     user sub routine for weld flux input.
c
c     f              weld flux value (to be defined)
c     temflu(1,2,3)  local integration point coordinates
c                    (with respect to weld origin)
c     temflu(4,5,6)  global integration point coordinates
c     mibody(1)      element number
c     mibody(2)      distributed flux type
c     mibody(3)      integration point number
c     mibody(4)      weld flux index
c     welddim(1)     weld width
c     welddim(2)     weld depth
c     welddim(3)     weld forward length
c     welddim(4)     weld rear length
c 	  welddim(5)     power
c     time           time at end of incement
c     INPUT:          temflu,mibody,welddim,time
c     OUTPUT:         f
c* * * * * * * * * * * * * * *
c     These variables are provided by the DAT-file
      real*8 LENG, WID, DEP      ! Distance from the origin of the source
c     These variables are provided by the DAT-file but can also be
c     set or changed inside this file ignoring the DAT-file
      real*8 QV                  ! Heat source power
      real*8 QR, B, T, A, REAR, FORW
	  real*8 EFFCY, AREA, FAKT, TCRIT


c     Those are to be set or calculated here
c-------------------------------
c Eingabe der Leistungsparameter
c-------------------------------
      QV = welddim(5)				! power [W]
	  
c    ! * * * * * * * * * * * * * * *
c    !      temflu 1       position vertical to welding direction
c    !      temflu 2       postition in depth
c    !      temflu 3       position in welding direction
c    !      Read the position of the node with respect to local
c    !      coordinate system of the heat source
c    !      LENG: Position along the weld line (might be negative!)
c    !      WID: Position perpendicular to the weld line (might be negative!)
c    !      DEP: Position in the depth
      LENG = temflu(3)
      WID = temflu(1)
      DEP = temflu(2)
c    !      Heat source geometry read from DAT-File
c    !      WELD FLUX 5th Block, entries 4, 5, 6, 7

      B = welddim(1)                ! half width of heating field (perpendicular to welding direction)
      T = welddim(2)                ! absorption depth
      REAR = welddim(3)             ! rear lenght
      FORW = welddim(4)				! front lenght

      A = REAR + FORW
      EFFCY = 1.0

      TCRIT = -1.0E-3

      QR = 0.0     ! heat flux variable start value
      F = 0        ! heat flux output 
	  FAKT = 1.0
	  
c    !      Tests, ob Integrationspunkte
      if((DEP.GT.T).OR.(DEP.LT.(TCRIT))) return            ! only points in absorption depth
      if(abs(WID).GT.(abs(B))) return            ! only points in field width
      if((abs(LENG).GT.(REAR)).OR.(abs(LENG).GT.(FORW))) return      ! only points in absorption field length

	
      AREA = A * (2*B)
      QR = ((QV * FAKT) / AREA) * EFFCY
      f = QR      ! Ausgabe des jeweiligen WÃƒÂ¤rmestroms an die Berechnung

      END
	  
