module SimulationVariables
    use Constants
    use json_module
    
    use COperationScenariosVariables
    use CStringConfigurationVariables
    use CFormationVariables
    use CReservoirVariables
    use CShoeVariables
    use CAccumulatorVariables
    use CBopStackVariables
    use CHoistingVariables
    use CPowerVariables
    use CPumpsVariables
    use CRigSizeVariables
    use CCasingLinerChokeVariables
    use CPathGenerationVariables
    use CWellSurveyDataVariables
    use CMudPropertiesVariables

    use CBopControlPanelVariables
    use CChokeControlPanelVariables
    use CChokeManifoldVariables
    use CDataDisplayConsoleVariables
    use CDrillingConsoleVariables
    use CHookVariables
    use CStandPipeManifoldVariables
    use CTopDrivePanelVariables
    use CDrillWatchVariables
    use CTanksVariables
    use COperationScenariosVariables
    use NotificationVariables
    use PermissionsVariables
    use UnitySignalVariables
    use SoftwareInputsVariables

     use CBitProblemsVariables
     use CBopProblemsVariables
     use CChokeProblemsVariables
     use CDrillStemProblemsVariables
     use CGaugesProblemsVariables
     use CHoistingProblemsVariables
     use CKickProblemsVariables
     use CLostProblemsVariables
     use CMudTreatmentProblemsVariables
     use COtherProblemsVariables
     use CPumpProblemsVariables
     use CRotaryProblemsVariables

     use CStudentStationVariables
     use CWarningsVariables

     use BopVariables
    use Pumps_VARIABLES
    use RTable_VARIABLES
    use TopDrive_VARIABLES
    use CHOKEVARIABLES
    use Drawworks_VARIABLES
    USE MudSystemVARIABLES
    use Fluid_Flow_Startup_Vars
    use PressureDisplayVARIABLESModule
    use FricPressDropVarsModule

    use sROP_Other_Variables
    use sROP_Variables

    use GeoElements_FluidModule
    use TD_DrillStemComponents
    use TD_GeneralData
    use TD_StringConnectionData
    use TD_WellElements
    use TD_WellGeometry

    type ConfigurationType
        Type(StringConfigurationType)::StringConfiguration
        Type(FormationType) :: Formation
        Type(ReservoirType)::Reservoir
        Type(ShoeType)::Shoe
        Type(AccumulatorType)::Accumulator
        Type(BopStackSpecificationType)::BopStack
        Type(HoistingType)::Hoisting
        Type(PowerType)::Power
        Type(PumpSpecificationType)::Pumps
        Type(RigSizeType)::RigSize
        Type(CasingLinerChokeType)::CasingLinerChoke
        Type(PathGenerationType)::Path
        ! Type(WellSurveyDataType)::WellSurveyData
        Type(MudPropertiesType)::Mud
    end type ConfigurationType
    
    type EquipmentControlType
        ! Control Panels
        type(BopControlPanelType) :: BopControlPanel
        Type(ChokeControlPanelType)::ChokeControlPanel
        Type(ChokeManifoldType)::ChokeManifold
        Type(DataDisplayConsoleType) :: DataDisplayConsole
        TYPE(DrillingConsoleType) :: DrillingConsole
        Type(HookType)::Hook
        type(StandPipeManifoldType)::StandPipeManifold
        Type(TopDrivePanelType)::TopDrivePanel
        ! Drill Watch
        Type(DrillingWatchType)::DrillingWatch
        Type(TankType)::Tank
    end type EquipmentControlType

    type SimulationStateType
        ! Type(HoistingType)::Hoisting !This ds placed twice in data (onece in configuration, once in state)
        type(OperationScenarioType)::OperationScenario
        type(NotificationType)::notifications
        type(PermissionsType):: permissions
        type(UnitySignalsType):: unitySignals
        type(StudentStationType)::StudentStation
        type(SoftwareInputsType):: softwareInputs
        
        !Bop
         type(BopStackInputType)::BopStackInput
         type(BopStackAccType)::BopStackAcc
         type(RamLineType)::RamLine
         type(AnnularComputationalType)::AnnularComputational
         type(AnnularType)::Annular
         type(PipeRams1Type)::PipeRam1
         type(ShearRamType)::ShearRam
         type(PipeRam2Type)::PipeRam2
         type(ChokeLineType)::ChokeLine
         type(KillLineType)::KillLine
         type(PumpsType)::Pumps
         TYPE(BOP_TypeVars), DIMENSION(1:6) :: RAM
         TYPE(BOP_TypeVars2D) :: RAMS        
        !Choke
        type(ChokeType)::Choke
        type(AirDrivenPumpType)::AirDrivenPump
        type(AirPumpLineType)::AirPumpLine
        TYPE(CHOKE_TypeVars), DIMENSION(1:2) :: CHOOKE
        !
        !!Drawworks
        TYPE(Drawworks_Var) :: Drawworks
        !!
        !!!MudSystem
        type(MudSystemType)::MudSystem    
        TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD  
        
        !!Pumps
        Type(Pumps_Var) :: MPumps
        TYPE(Pump_Var), DIMENSION(1:3) :: PUMP
        !
        TYPE(RTable_Var) :: RTable
        TYPE(TDS_Var) :: TDS
        !
        !! FluidFlow
        TYPE(GasData) :: GasType(3)         ! 1 = methane   ,   2 = Hydrogen sulfide   ,   3 = Carbon dioxid
        TYPE(PressureDisplayVARIABLESTYPE) :: PressureDisplay
        ! TYPE(ObservationAndGaugePointsInformations) , ALLOCATABLE :: ObservationPoint(:)
        TYPE(FricPressDropVarsTYPE) :: FricPressDrop
        !
        !Rop
        TYPE(ROPSpecificationInfo) :: ROP_Spec
        TYPE(ROPInfo) :: ROP_Bit

        !TD
        TYPE(Geo_Data) :: TDGeo
        TYPE(F_StringData) , Allocatable :: F_String(:)
        TYPE(F_IntervalsCountsData):: F_Counts
        TYPE(F_IntervalData) , Allocatable :: F_Interval(:)
        TYPE(OD_AnnulusData) :: OD_Annulus(4)

        TYPE(TD_DrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStem
        TYPE(TD_SeparatedDrillStemInfo), ALLOCATABLE, DIMENSION(:) :: TD_DrillStems
        TYPE(TD_StringInfo) :: TD_String
        TYPE(TD_AddRemoveInfo) :: TD_Count
        TYPE(CStringComponents), ALLOCATABLE, DIMENSION(:) :: G_StringElement
        TYPE(TD_RemovedVolumeInfo) :: TD_Vol
        TYPE(TD_GeneralInfo) :: TD_General
        TYPE(TD_BOPInfo) :: TD_BOP
        TYPE(CBopElement) :: TD_BOPElement(4)
        TYPE(TD_StringconnectionInfo) :: TD_StConn
        TYPE(TD_LoadInfo) :: TD_Load
        TYPE(TD_WellElementsInfo) :: TD_WellEl
        TYPE(TD_CasingInfo), ALLOCATABLE, DIMENSION(:) :: TD_Casing
        TYPE(TD_LinerInfo), ALLOCATABLE, DIMENSION(:)  :: TD_Liner
        TYPE(TD_OpenHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_OpenHole
        TYPE(TD_ROPHoleInfo), ALLOCATABLE, DIMENSION(:) :: TD_ROPHole
        TYPE(TD_WellGeneralInfo) :: TD_WellGeneral
        TYPE(TD_WellGeometryData), Allocatable :: TD_WellGeo(:)


    end type SimulationStateType

    type ProblemsType
        type(BitProblemsType)::BitProblems
        type(BopProblemsType)::BopProblems
        type(ChokeProblemsType)::ChokeProblems
        type(DrillStemProblemsType)::DrillStemProblems
        type(GaugesProblemsType)::GaugesProblems
        type(HoistingProblemsType):: HoistingProblems
        type(KickProblemsType)::KickProblems
        type(LostProblemsType)::LostProblems
        type(MudTreatmentProblemsType)::MudTreatmentProblems
        type(OtherProblemsType)::OtherProblems    
        type(PumpProblemsType)::PumpProblems
        type(RotaryProblemsType)::RotaryProblems
    end type ProblemsType

    type SimulationDataType
        type(WarmingsType)::Warnings
        type(SimulationStateType)::State
        type(EquipmentControlType)::EquipmentControl
        type(ConfigurationType)::Configuration
        type(ProblemsType)::problems
    end type SimulationDataType

    type(SimulationDataType)::data
contains
    
end module SimulationVariables
