subroutine TD_WellElementsReadData
    
   Use CCasingLinerChokeVariables
   use CStringConfigurationVariables
   use SimulationVariables
   use SimulationVariables !@
   use SimulationVariables !@

   implicit none 

   
   Integer :: i
   Real(8)    :: TD_OpenHoleLength
  
   
   
   
!====================================================
!                Set Casing Data
!====================================================
   data%State%TD_WellEl%CasingNumbs = 1
   
   if (Allocated(data%State%TD_Casing)) deAllocate (data%State%TD_Casing)
   Allocate (data%State%TD_Casing(data%State%TD_WellEl%CasingNumbs))
   
   Do i=1, data%State%TD_WellEl%CasingNumbs
       data%State%TD_Casing(i)%Length           = data%Configuration%CasingLinerChoke%CasingDepth              ! unit: [ft]
       data%State%TD_Casing(i)%TopDepth         = 0.d0
       data%State%TD_Casing(i)%DownDepth        = data%State%TD_Casing(i)%Length
       data%State%TD_Casing(i)%Od               = data%Configuration%CasingLinerChoke%CasingOd/12.d0           ! unit: [ft]
       data%State%TD_Casing(i)%Id               = data%Configuration%CasingLinerChoke%CasingId/12.d0           ! unit: [ft]
       data%State%TD_Casing(i)%Weight           = data%Configuration%CasingLinerChoke%CasingWeight
       data%State%TD_Casing(i)%CollapsePressure = data%Configuration%CasingLinerChoke%CasingCollapsePressure
       data%State%TD_Casing(i)%TensileStrength  = data%Configuration%CasingLinerChoke%CasingTensileStrength
   End Do
   
   
   
   
   
!====================================================
!                Set Liner Data
!====================================================
   data%State%TD_WellEl%LinerNumbs = 0
   if(data%Configuration%CasingLinerChoke%LinerLength > 0.d0) then
   data%State%TD_WellEl%LinerNumbs = 1
   
   !if (data%State%TD_WellEl%LinerNumbs>0)  then
       if (Allocated(data%State%TD_Liner)) deAllocate (data%State%TD_Liner)
       Allocate (data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs))
   
       Do i=1, data%State%TD_WellEl%LinerNumbs
           data%State%TD_Liner(i)%TopDepth = data%Configuration%CasingLinerChoke%LinerTopDepth                        ! unit: [ft]
           if (data%State%TD_Liner(i)%TopDepth<data%State%TD_Casing(i)%DownDepth) then
               data%State%TD_Casing(data%State%TD_WellEl%CasingNumbs)%DownDepth = data%State%TD_Liner(i)%TopDepth
           end if
           data%State%TD_Liner(i)%Length           = data%Configuration%CasingLinerChoke%LinerLength                  ! unit: [ft]
           data%State%TD_Liner(i)%DownDepth        = data%State%TD_Liner(i)%TopDepth+data%State%TD_Liner(i)%Length
           data%State%TD_Liner(i)%Od               = data%Configuration%CasingLinerChoke%LinerOd/12.d0                ! unit: [ft]
           data%State%TD_Liner(i)%Id               = data%Configuration%CasingLinerChoke%LinerId/12.d0                ! unit: [ft]
           data%State%TD_Liner(i)%Weight           = data%Configuration%CasingLinerChoke%LinerWeight
           data%State%TD_Liner(i)%CollapsePressure = data%Configuration%CasingLinerChoke%LinerCollapsePressure
           data%State%TD_Liner(i)%TensileStrength  = data%Configuration%CasingLinerChoke%LinerTensileStrength
       End Do
       
   else
        
        if (Allocated(data%State%TD_Liner)) deAllocate (data%State%TD_Liner)
        Allocate (data%State%TD_Liner(1))
        data%State%TD_WellEl%LinerNumbs      = 1
        data%State%TD_Liner%Length    = 0.d0
        data%State%TD_Liner%TopDepth  = data%State%TD_Casing(data%State%TD_WellEl%CasingNumbs)%DownDepth
        data%State%TD_Liner%DownDepth = data%State%TD_Liner%TopDepth
        
   end if
   
   
   
   
   
!====================================================
!                Set Open_Hole Data
!====================================================
   data%State%TD_WellEl%OpenHoleNumbs = 0
   
   TD_OpenHoleLength=data%State%TD_WellGeneral%WellTotalLength-(data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)%DownDepth)
   if(TD_OpenHoleLength > 0.d0) data%State%TD_WellEl%OpenHoleNumbs=1
   
   if (data%State%TD_WellEl%OpenHoleNumbs>0)  then
       if (Allocated(data%State%TD_OpenHole)) deAllocate (data%State%TD_OpenHole)
       Allocate (data%State%TD_OpenHole(data%State%TD_WellEl%OpenHoleNumbs))    !!!??????????????????check
   
       Do i = 1, data%State%TD_WellEl%OpenHoleNumbs
           data%State%TD_OpenHole(i)%TopDepth  = data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)%DownDepth
           data%State%TD_OpenHole(i)%Length    = TD_OpenHoleLength                ! unit: [ft]
           data%State%TD_OpenHole(i)%DownDepth = data%State%TD_OpenHole(i)%TopDepth+data%State%TD_OpenHole(i)%Length
           data%State%TD_OpenHole(i)%Id        = data%Configuration%CasingLinerChoke%OpenHoleId/12.d0                 ! unit: [ft]
       End Do
       
   else
       if (Allocated(data%State%TD_OpenHole)) deAllocate (data%State%TD_OpenHole)
       Allocate (data%State%TD_OpenHole(1))
        data%State%TD_WellEl%OpenHoleNumbs      = 1
        data%State%TD_OpenHole%Length    = 0.d0
        data%State%TD_OpenHole%TopDepth  = data%State%TD_Liner(data%State%TD_WellEl%LinerNumbs)%DownDepth
        data%State%TD_OpenHole%DownDepth = data%State%TD_OpenHole%TopDepth
       
   end if
   
   
   
   
!====================================================
!                Set ROP_Hole Data
!====================================================
   
   data%State%TD_WellEl%ROPHoleNumbs = 1
   if (Allocated(data%State%TD_ROPHole)) deAllocate (data%State%TD_ROPHole)
   Allocate (data%State%TD_ROPHole(data%State%TD_WellEl%ROPHoleNumbs))
   
       Do i = 1, data%State%TD_WellEl%ROPHoleNumbs
           data%State%TD_ROPHole(i)%TopDepth   = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth
           data%State%TD_ROPHole(i)%DownDepth  = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth
           data%State%TD_ROPHole(i)%Length     = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength
           data%State%TD_ROPHole(i)%Id         = data%Configuration%StringConfiguration%BitDefinition%BitSize/12.d0      ! unit: [ft]
       End Do
    
       
       
       
       
       
end subroutine 