subroutine Fluid_Flow_Solver
    
    Use GeoElements_FluidModule
    use UTUBEVARSModule
    use KickVARIABLESModule
    use PressureDisplayVARIABLESModule
    USE FricPressDropVarsModule
    USE MudSystemVARIABLES
use SimulationVariables !@@@
    USE Fluid_Flow_Startup_Vars
    USE CError
    
    implicit none
    INTEGER :: FlowDuration
    Integer :: qwer
    integer,dimension(8) :: FlowStartTime,FlowEndTime
    
    !WRITE (*,*) ' fluid flow pointer 1'
    CALL TD_MainCalculations
    
    Call MeshGeneration_FluidModule
    
    !WRITE (*,*) ' fluid flow pointer 2'
    
    data%State%MudSystem%FluidFlowCounter = data%State%MudSystem%FluidFlowCounter + 1
     
    call CirculationCodeSelect
    

    CALL WellPressureDataTransfer
        
    CALL FormationInformationCalculator
        
    DO KickIteration = 1 , 40

        !WRITE (*,*) ' Kick Iteration', KickIteration
        
        CALL PressureAnnAndOHDistribution
            
        IF (KickVARIABLES%NoGasPocket > 0) THEN
            !KickCorrectionVector(:) = 1.
            CALL GasKickCalculator
        END IF
            
        IF (KickVARIABLES%NoGasPocket == 0 .OR. NOT(KickVARIABLES%WellHeadOpen)) EXIT
        IF(MAXVAL(ABS(KickVARIABLES%KickVandPFunction(:))) < KickConvergenceTolerance) EXIT
        !IF(MAXVAL(ABS(KickCorrectionVector(:))) < KickConvergenceTolerance) EXIT
            
            
    END DO
                
    CALL PressureHorizAndStringDistribution
        
    IF (KickIteration == 41) THEN
        WRITE (*,*) ' KickCorrectionVector ' , KickVARIABLES%KickCorrectionVector
        WRITE (*,*) ' Kick Jacobian = ', KickVARIABLES%KickJacobian
    END IF
                
end subroutine