subroutine TD_ForceCalculation
    
   Use TD_DrillStemComponents
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables !@
   

   implicit none
   
   Integer :: i
   Real(8) :: TD_SemiMudVisc
   
   
   
   
   if  (data%State%TD_String%DrillStemForceType == 1) then
       
       Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs
           TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity
           if (data%State%TD_DrillStems(i)%HoleType == 0) then
               Call TD_ForceUpS(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 1) then
               Call TD_ForceUpB(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 2) then
               Call TD_ForceUpD(i,TD_SemiMudVisc)
           end if
           Call TD_StrainCalculation(i)
           Call TD_TorqueCalculation(i)
       End Do
       
   else if (data%State%TD_String%DrillStemForceType == 2) then
       
       Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs
           TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity
           if (data%State%TD_DrillStems(i)%HoleType == 0) then
               Call TD_ForceUpSRot(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 1) then
               Call TD_ForceUpBRot(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 2) then
               Call TD_ForceUpDRot(i,TD_SemiMudVisc)
           end if
           Call TD_StrainCalculation(i)
           Call TD_TorqueCalculation(i)
       End Do
       
   else if (data%State%TD_String%DrillStemForceType == 3) then
       
       Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs
           TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity
           if (data%State%TD_DrillStems(i)%HoleType == 0) then
               Call TD_ForceDownS(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 1) then
               Call TD_ForceDownB(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 2) then
               Call TD_ForceDownD(i,TD_SemiMudVisc)
           end if
           Call TD_StrainCalculation(i)
           Call TD_TorqueCalculation(i)
       End Do
       
   else if (data%State%TD_String%DrillStemForceType == 4) then
       
       Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs
           TD_SemiMudVisc = data%State%TD_DrillStems(i)%MudViscosity
           if (data%State%TD_DrillStems(i)%HoleType == 0) then
               Call TD_ForceDownSRot(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 1) then
               Call TD_ForceDownBRot(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 2) then
               Call TD_ForceDownDRot(i,TD_SemiMudVisc)
           end if
           Call TD_StrainCalculation(i)
           Call TD_TorqueCalculation(i)
       End Do
       
   else if (data%State%TD_String%DrillStemForceType == 5) then
       
       Do i = 1 , data%State%TD_String%DrillStemComponentsNumbs
           TD_SemiMudVisc = 0.0d0
           if (data%State%TD_DrillStems(i)%HoleType == 0) then
               Call TD_ForceUpS(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 1) then
               Call TD_ForceUpB(i,TD_SemiMudVisc)
           else if (data%State%TD_DrillStems(i)%HoleType == 2) then
               Call TD_ForceUpD(i,TD_SemiMudVisc)
           end if
           Call TD_StrainCalculation(i)
           Call TD_TorqueCalculation(i)
       End Do
       
   end if
   
   
   
!-----------------------------------------------------------------------------------
!  
   !if (data%State%TD_String%DrillStemAxialVelocity>0.) then
   !    
   !     i = 1
   !     data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 - data%State%TD_DrillStems(i)%Drag
   !     data%State%TD_DrillStems(i)%Dl    = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule
   !     data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl
   ! 
   !     do i = 2 , data%State%TD_String%DrillStemComponentsNumbs 
   !         data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 - data%State%TD_DrillStems(i)%Drag
   !         data%State%TD_DrillStems(i)%Dl    = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule
   !         data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl
   !     end do
   !     !print*, 'i='     ,i
   !     !print*, 'data%State%TD_String%DrillStemComponentsNumbs='     ,data%State%TD_String%DrillStemComponentsNumbs
   !     
   !else if (data%State%TD_String%DrillStemAxialVelocity<0.) then
   !    i = 1
   !     data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 + data%State%TD_DrillStems(i)%Drag
   !     data%State%TD_DrillStems(i)%Dl    = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule
   !     data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i)%Dl
   ! 
   !     do i = 2 , data%State%TD_String%DrillStemComponentsNumbs 
   !         data%State%TD_DrillStems(i)%Force2 = data%State%TD_DrillStems(i)%Force2 + data%State%TD_DrillStems(i)%Drag
   !         data%State%TD_DrillStems(i)%Dl    = data%State%TD_DrillStems(i)%Force2 * data%State%TD_DrillStems(i)%Length / data%State%TD_DrillStems(i)%Area / data%State%TD_DrillStems(i)%ElasticModule
   !         data%State%TD_DrillStems(i)%DlTotal = data%State%TD_DrillStems(i-1)%DlTotal + data%State%TD_DrillStems(i)%Dl
   !     end do
   !end if
   
   
     data%State%TD_String%DlTotal = data%State%TD_DrillStems(data%State%TD_String%DrillStemComponentsNumbs)%DlTotal
    
    
    
    
!!=====> Modified Length of the Drill Stem
!    do i = 1 , data%State%TD_String%DrillStemComponentsNumbs 
!     data%State%TD_DrillStems(i)%Length = data%State%TD_DrillStems(i)%Length + data%State%TD_DrillStems(i)%Dl
!    end do
   
   
end subroutine