subroutine TD_StartUp
    
    Use CCasingLinerChokeVariables
    Use CStringConfigurationVariables
    ! use CSimulationVariables
    use UnitySignalVariables
    use UnitySignalsModule
    ! use UnitySignalsModuleVariables
    use CHoistingVariables
    use SimulationVariables
    use SimulationVariables !@
    Use TD_DrillStemComponents
    use SimulationVariables !@
    use SimulationVariables !@
    use SimulationVariables !@
    Use TD_StringConnectionData
    use SimulationVariables !@!, only: Drawworks
    Use sROP_Variables
    Use sROP_Other_Variables
   
    
   implicit none
   
   
!!====================================================
!!                Allocate Modules
!!====================================================
!   !=====> Set WellGeo Dimension
!   data%State%TD_WellGeneral%WellIntervalsCount = data%Configuration%Path%ItemCount + 1    ! +1 is belong to ROP hole
!   Allocate (data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount))
!   
!   !=====> Set WellGeo Dimension
   
   
   !=====> Set ROP StartUp
   data%State%ROP_Bit%BitWearing         = 0.d0
   data%State%ROP_Bit%RateOfPenetration  = 0.d0
   data%State%ROP_Bit%BearingWear        = 0.d0
   data%State%ROP_Spec%FormationNumber   = 0
   data%State%ROP_Bit%OldROPDepth        = data%Configuration%Path%Items(data%Configuration%Path%ItemCount)%MeasuredDepth
   data%State%ROP_Bit%OldROPValue        = 0.d0
   data%State%ROP_Bit%SetROPGauge        = 0.d0
   
   
   
   !=====> Set BOP StartUp
   data%State%TD_BOP%BOPCondition = 0
   data%State%TD_BOP%BOPThickness = (0.13477d0/2.d0)*3.28d0 ![m]*3.28=[ft]  , Total Thickness (RAM)= 134.77mm
   data%State%TD_BOP%AnnularFillingFinal = 0.d0
   
   
   data%State%Drawworks%TDHookHeight = 75.d0         ![ft]
   data%State%Drawworks%Hook_Height_ini   = 75.d0    ![ft]
   data%State%Drawworks%Hook_Height_final = 75.d0    ![ft]
   
  
  
   !=====> String Connection Mode
   if ( Get_OperationCondition()==OPERATION_TRIP ) then
       data%State%TD_StConn%OldOperationCondition = 1
   else
       data%State%TD_StConn%OldOperationCondition = 0
   end if
   data%State%TD_StConn%KellyDriveTypeMode = 0          !Kelly Mode
   data%State%TD_StConn%FluidStringConnectionMode = 0
   data%State%TD_StConn%ConnectionHeight = 3.48d0     ![ft]
   data%State%TD_StConn%RigidConnectionHeight  = 3.48d0     ![ft]
   data%State%TD_StConn%GRigidConnectionHeight = 3.48d0     ![ft]
   data%State%TD_String%TopJointHeight  = 3.48d0     ![ft]
   !data%State%TD_StConn%TouchConnectionHeight =
   data%State%TD_StConn%StringVelocity         = 0.0d0
   data%State%TD_StConn%HookHeightOld          = 75.d0      ![ft]
   data%State%TD_StConn%HookHeight             = 75.d0      ![ft]
   data%State%TD_StConn%HookVelocity           = 0.0d0
   
   !=====> Element Specification
   data%State%TD_StConn%HookHeight           = data%State%Drawworks%TDHookHeight        ! unit: [ft]
   data%State%TD_StConn%ElevatorConst        = 17.985                        ! [ft]   Elevator Length(14.84)   ????????????????? adad ha daghigh shavand
   data%State%TD_StConn%ElevatorECG          = 2.217                         ! [ft]
   data%State%TD_StConn%KellyConst           = 63.280d0                      ! [ft]   Kelly Length(61.74) + Safety Valve Length(1.54)
   data%State%TD_StConn%KellyElementConst    = 41.840d0                      ! [ft]   Kelly Element Length(40.3) + Safety Valve Length(1.54)
   data%State%TD_StConn%TDSLength            = 24.08d0  !??????????????????? ! [ft]   
   data%State%TD_StConn%TDSToolJointLength   = 0.77d0  !???????????????????  ! [ft]   
   data%State%TD_StConn%TDSElevatorLength    = 26.837d0   !??????            ! TDS with Elevator Length [ft]
   data%State%TD_StConn%TDSElevatorToolLength= 0.859d0  !??????????????????? ! [ft]
   data%State%TD_StConn%TDSElevatorECG       = 2.454                         ! [ft]
   data%State%TD_Load%NumOfCables            = data%Configuration%Hoisting%NumberOfLine
   data%State%TD_Load%WeightTB               = data%Configuration%Hoisting%TravelingBlockWeight ! [lb]
   data%State%TD_Load%WeightTD               = data%Configuration%Hoisting%TopDriveWeight       ! [lb]
   data%State%TD_Load%KellyWeight            = data%Configuration%Hoisting%KellyWeight          ! [lb]
   data%State%TD_StConn%SafetyValveLength    = 1.54d0                        ! [ft]
   data%State%TD_StConn%IBOPLength           = 1.54d0                        ! [ft]
   data%State%TD_StConn%KellyElementID       = 3.0d0/12.d0                   ! [ft]
   data%State%TD_StConn%KellyElementOD       = 5.90d0/12.d0                  ! [ft]
   data%State%TD_Load%DrawworksLoadInput     = data%Configuration%Hoisting%TravelingBlockWeight/data%Configuration%Hoisting%NumberOfLine
   
   data%State%TD_Count%IBOPNewAdd     = 0
   data%State%TD_Count%IBOPOldAdd     = 0     !Remove
   data%State%TD_Count%SafetyValveNewAdd = 0
   data%State%TD_Count%SafetyValveOldAdd = 1     !Install
   data%State%TD_Count%KellyNewAdd    = 0
   data%State%TD_Count%KellyOldAdd    = 0
   data%State%TD_Count%IBOPNewRemove  = 0
   data%State%TD_Count%IBOPOldRemove  = 1     !Remove
   data%State%TD_Count%SafetyValveNewRemove = 0
   data%State%TD_Count%SafetyValveOldRemove = 0     !Install
   data%State%TD_Count%KellyNewRemove = 0
   data%State%TD_Count%KellyOldRemove = 1
   
   data%State%TD_Count%KellyOldStatus(1) = 0
   data%State%TD_Count%KellyNewStatus(1) = 0
   data%State%TD_Count%KellyOldStatus(2) = 1          ! Kelly Connected Nothing
   data%State%TD_Count%KellyNewStatus(2) = 1          ! Kelly Connected Nothing
   data%State%TD_Count%KellyOldStatus(3) = 0
   data%State%TD_Count%KellyNewStatus(3) = 0
   
   data%State%TD_Count%KellyOldStatus(4) = 0
   data%State%TD_Count%KellyNewStatus(4) = 0
   data%State%TD_Count%KellyOldStatus(5) = 0
   data%State%TD_Count%KellyNewStatus(5) = 0
   data%State%TD_Count%KellyOldStatus(6) = 0
   data%State%TD_Count%KellyNewStatus(6) = 0
   data%State%TD_Count%KellyOldStatus(7) = 0
   data%State%TD_Count%KellyNewStatus(7) = 0
   data%State%TD_Count%KellyOldStatus(8) = 0
   data%State%TD_Count%KellyNewStatus(8) = 0
   data%State%TD_Count%KellyOldStatus(18) = 0
   data%State%TD_Count%KellyNewStatus(18) = 0
   data%State%TD_Count%KellyOldStatus(19) = 0
   data%State%TD_Count%KellyNewStatus(19) = 0
   
   data%State%TD_Count%KellyOldStatus(9)  = 0
   data%State%TD_Count%KellyNewStatus(9)  = 0
   data%State%TD_Count%KellyOldStatus(10) = 0
   data%State%TD_Count%KellyNewStatus(10) = 0
   data%State%TD_Count%KellyOldStatus(11) = 0
   data%State%TD_Count%KellyNewStatus(11) = 0
   data%State%TD_Count%KellyOldStatus(12) = 0
   data%State%TD_Count%KellyNewStatus(12) = 0
   data%State%TD_Count%KellyOldStatus(13) = 1
   data%State%TD_Count%KellyNewStatus(13) = 1
   data%State%TD_Count%KellyOldStatus(14) = 0
   data%State%TD_Count%KellyNewStatus(14) = 0
   data%State%TD_Count%KellyOldStatus(15) = 0
   data%State%TD_Count%KellyNewStatus(15) = 0
   data%State%TD_Count%KellyOldStatus(16) = 0
   data%State%TD_Count%KellyNewStatus(16) = 0
   data%State%TD_Count%KellyOldStatus(17) = 0
   data%State%TD_Count%KellyNewStatus(17) = 0
   
  
   
   
   !=====> Problems
    data%State%TD_General%WeightIndicatorMalf = 0
   
   
end subroutine