|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389 |
- module CManifolds
- use CStack
- use CArrangement
- use CPathChangeEvents
- use CDrillingConsoleVariables, only: IRSafetyValveLed, IRIBopLed, OpenKellyCockLed, CloseKellyCockLed, OpenSafetyValveLed, CloseSafetyValveLed
- implicit none
-
- public
- integer, parameter :: ValveCount = 128
- integer, parameter :: MinSource = 71
- integer, parameter :: MaxSource = 90
- integer, parameter :: MinRelation = 91
- integer, parameter :: MaxRelation = 128
- type(Arrangement) :: Valve(ValveCount)
- type(Path), allocatable :: OpenPaths(:)
- type(Stack) :: Fringe
- logical :: IsRepititveOutput
-
- logical :: IsSafetyValveInstalled
- logical :: IsSafetyValveInstalled_KellyMode
- logical :: IsSafetyValveInstalled_TripMode
- logical :: IsSafetyValveInstalled_TopDrive
- logical :: SafetyValve
- logical :: IsIBopInstalled
- logical :: IBop
- logical :: IsKellyCockInstalled
- logical :: KellyCock
- logical :: IsTopDriveIBopInstalled
- logical :: TopDriveIBop
- logical :: IsFloatValveInstalled
- logical :: FloatValve
-
- logical :: IsPathsDirty = .false.
-
- logical :: IsTraverse = .false.
-
- contains
-
- subroutine PathFinding_Setup()
- use CSimulationVariables
- implicit none
- IsTraverse = .false.
- call Setup()
- !call OnSimulationInitialization%Add(PathFinding_Init)
- !call OnSimulationStop%Add(PathFinding_Init)
- !call OnPathFindingStep%Add(PathFinding_Step)
- !call OnPathFindingOutput%Add(PathFinding_Output)
- call OnPathFindingMain%Add(PathFindingMainBody)
- end subroutine
-
- subroutine PathFinding_Init
- implicit none
- IsTraverse = .false.
- call Setup()
- end subroutine PathFinding_Init
-
- subroutine PathFinding_Step
- implicit none
- end subroutine PathFinding_Step
-
- subroutine PathFinding_Output
- implicit none
- end subroutine PathFinding_Output
-
- subroutine PathFindingMainBody
- use CSimulationVariables
- implicit none
- loop : do
- if(IsStopped) call Quit()
- call sleepqq(50)
- if (IsPathsDirty) then
- IsPathsDirty = .false.
- call Traverse()
- endif
- end do loop
- end subroutine PathFindingMainBody
-
- subroutine Traverse()
- use CLog5
- implicit none
- integer :: i, Duration
- integer, dimension(8) :: StartTime,EndTime !TODO: clean up
- call DATE_AND_TIME(values=StartTime) !TODO: clean up
-
- call BeforeTraverse%RunAll()
-
-
- if(allocated(OpenPaths)) deallocate(OpenPaths)
- do i=MinSource, MaxSource
- if(IsValveOpen(i)) then
- call AddRootNode(i)
- call AddChildren(Valve(i))
- endif
- enddo
-
- call PostProcess(OpenPaths)
-
- call AfterTraverse%RunAll()
-
- IsTraverse = .true.
-
- !TODO: clean up
- #ifdef Log5
- CALL DATE_AND_TIME(values=EndTime)
- Duration= EndTime(8) - StartTime(8)
- !print*, 'Duration= ', Duration, 'ms'
- call Log_5('Duration= ', Duration)
- call DisplayOpenPaths()
-
- call Log_5('==========================================')
- #endif
-
- endsubroutine
-
- subroutine PostProcess(pathArr)
- implicit none
- type(Path), allocatable, intent(inout) :: pathArr(:)
- integer :: i
-
- if(.not.allocated(pathArr)) return
-
- i = 1
- do
- call pathArr(i)%Purge(MinRelation, MaxRelation)
-
- if(pathArr(i)%Length() <= 2) then
- call RemovePath(pathArr, i)
- else
- i = i + 1
- endif
-
- if(i > size(pathArr)) exit
- enddo
-
- end subroutine
-
- subroutine AddRootNode(valve)
- implicit none
- integer, intent(in) :: valve
- call Fringe%Push(valve)
- end subroutine
-
- recursive subroutine AddChildren(node)
- implicit none
- type(Arrangement), intent(inout) :: node
- integer :: i,t
-
- do i=1, Valve(node%Number)%Length()
- t = Valve(node%Number)%Adjacent(i)
-
- if(IsValveOpen(t)) then
-
- if(Fringe%DoesHave(t)) cycle
-
- call Fringe%Push(t)
-
- if(Valve(t)%IsSource()) then
- call AddPath(OpenPaths, Fringe%List)
- call Fringe%Pop()
- cycle
- endif
-
- call AddChildren(Valve(node%Adjacent(i)))
-
- end if
- enddo
- call Fringe%Pop()
- end subroutine
-
- logical function IsValveOpen(no)
- implicit none
- integer, intent(in) :: no
-
- IsValveOpen = Valve(no)%Status
-
- end function
-
- subroutine AddPath(pathArr, p)
- implicit none
- type(Path), intent(in) :: p
- type(Path), allocatable, intent(inout) :: pathArr(:)
- type(Path), allocatable :: tempArr(:)
- integer :: i, isize
-
- if(p%IsNull()) return
- if(p%Length()<=1) return
-
- call OnPathOpen%RunAll(p%Valves)
-
- if(allocated(pathArr)) then
- isize = size(pathArr)
-
-
- ! check to see if already have a path same as p
- do i=1,isize
- if(pathArr(i)%First()==p%First() .and. pathArr(i)%Last()==p%Last()) then
- ! if there is then
- ! check to see if both have exacly a same length
- if(pathArr(i)%Length()==p%Length())then
- ! now they are the same so ignore adding this one
- return
- else
- !if they have different lengths then choose the shorter one
- if(pathArr(i)%Length()>p%Length())pathArr(i) = p
- return
- endif
-
- endif
- end do
-
-
-
- !TODO: if p last valve is input source then ignore adding it
- !TODO: if p start valve is output source then ignore adding it
-
-
-
- ! if p is a new entry then add it to the collections of found paths
- allocate(tempArr(isize+1))
- do i=1,isize
- tempArr(i) = pathArr(i)
- end do
- tempArr(isize+1) = p
- deallocate(pathArr)
- call move_alloc(tempArr, pathArr)
- else
- allocate(pathArr(1))
- pathArr(1) = p
- end if
-
- endsubroutine
-
- subroutine RemovePath(pathArr, index)
- implicit none
- integer, intent(in) :: index
- type(Path), allocatable, intent(inout) :: pathArr(:)
- type(Path), allocatable :: tempArr(:)
- integer :: i
- logical :: found
-
- if(index <= 0 .or. index > size(pathArr)) return
- if(.not.allocated(pathArr))return
- allocate(tempArr(size(pathArr)-1))
- found = .false.
- do i=1, size(pathArr)
- if(i==index) then
- found = .true.
- cycle
- end if
- if(found) then
- tempArr(i-1) = pathArr(i)
- !call OnPathClose%RunAll(pathArr(i)%Valves)
- else
- tempArr(i) = pathArr(i)
- endif
- end do
- deallocate(pathArr)
- call move_alloc(tempArr, pathArr)
-
- endsubroutine
-
- subroutine Setup()
- implicit none
- integer :: i
-
- ! initialize all valves
- do i = 1, ValveCount
- call Valve(i)%init(i)
- end do
-
- ! open source valves
- do i = MinSource , MaxSource
- Valve(i)%Status = .true.
- Valve(i)%ValveType = InputOutput
- end do
-
- do i = MinRelation , MaxRelation
- Valve(i)%Status = .true.
- Valve(i)%ValveType = Relation
- end do
-
-
-
- ! make adjustments
- call Valve(1)%AdjacentTo(91)
-
- call Valve(2)%AdjacentTo(92)
- call Valve(2)%AdjacentTo(117)
-
- call Valve(3)%AdjacentTo(93)
- call Valve(3)%AdjacentTo(118)
-
- call Valve(4)%AdjacentTo(94)
-
- call Valve(5)%AdjacentTo(95)
-
- call Valve(6)%AdjacentTo(91)
- call Valve(6)%AdjacentTo(92)
-
- call Valve(7)%AdjacentTo(92)
- call Valve(7)%AdjacentTo(93)
-
- call Valve(8)%AdjacentTo(93)
- call Valve(8)%AdjacentTo(94)
-
- call Valve(9)%AdjacentTo(91)
- call Valve(9)%AdjacentTo(96)
-
- call Valve(10)%AdjacentTo(94)
- call Valve(10)%AdjacentTo(98)
-
- call Valve(11)%AdjacentTo(96)
- call Valve(11)%AdjacentTo(97)
-
- call Valve(12)%AdjacentTo(97)
- call Valve(12)%AdjacentTo(98)
-
- call Valve(13)%AdjacentTo(96)
- call Valve(13)%AdjacentTo(99)
-
- call Valve(14)%AdjacentTo(78)
- call Valve(14)%AdjacentTo(97)
- !call Valve(14)%AdjacentTo(126)
-
- call Valve(15)%AdjacentTo(98)
- call Valve(15)%AdjacentTo(99)
-
- call Valve(16)%AdjacentTo(121)
- !call Valve(16)%AdjacentTo()
-
- call Valve(17)%AdjacentTo(122)
- !call Valve(17)%AdjacentTo()
-
- call Valve(18)%AdjacentTo(123)
- !call Valve(18)%AdjacentTo()
-
- call Valve(19)%AdjacentTo(101)
- call Valve(19)%AdjacentTo(102)
-
- call Valve(20)%AdjacentTo(100)
-
- call Valve(21)%AdjacentTo(101)
-
- call Valve(22)%AdjacentTo(102)
-
- call Valve(23)%AdjacentTo(71)
-
- call Valve(24)%AdjacentTo(71)
-
- call Valve(25)%AdjacentTo(108)
- call Valve(25)%AdjacentTo(118)
-
- call Valve(26)%AdjacentTo(109)
- call Valve(26)%AdjacentTo(117)
-
- call Valve(27)%AdjacentTo(32)
- call Valve(27)%AdjacentTo(108)
-
- call Valve(28)%AdjacentTo(33)
- call Valve(28)%AdjacentTo(108)
-
- call Valve(29)%AdjacentTo(110)
- call Valve(29)%AdjacentTo(113)
-
- call Valve(30)%AdjacentTo(34)
- call Valve(30)%AdjacentTo(109)
-
- call Valve(31)%AdjacentTo(35)
- call Valve(31)%AdjacentTo(109)
-
- call Valve(32)%AdjacentTo(27)
- call Valve(32)%AdjacentTo(61)
-
- call Valve(33)%AdjacentTo(28)
- call Valve(33)%AdjacentTo(62)
-
- call Valve(34)%AdjacentTo(30)
- call Valve(34)%AdjacentTo(63)
-
- call Valve(35)%AdjacentTo(31)
- call Valve(35)%AdjacentTo(64)
-
- call Valve(36)%AdjacentTo(116)
-
- call Valve(37)%AdjacentTo(78)
-
- call Valve(38)%AdjacentTo(71)
-
- call Valve(39)%AdjacentTo(77)
-
- !call Valve(40)%AdjacentTo(105)
- call Valve(40)%AdjacentTo(80)
-
- call Valve(41)%AdjacentTo(77)
-
- call Valve(42)%AdjacentTo(71)
-
- call Valve(43)%AdjacentTo(106)
-
- call Valve(44)%AdjacentTo(77)
-
- call Valve(45)%AdjacentTo(71)
-
- call Valve(46)%AdjacentTo(104)
-
- call Valve(47)%AdjacentTo(104)
- call Valve(47)%AdjacentTo(117)
-
- call Valve(48)%AdjacentTo(69)
- call Valve(48)%AdjacentTo(79)
-
- call Valve(49)%AdjacentTo(104)
- call Valve(49)%AdjacentTo(79)
-
- !call Valve(50)%AdjacentTo(48)
- call Valve(50)%AdjacentTo(51)
- !call Valve(50)%AdjacentTo(54)
- call Valve(50)%AdjacentTo(104)
-
- call Valve(51)%AdjacentTo(50)
- call Valve(51)%AdjacentTo(52)
-
- call Valve(52)%AdjacentTo(51)
- !call Valve(52)%AdjacentTo(127)
- call Valve(52)%AdjacentTo(80)
-
- !call Valve(53)%AdjacentTo(103)
- !call Valve(53)%AdjacentTo(105)
- call Valve(53)%AdjacentTo(80)
-
- !call Valve(54)%AdjacentTo(69)
- !call Valve(54)%AdjacentTo(124)
-
- !call Valve(55)%AdjacentTo(103)
- !call Valve(55)%AdjacentTo(124)
-
- call Valve(56)%AdjacentTo(128)
- call Valve(56)%AdjacentTo(127)
-
- !call Valve(57)%AdjacentTo(14)
- !call Valve(57)%AdjacentTo(103)
- !call Valve(57)%AdjacentTo(126)
-
- call Valve(58)%AdjacentTo(78)
-
- call Valve(59)%AdjacentTo(78)
-
- call Valve(60)%AdjacentTo(78)
-
- call Valve(61)%AdjacentTo(32)
- call Valve(61)%AdjacentTo(115)
-
- call Valve(62)%AdjacentTo(33)
- call Valve(62)%AdjacentTo(114)
-
- call Valve(63)%AdjacentTo(112)
- call Valve(63)%AdjacentTo(34)
-
- call Valve(64)%AdjacentTo(35)
- call Valve(64)%AdjacentTo(111)
-
- call Valve(65)%AdjacentTo(120)
-
- call Valve(66)%AdjacentTo(120)
-
- call Valve(67)%AdjacentTo(73)
-
- call Valve(68)%AdjacentTo(125)
- call Valve(68)%AdjacentTo(126)
-
- call Valve(69)%AdjacentTo(48)
- call Valve(69)%AdjacentTo(124)
-
- !call Valve(70)%AdjacentTo()
- !call Valve(70)%AdjacentTo()
-
- call Valve(71)%AdjacentTo(20)
- call Valve(71)%AdjacentTo(44)
- call Valve(71)%AdjacentTo(59)
-
- call Valve(72)%AdjacentTo(21)
- call Valve(72)%AdjacentTo(23)
-
- call Valve(73)%AdjacentTo(22)
-
- call Valve(74)%AdjacentTo(24)
-
- !call Valve(75)%AdjacentTo()
-
- !call Valve(76)%AdjacentTo()
-
- call Valve(77)%AdjacentTo(43)
- call Valve(77)%AdjacentTo(58)
-
- !call Valve(78)%AdjacentTo()
-
- call Valve(79)%AdjacentTo(48)
- call Valve(79)%AdjacentTo(49)
-
- call Valve(80)%AdjacentTo(52)
- call Valve(80)%AdjacentTo(107)
-
- call Valve(81)%AdjacentTo(53)
-
- call Valve(82)%AdjacentTo(16)
-
- call Valve(83)%AdjacentTo(17)
-
- call Valve(84)%AdjacentTo(18)
-
- !call Valve(85)%AdjacentTo()
-
- !call Valve(86)%AdjacentTo()
-
- !call Valve(87)%AdjacentTo()
-
- !call Valve(88)%AdjacentTo()
-
- !!call Valve(89)%AdjacentTo()
-
- !call Valve(90)%AdjacentTo()
-
- call Valve(91)%AdjacentTo(6)
- call Valve(91)%AdjacentTo(9)
- call Valve(91)%AdjacentTo(75)
-
- call Valve(92)%AdjacentTo(6)
- call Valve(92)%AdjacentTo(7)
- call Valve(92)%AdjacentTo(2)
-
- call Valve(93)%AdjacentTo(3)
- call Valve(93)%AdjacentTo(7)
- call Valve(93)%AdjacentTo(8)
-
- call Valve(94)%AdjacentTo(8)
- call Valve(94)%AdjacentTo(10)
- call Valve(94)%AdjacentTo(95)
-
- call Valve(95)%AdjacentTo(76)
- call Valve(95)%AdjacentTo(94)
-
- call Valve(96)%AdjacentTo(9)
- call Valve(96)%AdjacentTo(11)
- call Valve(96)%AdjacentTo(13)
-
- call Valve(97)%AdjacentTo(11)
- call Valve(97)%AdjacentTo(12)
- call Valve(97)%AdjacentTo(14)
-
- call Valve(98)%AdjacentTo(10)
- call Valve(98)%AdjacentTo(12)
- call Valve(98)%AdjacentTo(15)
-
- call Valve(99)%AdjacentTo(13)
- call Valve(99)%AdjacentTo(15)
- call Valve(99)%AdjacentTo(125)
-
- !call Valve(100)%AdjacentTo(16)
- call Valve(100)%AdjacentTo(82)
- call Valve(100)%AdjacentTo(101)
-
- !call Valve(101)%AdjacentTo(17)
- call Valve(101)%AdjacentTo(19)
- call Valve(101)%AdjacentTo(83)
- call Valve(101)%AdjacentTo(100)
-
- !call Valve(102)%AdjacentTo(18)
- call Valve(102)%AdjacentTo(19)
- call Valve(102)%AdjacentTo(84)
-
- !call Valve(103)%AdjacentTo(53)
- !call Valve(103)%AdjacentTo(56)
- call Valve(103)%AdjacentTo(124)
- !call Valve(103)%AdjacentTo(56)
- !call Valve(103)%AdjacentTo(78)
-
- call Valve(104)%AdjacentTo(46)
- call Valve(104)%AdjacentTo(47)
- call Valve(104)%AdjacentTo(49)
- call Valve(104)%AdjacentTo(50)
-
- !call Valve(105)%AdjacentTo(53)
- !call Valve(105)%AdjacentTo(107)
- !call Valve(105)%AdjacentTo(127)
-
- call Valve(106)%AdjacentTo(40)
- call Valve(106)%AdjacentTo(45)
-
-
- call Valve(107)%AdjacentTo(41)
- !call Valve(107)%AdjacentTo(105)
- call Valve(107)%AdjacentTo(119)
- !call Valve(107)%AdjacentTo(42)
-
- call Valve(108)%AdjacentTo(25)
- call Valve(108)%AdjacentTo(27)
- call Valve(108)%AdjacentTo(28)
- call Valve(108)%AdjacentTo(110)
-
- call Valve(109)%AdjacentTo(26)
- call Valve(109)%AdjacentTo(30)
- call Valve(109)%AdjacentTo(31)
- call Valve(109)%AdjacentTo(110)
-
- call Valve(110)%AdjacentTo(29)
- call Valve(110)%AdjacentTo(85)
- call Valve(110)%AdjacentTo(108)
- call Valve(110)%AdjacentTo(109)
-
- call Valve(111)%AdjacentTo(37)
- call Valve(111)%AdjacentTo(64)
- call Valve(111)%AdjacentTo(112)
-
- call Valve(112)%AdjacentTo(63)
- call Valve(112)%AdjacentTo(111)
- call Valve(112)%AdjacentTo(113)
-
- call Valve(113)%AdjacentTo(29)
- call Valve(113)%AdjacentTo(112)
- call Valve(113)%AdjacentTo(114)
-
- call Valve(114)%AdjacentTo(62)
- call Valve(114)%AdjacentTo(113)
- call Valve(114)%AdjacentTo(115)
-
- call Valve(115)%AdjacentTo(36)
- call Valve(115)%AdjacentTo(61)
- call Valve(115)%AdjacentTo(114)
-
- call Valve(116)%AdjacentTo(38)
- call Valve(116)%AdjacentTo(39)
-
- call Valve(117)%AdjacentTo(2)
- call Valve(117)%AdjacentTo(26)
- call Valve(117)%AdjacentTo(47)
-
- call Valve(118)%AdjacentTo(3)
- call Valve(118)%AdjacentTo(25)
- call Valve(118)%AdjacentTo(46)
-
- call Valve(119)%AdjacentTo(42)
- call Valve(119)%AdjacentTo(60)
- call Valve(119)%AdjacentTo(107)
-
- call Valve(120)%AdjacentTo(71)
-
- !call Valve(121)%AdjacentTo(16)
- call Valve(121)%AdjacentTo(1)
- call Valve(121)%AdjacentTo(65)
-
- !call Valve(122)%AdjacentTo(17)
- call Valve(122)%AdjacentTo(4)
- call Valve(122)%AdjacentTo(66)
-
- !call Valve(123)%AdjacentTo(18)
- call Valve(123)%AdjacentTo(5)
- call Valve(123)%AdjacentTo(67)
-
- !call Valve(124)%AdjacentTo(54)
- !call Valve(124)%AdjacentTo(55)
- call Valve(124)%AdjacentTo(69)
- call Valve(124)%AdjacentTo(103)
-
- call Valve(125)%AdjacentTo(68)
- call Valve(125)%AdjacentTo(99)
- ! call Valve(125)%AdjacentTo(126)
-
- call Valve(126)%AdjacentTo(128)
- call Valve(126)%AdjacentTo(68)
- !call Valve(126)%AdjacentTo(125)
-
- call Valve(127)%AdjacentTo(56)
- call Valve(127)%AdjacentTo(78)
- !call Valve(127)%AdjacentTo(105)
-
- call Valve(128)%AdjacentTo(56)
- call Valve(128)%AdjacentTo(126)
-
-
- ! initialization
- call ChangeValve(60, .true.)
- call RemoveIBop()
- call ToggleFillupHead(.false.)
- call ToggleMudBox(.false.)
- call RemoveTopDriveIBop()
- call InstallSafetyValve_KellyMode()
- call KellyDisconnected()
- end subroutine
-
-
-
- subroutine KellyConnected()
- !use CLog3
- implicit none
-
- call Valve(127)%RemoveAdjacent(78)
-
- call Valve(127)%AdjacentTo(103)
- call Valve(103)%AdjacentTo(127)
-
- #ifdef deb
- print*, 'KellyConnected()'
- !call Log_3( 'KellyConnected()')
- #endif
- IsPathsDirty = .true.
- end subroutine
-
- subroutine KellyDisconnected()
- !use CLog3
- implicit none
-
- call Valve(127)%RemoveAdjacent(103)
- call Valve(103)%RemoveAdjacent(127)
-
- call Valve(127)%AdjacentTo(78)
-
- #ifdef deb
- print*, 'KellyDisconnected()'
- !call Log_3( 'KellyDisconnected()')
- #endif
-
- IsPathsDirty = .true.
-
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine InstallSafetyValve_KellyMode()
- implicit none
- IsSafetyValveInstalled_KellyMode = .true.
-
- call RemoveTopDriveIBop()
-
- ! Remove Safey Valve (54)
- call Valve(124)%RemoveAdjacent(54)
- call Valve(54)%RemoveAdjacent(124)
-
- call Valve(69)%RemoveAdjacent(54)
- call Valve(54)%RemoveAdjacent(69)
-
- ! Remove 126-103 cnn
- call Valve(128)%RemoveAdjacent(127)
- call Valve(127)%RemoveAdjacent(128)
-
- ! now make cnn
- call Valve(124)%AdjacentTo(69)
- call Valve(69)%AdjacentTo(124)
-
- call Valve(128)%AdjacentTo(56)
-
- call Valve(56)%AdjacentTo(128)
- call Valve(56)%AdjacentTo(127)
-
- call Valve(127)%AdjacentTo(56)
-
- #ifdef deb
- print*, 'InstallSafetyValve_KellyMode()'
- #endif
-
- IRSafetyValveLed = 1
- call OpenSafetyValve_KellyMode()
- end subroutine
-
- subroutine RemoveSafetyValve_KellyMode()
- implicit none
- IsSafetyValveInstalled_KellyMode = .false.
-
- call Valve(128)%RemoveAdjacent(56)
- call Valve(56)%RemoveAdjacent(128)
-
- call Valve(127)%RemoveAdjacent(56)
- call Valve(56)%RemoveAdjacent(127)
-
- call Valve(127)%AdjacentTo(128)
- call Valve(128)%AdjacentTo(127)
-
- IRSafetyValveLed = 0
- call CloseSafetyValve_KellyMode()
- OpenSafetyValveLed = 0
- CloseSafetyValveLed = 0
-
- #ifdef deb
- print*, 'RemoveSafetyValve_KellyMode()'
- #endif
-
- end subroutine
-
- subroutine OpenSafetyValve_KellyMode()
- implicit none
- if(.not.IsSafetyValveInstalled_KellyMode) return
- OpenSafetyValveLed = 1
- CloseSafetyValveLed = 0
- SafetyValve = .true.
- call ChangeValve(56, SafetyValve)
-
- #ifdef deb
- print*, 'OpenSafetyValve_KellyMode()'
- #endif
-
- end subroutine
-
- subroutine CloseSafetyValve_KellyMode()
- implicit none
- if(.not.IsSafetyValveInstalled_KellyMode) return
- CloseSafetyValveLed = 1
- OpenSafetyValveLed = 0
- SafetyValve = .false.
- call ChangeValve(56, SafetyValve)
-
- #ifdef deb
- print*, 'CloseSafetyValve_KellyMode()'
- #endif
-
- end subroutine
-
-
-
-
-
-
-
-
-
-
- subroutine InstallSafetyValve_TripMode()
- implicit none
- IsSafetyValveInstalled_TripMode = .true.
-
- call Valve(128)%RemoveAdjacent(56)
- call Valve(56)%RemoveAdjacent(128)
-
- call Valve(127)%RemoveAdjacent(56)
- call Valve(56)%RemoveAdjacent(127)
-
- call Valve(69)%RemoveAdjacent(124)
- call Valve(124)%RemoveAdjacent(69)
-
-
- call Valve(127)%AdjacentTo(128)
- call Valve(128)%AdjacentTo(127)
-
- call Valve(124)%AdjacentTo(54)
- call Valve(54)%AdjacentTo(124)
-
- call Valve(54)%AdjacentTo(69)
- call Valve(69)%AdjacentTo(54)
-
- IRSafetyValveLed = 1
- call OpenSafetyValve_TripMode()
-
- #ifdef deb
- print*, 'InstallSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
- subroutine RemoveSafetyValve_TripMode()
- implicit none
- IsSafetyValveInstalled_TripMode = .false.
-
- call Valve(124)%RemoveAdjacent(54)
- call Valve(54)%RemoveAdjacent(124)
-
- call Valve(54)%RemoveAdjacent(69)
- call Valve(69)%RemoveAdjacent(54)
-
- call Valve(124)%AdjacentTo(69)
- call Valve(69)%AdjacentTo(124)
-
- IRSafetyValveLed = 0
- call CloseSafetyValve_TripMode()
- OpenSafetyValveLed = 0
- CloseSafetyValveLed = 0
-
- #ifdef deb
- print*, 'RemoveSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
- subroutine OpenSafetyValve_TripMode()
- implicit none
- if(.not.IsSafetyValveInstalled_TripMode) return
- OpenSafetyValveLed = 1
- CloseSafetyValveLed = 0
- SafetyValve = .true.
- call ChangeValve(54, SafetyValve)
-
- #ifdef deb
- print*, 'OpenSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
- subroutine CloseSafetyValve_TripMode()
- implicit none
- if(.not.IsSafetyValveInstalled_TripMode) return
- CloseSafetyValveLed = 1
- OpenSafetyValveLed = 0
- SafetyValve = .false.
- call ChangeValve(54, SafetyValve)
-
- #ifdef deb
- print*, 'CloseSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
-
-
-
-
-
-
-
- subroutine InstallSafetyValve_TopDrive()
- implicit none
- IsSafetyValveInstalled_TopDrive = .true.
-
- call Valve(128)%RemoveAdjacent(56)
- call Valve(56)%RemoveAdjacent(128)
-
- call Valve(127)%RemoveAdjacent(56)
- call Valve(56)%RemoveAdjacent(127)
-
- call Valve(69)%RemoveAdjacent(124)
- call Valve(124)%RemoveAdjacent(69)
-
- call Valve(124)%AdjacentTo(54)
- call Valve(54)%AdjacentTo(124)
-
- call Valve(54)%AdjacentTo(69)
- call Valve(69)%AdjacentTo(54)
-
- IRSafetyValveLed = 1
- call OpenSafetyValve_TopDrive()
-
- #ifdef deb
- print*, 'InstallSafetyValve_TopDrive()'
- #endif
-
- end subroutine
-
- subroutine RemoveSafetyValve_TopDrive()
- implicit none
- IsSafetyValveInstalled_TopDrive = .false.
-
- call Valve(124)%RemoveAdjacent(54)
- call Valve(54)%RemoveAdjacent(124)
-
- call Valve(54)%RemoveAdjacent(69)
- call Valve(69)%RemoveAdjacent(54)
-
- call Valve(124)%AdjacentTo(69)
- call Valve(69)%AdjacentTo(124)
-
- IRSafetyValveLed = 0
- call CloseSafetyValve_TopDrive()
- OpenSafetyValveLed = 0
- CloseSafetyValveLed = 0
-
- #ifdef deb
- print*, 'RemoveSafetyValve_TopDrive()'
- #endif
-
- end subroutine
-
- subroutine OpenSafetyValve_TopDrive()
- implicit none
- if(.not.IsSafetyValveInstalled_TopDrive) return
- OpenSafetyValveLed = 1
- CloseSafetyValveLed = 0
- SafetyValve = .true.
-
- #ifdef deb
- print*, 'OpenSafetyValve_TopDrive()'
- #endif
-
- call ChangeValve(54, SafetyValve)
- end subroutine
-
- subroutine CloseSafetyValve_TopDrive()
- implicit none
- if(.not.IsSafetyValveInstalled_TopDrive) return
- CloseSafetyValveLed = 1
- OpenSafetyValveLed = 0
- SafetyValve = .false.
-
- #ifdef deb
- print*, 'CloseSafetyValve_TopDrive()'
- #endif
-
- call ChangeValve(54, SafetyValve)
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine InstallIBop()
- implicit none
- IsIBopInstalled = .true.
-
- call Valve(103)%RemoveAdjacent(124)
- call Valve(124)%RemoveAdjacent(103)
-
- call Valve(55)%AdjacentTo(103)
- call Valve(55)%AdjacentTo(124)
-
- call Valve(103)%AdjacentTo(55)
- call Valve(124)%AdjacentTo(55)
-
- #ifdef deb
- print*, 'InstallIBop()'
- #endif
-
- IRIBopLed = 1
- call OpenIBop()
- end subroutine
-
- subroutine RemoveIBop()
- implicit none
- IsIBopInstalled = .false.
-
- call Valve(55)%RemoveAdjacent(103)
- call Valve(55)%RemoveAdjacent(124)
-
- call Valve(103)%RemoveAdjacent(55)
- call Valve(124)%RemoveAdjacent(55)
-
- call Valve(103)%AdjacentTo(124)
- call Valve(124)%AdjacentTo(103)
-
- #ifdef deb
- print*, 'RemoveIBop()'
- #endif
-
- IRIBopLed = 0
- IBop = .false.
- call ChangeValve(55, IBop)
- end subroutine
-
- subroutine OpenIBop()
- implicit none
- if(.not.IsIBopInstalled) return
- IBop = .true.
-
- #ifdef deb
- print*, 'OpenIBop()'
- #endif
-
- call ChangeValve(55, IBop)
- end subroutine
-
- subroutine CloseIBop()
- implicit none
- if(.not.IsIBopInstalled) return
- IBop = .false.
-
- #ifdef deb
- print*, 'CloseIBop()'
- #endif
-
- call ChangeValve(55, IBop)
- end subroutine
-
-
-
-
-
-
- subroutine InstallKellyCock()
- implicit none
- IsKellyCockInstalled = .true.
-
- call Valve(125)%RemoveAdjacent(126)
- call Valve(126)%RemoveAdjacent(125)
-
- call Valve(125)%AdjacentTo(68)
-
- call Valve(68)%AdjacentTo(125)
- call Valve(68)%AdjacentTo(126)
-
- call Valve(126)%AdjacentTo(68)
-
- #ifdef deb
- print*, 'InstallKellyCock()'
- #endif
-
- call OpenKellyCock()
- end subroutine
-
- subroutine RemoveKellyCock()
- implicit none
- IsKellyCockInstalled = .false.
-
- call Valve(125)%RemoveAdjacent(68)
- call Valve(126)%RemoveAdjacent(68)
-
- call Valve(68)%RemoveAdjacent(125)
- call Valve(68)%RemoveAdjacent(126)
-
- call Valve(125)%AdjacentTo(126)
- call Valve(126)%AdjacentTo(125)
-
- KellyCock = .false.
- call ChangeValve(68, KellyCock)
- CloseKellyCockLed = 0
- OpenKellyCockLed = 0
-
- #ifdef deb
- print*, 'RemoveKellyCock()'
- #endif
-
- end subroutine
-
- subroutine OpenKellyCock()
- implicit none
- if(.not.IsKellyCockInstalled) return
- OpenKellyCockLed = 1
- CloseKellyCockLed = 0
- KellyCock = .true.
-
- #ifdef deb
- print*, 'OpenKellyCock()'
- #endif
-
- call ChangeValve(68, KellyCock)
- end subroutine
-
- subroutine CloseKellyCock()
- implicit none
- if(.not.IsKellyCockInstalled) return
- CloseKellyCockLed = 1
- OpenKellyCockLed = 0
- KellyCock = .false.
-
- #ifdef deb
- print*, 'CloseKellyCock()'
- #endif
-
- call ChangeValve(68, KellyCock)
- end subroutine
-
-
-
-
-
-
-
-
- subroutine InstallTopDriveIBop()
- implicit none
- IsTopDriveIBopInstalled = .true.
-
- call Valve(126)%RemoveAdjacent(128)
- call Valve(128)%RemoveAdjacent(126)
-
-
- call Valve(126)%AdjacentTo(70)
- call Valve(70)%AdjacentTo(126)
-
- call Valve(128)%AdjacentTo(70)
- call Valve(70)%AdjacentTo(128)
-
- #ifdef deb
- print*, 'InstallTopDriveIBop()'
- #endif
- call OpenTopDriveIBop()
- end subroutine
-
- subroutine RemoveTopDriveIBop()
- implicit none
- IsTopDriveIBopInstalled = .false.
-
- call Valve(126)%RemoveAdjacent(70)
- call Valve(70)%RemoveAdjacent(126)
-
- call Valve(128)%RemoveAdjacent(70)
- call Valve(70)%RemoveAdjacent(128)
-
- call Valve(126)%AdjacentTo(128)
- call Valve(128)%AdjacentTo(126)
-
- #ifdef deb
- print*, 'RemoveTopDriveIBop()'
- #endif
- TopDriveIBop = .false.
- call ChangeValve(70, TopDriveIBop)
- end subroutine
-
- subroutine OpenTopDriveIBop()
- implicit none
- if(.not.IsTopDriveIBopInstalled) return
- TopDriveIBop = .true.
- call ChangeValve(70, TopDriveIBop)
- #ifdef deb
- print*, 'OpenTopDriveIBop()'
- #endif
- end subroutine
-
- subroutine CloseTopDriveIBop()
- implicit none
- if(.not.IsTopDriveIBopInstalled) return
- TopDriveIBop = .false.
- call ChangeValve(70, TopDriveIBop)
- #ifdef deb
- print*, 'CloseTopDriveIBop()'
- #endif
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine InstallFloatValve()
- implicit none
- IsFloatValveInstalled = .true.
-
- call Valve(69)%RemoveAdjacent(79)
- call Valve(79)%RemoveAdjacent(69)
-
- call Valve(48)%AdjacentTo(69)
- call Valve(48)%AdjacentTo(79)
-
- call Valve(69)%AdjacentTo(48)
- call Valve(79)%AdjacentTo(48)
- #ifdef deb
- print*, 'InstallFloatValve()'
- #endif
- call OpenFloatValve()
- end subroutine
-
- subroutine RemoveFloatValve()
- implicit none
- IsFloatValveInstalled = .false.
-
- call Valve(48)%RemoveAdjacent(69)
- call Valve(48)%RemoveAdjacent(79)
-
- call Valve(69)%RemoveAdjacent(48)
- call Valve(79)%RemoveAdjacent(48)
-
- call Valve(69)%AdjacentTo(79)
- call Valve(79)%AdjacentTo(69)
- #ifdef deb
- print*, 'RemoveFloatValve()'
- #endif
- FloatValve = .false.
- call ChangeValve(48, FloatValve)
- end subroutine
-
- subroutine OpenFloatValve()
- implicit none
- if(.not.IsFloatValveInstalled) return
- FloatValve = .true.
- #ifdef deb
- print*, 'OpenFloatValve()'
- #endif
- call ChangeValve(48, FloatValve)
- end subroutine
-
- subroutine CloseFloatValve()
- implicit none
- if(.not.IsFloatValveInstalled) return
- FloatValve = .false.
- #ifdef deb
- print*, 'CloseFloatValve()'
- #endif
- call ChangeValve(48, FloatValve)
- end subroutine
-
-
-
-
-
-
-
- subroutine ToggleFillupHead(v)
- implicit none
- logical, intent(in) :: v
- if(v) then
- call Valve(14)%RemoveAdjacent(78)
-
- call Valve(14)%AdjacentTo(57)
- call Valve(57)%AdjacentTo(14)
- call Valve(57)%AdjacentTo(103)
- call Valve(103)%AdjacentTo(57)
-
- else
- call Valve(14)%RemoveAdjacent(57)
- call Valve(57)%RemoveAdjacent(14)
- call Valve(57)%RemoveAdjacent(103)
- call Valve(103)%RemoveAdjacent(57)
-
- call Valve(14)%AdjacentTo(78)
- endif
- IsPathsDirty = .true.
- call ChangeValve(57, .true.)
- end subroutine
-
- subroutine ToggleMudBox(v)
- implicit none
- logical, intent(in) :: v
- call ChangeValve(53, v)
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine ToggleMiddleRams(v)
- implicit none
- logical, intent(in) :: v
- Valve(50)%Status = v
- call ChangeValve(69, v)
- end subroutine
-
-
-
-
-
-
-
-
- subroutine ChangeValve(i, state)
- implicit none
- integer, intent(in) :: i
- logical, intent(in) :: state
-
- if(Valve(i)%Status==state) return
- Valve(i)%Status = state
- if(i == 41 .or. i == 42) then
- if(Valve(41)%Status == .false. .and. Valve(42)%Status == .false.) then
- Valve(60)%Status = .true.
- else
- Valve(60)%Status = .false.
- endif
- endif
- #ifdef deb
- print*, 'Valve(', i, ') = ', state
- #endif
- !call Traverse()
- IsPathsDirty = .true.
- end subroutine
-
-
-
-
-
- subroutine DisplayOpenPaths()
- implicit none
- integer :: i
- if(allocated(OpenPaths)) then
- do i = 1, size(OpenPaths)
- call OpenPaths(i)%Display()
- end do
- end if
- end subroutine
-
- subroutine DisplayOpenPathsWrite()
- implicit none
- integer :: i
- if(allocated(OpenPaths)) then
- do i = 1, size(OpenPaths)
- call OpenPaths(i)%DisplayWrite()
- end do
- end if
- end subroutine
-
- end module CManifolds
|