subroutine TD_MudPropertiesReadData (i)
    
   Use TD_DrillStemComponents
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables !@
   USE FricPressDropVarsModule
   USE MudSystemVARIABLES
use SimulationVariables !@@@

   implicit none 
   
   

   Integer :: i , j , TDmd
   real(8) :: TDden, TDpre, TDtem
  
   
   
!====================================================
!           Set Mud Properties Data
!====================================================
   IF ( ALLOCATED(FlowEl) ) THEN
       if ( i==2 ) then
           TDmd = int(data%State%TD_DrillStems(i)%DownDepthIni-1.d0)
       else
           TDmd = int(data%State%TD_DrillStems(i)%DownDepthIni)
       end if
       Call StringPropertyCalculator (TDmd , TDden, TDpre, TDtem)
       data%State%TD_DrillStems(i)%MudDensityIn  = TDden*7.48051948d0             ! [ppg]*7.48051948=[lb/ft3]
       Call AnnulusPropertyCalculator (TDmd , TDden, TDpre, TDtem)
       data%State%TD_DrillStems(i)%MudDensityOut = TDden*7.48051948d0             ! [ppg]*7.48051948=[lb/ft3]
       data%State%TD_DrillStems(i)%MudWeight     = TDden                          ! [ppg]     ???????????????
   ELSE
       data%State%TD_DrillStems(i)%MudDensityIn  = data%State%TD_DrillStems(i)%MudDensityIn
       data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_DrillStems(i)%MudDensityOut
       data%State%TD_DrillStems(i)%MudWeight     = data%State%TD_DrillStems(i)%MudWeight
   END IF
   
   
   !data%State%TD_DrillStems(i)%Drag = 
   
   
   
   
   
   !IF (ALLOCATED(data%State%TD_String%FluidMudDensity) .and. ALLOCATED(data%State%TD_String%FluidMudStartX) .and. data%State%TD_String%NoStringMudElements/=0) THEN
   !    Do j = TD_StringNoHorizontalMudElements+1,TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements
   !        if ( data%State%TD_DrillStems(i)%DownDepthIni<=data%State%TD_String%FluidMudStartX(j) ) then
   !            exit
   !        end if
   !        data%State%TD_DrillStems(i)%MudDensityIn = data%State%TD_String%FluidMudDensity(j)*7.48051948d0    !10.*7.48051948        ! [ppg]*7.48051948=[lb/ft3] 
   !        !print*, 'data%State%TD_DrillStems(i)%MudDensityIn='    ,data%State%TD_DrillStems(i)%MudDensityIn , i
   !        !print*, 'FlowEl(j)%density='    ,FlowEl(j)%density , i
   !    End Do
   !ELSE
   !    data%State%TD_DrillStems(i)%MudDensityIn = data%State%TD_DrillStems(i)%MudDensityIn       ! [ppg]*7.48051948=[lb/ft3]
   !!    !print*, '=================' , i
   !END IF
   !
   !
   !
   !
   !
   !
   !
   !IF (ALLOCATED(data%State%TD_String%FluidMudDensity) .and. ALLOCATED(data%State%TD_String%FluidMudEndX) .and. data%State%TD_String%NoCasingMudElements/=0) THEN
   !    Do j = (TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+data%State%TD_String%NoCasingMudElements),(TD_StringNoHorizontalMudElements+data%State%TD_String%NoStringMudElements+1),-1
   !        if ( data%State%TD_DrillStems(i)%DownDepthIni<=data%State%TD_String%FluidMudEndX(j) ) then
   !            exit
   !        end if
   !        data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_String%FluidMudDensity(j)*7.48051948d0  !10.*7.48051948        ! [ppg]*7.48051948=[lb/ft3]
   !        data%State%TD_DrillStems(i)%MudWeight     = data%State%TD_String%FluidMudDensity(j)               !10.0                  ! [ppg]     ???????????????
   !    End Do
   !ELSE
   !    data%State%TD_DrillStems(i)%MudDensityOut = data%State%TD_DrillStems(i)%MudDensityOut        ! [ppg]*7.48051948=[lb/ft3]
   !    data%State%TD_DrillStems(i)%MudWeight     = data%State%TD_DrillStems(i)%MudWeight            ! [ppg]     ???????????????
   !END IF
   
   
   
   
   
   
   
   
   data%State%TD_DrillStems(i)%MudPlasticVis = 5.d0+(5.d0*(data%State%TD_DrillStems(i)%MudWeight-8.3d0))    ! [cP]
   !data%State%TD_DrillStems(i)%MudPlasticVis= data%State%TD_DrillStems(i)%MudPlasticVis * 6.71968d-4       ! [cP]*6.71968d-4=[lb/(ft.s)]
   data%State%TD_DrillStems(i)%MudViscosity  = 0.2d0      !data%State%TD_DrillStems(i)%MudPlasticVis
   data%State%TD_DrillStems(i)%MudYieldPoint = 10.d0+(data%State%TD_DrillStems(i)%MudWeight-8.3d0)
   
  
   
   
   
    
end subroutine