subroutine TD_WellElementsReadData
    
   Use CCasingLinerChokeVariables
   use CStringConfigurationVariables
   Use TD_WellElements
   Use TD_WellGeometry

   implicit none 

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