subroutine TD_WellGeoConfiguration
    
   Use TD_DrillStemComponents
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables !@
   Use sROP_Variables
   use CDataDisplayConsole
    use SimulationVariables
   use CWarnings
   
   

   implicit none 
  

!====================================================
!         Well Geometry Data Modification
!====================================================
   
   
!=====> ROP Calculation
   if ( data%State%TD_DrillStems(1)%ComponentType==0 .and. data%Warnings%MaximumWellDepthExceeded==.false. ) then
       Call ROP_MainCalculation
   else
       data%State%ROP_Bit%RateOfPenetration = 0.d0
       Call Set_ROP(data%State%ROP_Bit%RateOfPenetration)
   end if
   
   
   
   
!=====> ROPHole Data correction
   data%State%TD_WellEl%ROP = (data%State%ROP_Bit%RateOfPenetration/3600.d0)   ! [ft/s]
   data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth  = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%VerticalDepth++((data%State%TD_WellEl%ROP*data%State%TD_General%TimeStep)*cos(data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle))
   data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength+(data%State%TD_WellEl%ROP*data%State%TD_General%TimeStep)           !????????check
   data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth      = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%TopDepth+data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%IntervalLength
   
   
   
  
   
!=====> Well Total Length Calculation 
   data%State%TD_WellGeneral%WellTotalLength         = data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%DownDepth
   data%State%TD_WellGeneral%WellTotalVerticalLength = data%State%TD_WellGeneral%WellTotalVerticalLength+((data%State%TD_WellEl%ROP*data%State%TD_General%TimeStep)*cos(data%State%TD_WellGeo(data%State%TD_WellGeneral%WellIntervalsCount)%StartAngle))
   
   Call Set_TotalDepth(real(data%State%TD_WellGeneral%WellTotalLength,8))
   
   
   
   
end subroutine