module CWarnings
    ! use CWarnings
    use SimulationVariables
    implicit none    
    public
    contains
    subroutine Activate_PumpWithKellyDisconnected()
        implicit none
        if(data%Warnings%PumpWithKellyDisconnected) return
        data%Warnings%PumpWithKellyDisconnected = .true.
        call RunPumpWithKellyDisconnected()            
    end subroutine
    
    subroutine Activate_PumpWithTopdriveDisconnected()
        implicit none
        if(data%Warnings%PumpWithTopdriveDisconnected) return
        data%Warnings%PumpWithTopdriveDisconnected = .true.
        call RunPumpWithTopdriveDisconnected()
    end subroutine
    
    subroutine Activate_Pump1PopOffValveBlown()
        implicit none
        if(data%Warnings%Pump1PopOffValveBlown) return
        data%Warnings%Pump1PopOffValveBlown = .true.
        call RunPump1PopOffValveBlown()
    end subroutine
    
    subroutine Activate_Pump1Failure()
        implicit none
        if(data%Warnings%Pump1Failure) return
        data%Warnings%Pump1Failure = .true.
        call RunPump1Failure()
    end subroutine
    
    subroutine Activate_Pump2PopOffValveBlown()
        implicit none
        if(data%Warnings%Pump2PopOffValveBlown) return
        data%Warnings%Pump2PopOffValveBlown = .true.
        call RunPump2PopOffValveBlown()
    end subroutine
    
    subroutine Activate_Pump2Failure()
        implicit none
        if(data%Warnings%Pump2Failure) return
        data%Warnings%Pump2Failure = .true.
        call RunPump2Failure()
    end subroutine
    
    subroutine Activate_Pump3PopOffValveBlown()
        implicit none
        if(data%Warnings%Pump3PopOffValveBlown) return
        data%Warnings%Pump3PopOffValveBlown = .true.
        call RunPump3PopOffValveBlown()
    end subroutine
    
    subroutine Activate_Pump3Failure()
        implicit none
        if(data%Warnings%Pump3Failure) return
        data%Warnings%Pump3Failure = .true.
        call RunPump3Failure()
    end subroutine
    
    subroutine Activate_DrawworksGearsAbuse()
        implicit none
        if(data%Warnings%DrawworksGearsAbuse) return
        data%Warnings%DrawworksGearsAbuse = .true.
        call RunDrawworksGearsAbuse()
    end subroutine
    
    subroutine Activate_RotaryGearsAbuse()
        implicit none
        if(data%Warnings%RotaryGearsAbuse) return
        data%Warnings%RotaryGearsAbuse = .true.
        call RunRotaryGearsAbuse()
    end subroutine
    
    subroutine Activate_HoistLineBreak()
        implicit none
        if(data%Warnings%HoistLineBreak) return
        data%Warnings%HoistLineBreak = .true.
        call RunHoistLineBreak()
    end subroutine
    
    subroutine Activate_PartedDrillString()
        implicit none
        if(data%Warnings%PartedDrillString) return
        data%Warnings%PartedDrillString = .true.
        call RunPartedDrillString()
    end subroutine
    
    subroutine Activate_ActiveTankOverflow()
        implicit none
        if(data%Warnings%ActiveTankOverflow) return
        data%Warnings%ActiveTankOverflow = .true.
        call RunActiveTankOverflow()
    end subroutine
    
    subroutine Activate_ActiveTankUnderVolume()
        implicit none
        if(data%Warnings%ActiveTankUnderVolume) return
        data%Warnings%ActiveTankUnderVolume = .true.
        call RunActiveTankUnderVolume()
    end subroutine
    
    subroutine Activate_TripTankOverflow()
        implicit none
        if(data%Warnings%TripTankOverflow) return
        data%Warnings%TripTankOverflow = .true.
        call RunTripTankOverflow()
    end subroutine
    
    subroutine Activate_DrillPipeTwistOff()
        implicit none
        if(data%Warnings%DrillPipeTwistOff) return
        data%Warnings%DrillPipeTwistOff = .true.
        call RunDrillPipeTwistOff()
    end subroutine
    
    subroutine Activate_DrillPipeParted()
        implicit none
        if(data%Warnings%DrillPipeParted) return
        data%Warnings%DrillPipeParted = .true.
        call RunDrillPipeParted()
    end subroutine
    
    subroutine Activate_TripWithSlipsSet()
        implicit none
        if(data%Warnings%TripWithSlipsSet) return
        data%Warnings%TripWithSlipsSet = .true.
        call RunTripWithSlipsSet()
    end subroutine
    
    subroutine Activate_Blowout()
        implicit none
        if(data%Warnings%Blowout) return
        data%Warnings%Blowout = .true.
        call RunBlowout()
    end subroutine
    
    subroutine Activate_UndergroundBlowout()
        implicit none
        if(data%Warnings%UndergroundBlowout) return
        data%Warnings%UndergroundBlowout = .true.
        call RunUndergroundBlowout()
    end subroutine
    
    subroutine Activate_MaximumWellDepthExceeded()
        implicit none
        if(data%Warnings%MaximumWellDepthExceeded) return
        data%Warnings%MaximumWellDepthExceeded = .true.
        call RunMaximumWellDepthExceeded()
    end subroutine
    
    subroutine Activate_CrownCollision()
        implicit none
        if(data%Warnings%CrownCollision) return
        data%Warnings%CrownCollision = .true.
        call RunCrownCollision()
    end subroutine
    
    subroutine Activate_FloorCollision()
        implicit none
        if(data%Warnings%FloorCollision) return
        data%Warnings%FloorCollision = .true.
        call RunFloorCollision()
    end subroutine
    
    subroutine Activate_TopdriveRotaryTableConfilict()
        implicit none
        if(data%Warnings%TopdriveRotaryTableConfilict) return
        data%Warnings%TopdriveRotaryTableConfilict = .true.
        call RunTopdriveRotaryTableConfilict()
    end subroutine
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    subroutine Deactivate_PumpWithKellyDisconnected()
        implicit none
        if(.not.data%Warnings%PumpWithKellyDisconnected) return
        data%Warnings%PumpWithKellyDisconnected = .false.
        call RunPumpWithKellyDisconnected()
    end subroutine
    
    subroutine Deactivate_PumpWithTopdriveDisconnected()
        implicit none
        if(.not.data%Warnings%PumpWithTopdriveDisconnected) return
        data%Warnings%PumpWithTopdriveDisconnected = .false.
        call RunPumpWithTopdriveDisconnected()
    end subroutine
    
    subroutine Deactivate_Pump1PopOffValveBlown()
        use CManifolds
        implicit none
        if(.not.data%Warnings%Pump1PopOffValveBlown) return
        data%Warnings%Pump1PopOffValveBlown = .false.
        call ChangeValve(65, .false.)
        call RunPump1PopOffValveBlown()
    end subroutine
    
    subroutine Deactivate_Pump1Failure()
        use CManifolds
        implicit none
        if(.not.data%Warnings%Pump1Failure) return
        data%Warnings%Pump1Failure = .false.
        call RunPump1Failure()
    end subroutine
    
    subroutine Deactivate_Pump2PopOffValveBlown()
        use CManifolds
        implicit none
        if(.not.data%Warnings%Pump2PopOffValveBlown) return
        data%Warnings%Pump2PopOffValveBlown = .false.
        call ChangeValve(66, .false.)
        call RunPump2PopOffValveBlown()
    end subroutine
    
    subroutine Deactivate_Pump2Failure()
        use CManifolds
        implicit none
        if(.not.data%Warnings%Pump2Failure) return
        data%Warnings%Pump2Failure = .false.
        call RunPump2Failure()
    end subroutine
    
    subroutine Deactivate_Pump3PopOffValveBlown()
        use CManifolds
        implicit none
        if(.not.data%Warnings%Pump3PopOffValveBlown) return
        data%Warnings%Pump3PopOffValveBlown = .false.
        call RunPump3PopOffValveBlown()
    end subroutine
    
    subroutine Deactivate_Pump3Failure()
        use CManifolds
        implicit none
        if(.not.data%Warnings%Pump3Failure) return
        data%Warnings%Pump3Failure = .false.
        call RunPump3Failure()
    end subroutine
    
    subroutine Deactivate_DrawworksGearsAbuse()
        implicit none
        if(.not.data%Warnings%DrawworksGearsAbuse) return
        data%Warnings%DrawworksGearsAbuse = .false.
        call RunDrawworksGearsAbuse()
    end subroutine
    
    subroutine Deactivate_RotaryGearsAbuse()
        implicit none
        if(.not.data%Warnings%RotaryGearsAbuse) return
        data%Warnings%RotaryGearsAbuse = .false.
        call RunRotaryGearsAbuse()
    end subroutine
    
    subroutine Deactivate_HoistLineBreak()
        implicit none
        if(.not.data%Warnings%HoistLineBreak) return
        data%Warnings%HoistLineBreak = .false.
        call RunHoistLineBreak()
    end subroutine
    
    subroutine Deactivate_PartedDrillString()
        implicit none
        if(.not.data%Warnings%PartedDrillString) return
        data%Warnings%PartedDrillString = .false.
        call RunPartedDrillString()
    end subroutine
    
    subroutine Deactivate_ActiveTankOverflow()
        implicit none
        if(.not.data%Warnings%ActiveTankOverflow) return
        data%Warnings%ActiveTankOverflow = .false.
        call RunActiveTankOverflow()
    end subroutine
    
    subroutine Deactivate_ActiveTankUnderVolume()
        implicit none
        if(.not.data%Warnings%ActiveTankUnderVolume) return
        data%Warnings%ActiveTankUnderVolume = .false.
        call RunActiveTankUnderVolume()
    end subroutine
    
    subroutine Deactivate_TripTankOverflow()
        implicit none
        if(.not.data%Warnings%TripTankOverflow) return
        data%Warnings%TripTankOverflow = .false.
        call RunTripTankOverflow()
    end subroutine
    
    subroutine Deactivate_DrillPipeTwistOff()
        implicit none
        if(.not.data%Warnings%DrillPipeTwistOff) return
        data%Warnings%DrillPipeTwistOff = .false.
        call RunDrillPipeTwistOff()
    end subroutine
    
    subroutine Deactivate_DrillPipeParted()
        implicit none
        if(.not.data%Warnings%DrillPipeParted) return
        data%Warnings%DrillPipeParted = .false.
        call RunDrillPipeParted()
    end subroutine
    
    subroutine Deactivate_TripWithSlipsSet()
        implicit none
        if(.not.data%Warnings%TripWithSlipsSet) return
        data%Warnings%TripWithSlipsSet = .false.
        call RunTripWithSlipsSet()
    end subroutine
    
    subroutine Deactivate_Blowout()
        implicit none
        if(.not.data%Warnings%Blowout) return
        data%Warnings%Blowout = .false.
        call RunBlowout()
    end subroutine
    
    subroutine Deactivate_UndergroundBlowout()
        implicit none
        if(.not.data%Warnings%UndergroundBlowout) return
        data%Warnings%UndergroundBlowout = .false.
        call RunUndergroundBlowout()
    end subroutine
    
    subroutine Deactivate_MaximumWellDepthExceeded()
        implicit none
        if(.not.data%Warnings%MaximumWellDepthExceeded) return
        data%Warnings%MaximumWellDepthExceeded = .false.
        call RunMaximumWellDepthExceeded()
    end subroutine
    
    subroutine Deactivate_CrownCollision()
        implicit none
        if(.not.data%Warnings%CrownCollision) return
        data%Warnings%CrownCollision = .false.
        call RunCrownCollision()
    end subroutine
    
    subroutine Deactivate_FloorCollision()
        implicit none
        if(.not.data%Warnings%FloorCollision) return
        data%Warnings%FloorCollision = .false.
        call RunFloorCollision()
    end subroutine
    
    subroutine Deactivate_TopdriveRotaryTableConfilict()
        implicit none
        if(.not.data%Warnings%TopdriveRotaryTableConfilict) return
        data%Warnings%TopdriveRotaryTableConfilict = .false.
        call RunTopdriveRotaryTableConfilict()
    end subroutine
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    subroutine RunPumpWithKellyDisconnected()
        implicit none
        ! if(associated(PumpWithKellyDisconnectedPtr)) then 
        !     call PumpWithKellyDisconnectedPtr(data%Warnings%PumpWithKellyDisconnected)          
        ! end if
    end subroutine
    
    subroutine RunPumpWithTopdriveDisconnected()
		implicit none
		! if(associated(PumpWithTopdriveDisconnectedPtr)) then 
		! 	call PumpWithTopdriveDisconnectedPtr(data%Warnings%PumpWithTopdriveDisconnected)
		! end if
    end subroutine
    
    subroutine RunPump1PopOffValveBlown()
		implicit none
		! if(associated(Pump1PopOffValveBlownPtr)) then 
		! 	call Pump1PopOffValveBlownPtr(data%Warnings%Pump1PopOffValveBlown)
		! end if
    end subroutine
    
    subroutine RunPump1Failure()
		! implicit none
		! if(associated(Pump1FailurePtr)) then 
		! 	call Pump1FailurePtr(data%Warnings%Pump1Failure)
		! end if
    end subroutine
    
    subroutine RunPump2PopOffValveBlown()
		! implicit none
		! if(associated(Pump2PopOffValveBlownPtr)) then 
		! 	call Pump2PopOffValveBlownPtr(data%Warnings%Pump2PopOffValveBlown)
		! end if
    end subroutine
    
    subroutine RunPump2Failure()
		implicit none
		! if(associated(Pump2FailurePtr)) then 
		! 	call Pump2FailurePtr(data%Warnings%Pump2Failure)
		! end if
    end subroutine
    
    subroutine RunPump3PopOffValveBlown()
		implicit none
		! if(associated(Pump3PopOffValveBlownPtr)) then 
		! 	call Pump3PopOffValveBlownPtr(data%Warnings%Pump3PopOffValveBlown)
		! end if
    end subroutine
    
    subroutine RunPump3Failure()
		implicit none
		! if(associated(Pump3FailurePtr)) then 
		! 	call Pump3FailurePtr(data%Warnings%Pump3Failure)
		! end if
    end subroutine
    
    subroutine RunDrawworksGearsAbuse()
		implicit none
		! if(associated(DrawworksGearsAbusePtr)) then 
		! 	call DrawworksGearsAbusePtr(data%Warnings%DrawworksGearsAbuse)
		! end if
    end subroutine
    
    subroutine RunRotaryGearsAbuse()
		implicit none
		! if(associated(RotaryGearsAbusePtr)) then 
		! 	call RotaryGearsAbusePtr(data%Warnings%RotaryGearsAbuse)
		! end if
    end subroutine
    
    subroutine RunHoistLineBreak()
		implicit none
		! if(associated(HoistLineBreakPtr)) then 
		! 	call HoistLineBreakPtr(data%Warnings%HoistLineBreak)
		! end if
    end subroutine
    
    subroutine RunPartedDrillString()
		implicit none
		! if(associated(PartedDrillStringPtr)) then 
		! 	call PartedDrillStringPtr(data%Warnings%PartedDrillString)
		! end if
    end subroutine
    
    subroutine RunActiveTankOverflow()
		implicit none
		! if(associated(ActiveTankOverflowPtr)) then 
		! 	call ActiveTankOverflowPtr(data%Warnings%ActiveTankOverflow)
		! end if
    end subroutine
    
    subroutine RunActiveTankUnderVolume()
		implicit none
		! if(associated(ActiveTankUnderVolumePtr)) then 
			! call ActiveTankUnderVolumePtr(data%Warnings%ActiveTankUnderVolume)
		! end if
    end subroutine
    
    subroutine RunTripTankOverflow()
		implicit none
		! if(associated(TripTankOverflowPtr)) then 
			! call TripTankOverflowPtr(data%Warnings%TripTankOverflow)
		! end if
    end subroutine
    
    subroutine RunDrillPipeTwistOff()
		implicit none
		! if(associated(DrillPipeTwistOffPtr)) then 
			! call DrillPipeTwistOffPtr(data%Warnings%DrillPipeTwistOff)
		! end if
    end subroutine
    
    subroutine RunDrillPipeParted()
		implicit none
		! if(associated(DrillPipePartedPtr)) then 
			! call DrillPipePartedPtr(data%Warnings%DrillPipeParted)
		! end if
    end subroutine
    
    subroutine RunTripWithSlipsSet()
		implicit none
		! if(associated(TripWithSlipsSetPtr)) then 
			! call TripWithSlipsSetPtr(data%Warnings%TripWithSlipsSet)
		! end if
    end subroutine
    
    subroutine RunBlowout()
		implicit none
		! if(associated(BlowoutPtr)) then 
			! call BlowoutPtr(data%Warnings%Blowout)
		! end if
    end subroutine
    
    subroutine RunUndergroundBlowout()
		implicit none
		! if(associated(UndergroundBlowoutPtr)) then 
			! call UndergroundBlowoutPtr(data%Warnings%UndergroundBlowout)
		! end if
    end subroutine
    
    subroutine RunMaximumWellDepthExceeded()
		implicit none
		! if(associated(MaximumWellDepthExceededPtr)) then 
			! call MaximumWellDepthExceededPtr(data%Warnings%MaximumWellDepthExceeded)
		! end if
    end subroutine
    
    subroutine RunCrownCollision()
		implicit none
		! if(associated(CrownCollisionPtr)) then 
			! call CrownCollisionPtr(data%Warnings%CrownCollision)
		! end if
    end subroutine
    
    subroutine RunFloorCollision()
		implicit none
		! if(associated(FloorCollisionPtr)) then 
			! call FloorCollisionPtr(data%Warnings%FloorCollision)
		! end if
    end subroutine
    
    subroutine RunTopdriveRotaryTableConfilict()
		implicit none
		! if(associated(TopdriveRotaryTableConfilictPtr)) then 
			! call TopdriveRotaryTableConfilictPtr(data%Warnings%TopdriveRotaryTableConfilict)
		! end if
    end subroutine

end module CWarnings