subroutine TD_WeightOnBitCalculation
    
   Use TD_DrillStemComponents
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables !@
   Use TD_StringConnectionData
   use CDataDisplayConsole
    use SimulationVariables
   
   
   implicit none
   
   Integer :: i
   
   
   !data%State%TD_StConn%TouchConnectionHeight = data%State%TD_String%DlMax + data%State%TD_String%DrillStemTotalLengthIni - data%State%TD_WellGeneral%WellTotalLength
   data%State%TD_StConn%TouchConnectionHeight = data%State%TD_String%DrillStemTotalLengthIni - data%State%TD_WellGeneral%WellTotalLength
   
   
   
   !if (data%State%TD_DrillStems(1)%ComponentType == 0) then        ?????????????
   
   
   
   !if (data%State%TD_DrillStems(1)%DownDepth < data%State%TD_WellGeneral%WellTotalLength) then
   if (data%State%TD_StConn%ConnectionHeight < data%State%TD_StConn%TouchConnectionHeight) then
       data%State%TD_String%DlTouch = data%State%TD_String%DlMax-(data%State%TD_StConn%TouchConnectionHeight-data%State%TD_StConn%ConnectionHeight) 
       data%State%TD_String%WeightOnBit = ((data%State%TD_String%StaticHookLoad/2.0d0)/data%State%TD_String%DlMax)*(data%State%TD_String%DlMax-data%State%TD_String%DlTouch)    !(data%State%TD_String%StaticHookLoad/2.0d0) ---> because of Uniform drill stem(drillpipes)   ??????????
   else
       data%State%TD_String%WeightOnBit = 0.d0         ![lb]
   end if
   
   Call Set_WeightOnBit(AINT(real(data%State%TD_String%WeightOnBit,8)))
   
  

   
   
   
end subroutine