|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390 |
- module CManifolds
- use CStack
- use CArrangement
- use CPathChangeEvents
- use CDrillingConsoleVariables!, only: DrillingConsole%IRSafetyValveLed, DrillingConsole%IRIBopLed, DrillingConsole%OpenKellyCockLed, DrillingConsole%CloseKellyCockLed, DrillingConsole%OpenSafetyValveLed, DrillingConsole%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::ManifoldType
- 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.
- End type ManifoldType
- type(ManifoldType)::Manifold
- contains
-
- subroutine PathFinding_Setup()
- use CSimulationVariables
- implicit none
- Manifold%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
- Manifold%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 (Manifold%IsPathsDirty) then
- Manifold%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(Manifold%OpenPaths)) deallocate(Manifold%OpenPaths)
- do i=MinSource, MaxSource
- if(IsValveOpen(i)) then
- call AddRootNode(i)
- call AddChildren(Manifold%Valve(i))
- endif
- enddo
-
- call PostProcess(Manifold%OpenPaths)
-
- call AfterTraverse%RunAll()
-
- Manifold%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 Manifold%Fringe%Push(valve)
- end subroutine
-
- recursive subroutine AddChildren(node)
- implicit none
- type(Arrangement), intent(inout) :: node
- integer :: i,t
-
- do i=1, Manifold%Valve(node%Number)%Length()
- t = Manifold%Valve(node%Number)%Adjacent(i)
-
- if(IsValveOpen(t)) then
-
- if(Manifold%Fringe%DoesHave(t)) cycle
-
- call Manifold%Fringe%Push(t)
-
- if(Manifold%Valve(t)%IsSource()) then
- call AddPath(Manifold%OpenPaths, Manifold%Fringe%List)
- call Manifold%Fringe%Pop()
- cycle
- endif
-
- call AddChildren(Manifold%Valve(node%Adjacent(i)))
-
- end if
- enddo
- call Manifold%Fringe%Pop()
- end subroutine
-
- logical function IsValveOpen(no)
- implicit none
- integer, intent(in) :: no
-
- IsValveOpen = Manifold%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 Manifold%Valve(i)%init(i)
- end do
-
- ! open source valves
- do i = MinSource , MaxSource
- Manifold%Valve(i)%Status = .true.
- Manifold%Valve(i)%ValveType = InputOutput
- end do
-
- do i = MinRelation , MaxRelation
- Manifold%Valve(i)%Status = .true.
- Manifold%Valve(i)%ValveType = Relation
- end do
-
-
-
- ! make adjustments
- call Manifold%Valve(1)%AdjacentTo(91)
-
- call Manifold%Valve(2)%AdjacentTo(92)
- call Manifold%Valve(2)%AdjacentTo(117)
-
- call Manifold%Valve(3)%AdjacentTo(93)
- call Manifold%Valve(3)%AdjacentTo(118)
-
- call Manifold%Valve(4)%AdjacentTo(94)
-
- call Manifold%Valve(5)%AdjacentTo(95)
-
- call Manifold%Valve(6)%AdjacentTo(91)
- call Manifold%Valve(6)%AdjacentTo(92)
-
- call Manifold%Valve(7)%AdjacentTo(92)
- call Manifold%Valve(7)%AdjacentTo(93)
-
- call Manifold%Valve(8)%AdjacentTo(93)
- call Manifold%Valve(8)%AdjacentTo(94)
-
- call Manifold%Valve(9)%AdjacentTo(91)
- call Manifold%Valve(9)%AdjacentTo(96)
-
- call Manifold%Valve(10)%AdjacentTo(94)
- call Manifold%Valve(10)%AdjacentTo(98)
-
- call Manifold%Valve(11)%AdjacentTo(96)
- call Manifold%Valve(11)%AdjacentTo(97)
-
- call Manifold%Valve(12)%AdjacentTo(97)
- call Manifold%Valve(12)%AdjacentTo(98)
-
- call Manifold%Valve(13)%AdjacentTo(96)
- call Manifold%Valve(13)%AdjacentTo(99)
-
- call Manifold%Valve(14)%AdjacentTo(78)
- call Manifold%Valve(14)%AdjacentTo(97)
- !call Valve(14)%AdjacentTo(126)
-
- call Manifold%Valve(15)%AdjacentTo(98)
- call Manifold%Valve(15)%AdjacentTo(99)
-
- call Manifold%Valve(16)%AdjacentTo(121)
- !call Valve(16)%AdjacentTo()
-
- call Manifold%Valve(17)%AdjacentTo(122)
- !call Valve(17)%AdjacentTo()
-
- call Manifold%Valve(18)%AdjacentTo(123)
- !call Valve(18)%AdjacentTo()
-
- call Manifold%Valve(19)%AdjacentTo(101)
- call Manifold%Valve(19)%AdjacentTo(102)
-
- call Manifold%Valve(20)%AdjacentTo(100)
-
- call Manifold%Valve(21)%AdjacentTo(101)
-
- call Manifold%Valve(22)%AdjacentTo(102)
-
- call Manifold%Valve(23)%AdjacentTo(71)
-
- call Manifold%Valve(24)%AdjacentTo(71)
-
- call Manifold%Valve(25)%AdjacentTo(108)
- call Manifold%Valve(25)%AdjacentTo(118)
-
- call Manifold%Valve(26)%AdjacentTo(109)
- call Manifold%Valve(26)%AdjacentTo(117)
-
- call Manifold%Valve(27)%AdjacentTo(32)
- call Manifold%Valve(27)%AdjacentTo(108)
-
- call Manifold%Valve(28)%AdjacentTo(33)
- call Manifold%Valve(28)%AdjacentTo(108)
-
- call Manifold%Valve(29)%AdjacentTo(110)
- call Manifold%Valve(29)%AdjacentTo(113)
-
- call Manifold%Valve(30)%AdjacentTo(34)
- call Manifold%Valve(30)%AdjacentTo(109)
-
- call Manifold%Valve(31)%AdjacentTo(35)
- call Manifold%Valve(31)%AdjacentTo(109)
-
- call Manifold%Valve(32)%AdjacentTo(27)
- call Manifold%Valve(32)%AdjacentTo(61)
-
- call Manifold%Valve(33)%AdjacentTo(28)
- call Manifold%Valve(33)%AdjacentTo(62)
-
- call Manifold%Valve(34)%AdjacentTo(30)
- call Manifold%Valve(34)%AdjacentTo(63)
-
- call Manifold%Valve(35)%AdjacentTo(31)
- call Manifold%Valve(35)%AdjacentTo(64)
-
- call Manifold%Valve(36)%AdjacentTo(116)
-
- call Manifold%Valve(37)%AdjacentTo(78)
-
- call Manifold%Valve(38)%AdjacentTo(71)
-
- call Manifold%Valve(39)%AdjacentTo(77)
-
- !call Valve(40)%AdjacentTo(105)
- call Manifold%Valve(40)%AdjacentTo(80)
-
- call Manifold%Valve(41)%AdjacentTo(77)
-
- call Manifold%Valve(42)%AdjacentTo(71)
-
- call Manifold%Valve(43)%AdjacentTo(106)
-
- call Manifold%Valve(44)%AdjacentTo(77)
-
- call Manifold%Valve(45)%AdjacentTo(71)
-
- call Manifold%Valve(46)%AdjacentTo(104)
-
- call Manifold%Valve(47)%AdjacentTo(104)
- call Manifold%Valve(47)%AdjacentTo(117)
-
- call Manifold%Valve(48)%AdjacentTo(69)
- call Manifold%Valve(48)%AdjacentTo(79)
-
- call Manifold%Valve(49)%AdjacentTo(104)
- call Manifold%Valve(49)%AdjacentTo(79)
-
- !call Valve(50)%AdjacentTo(48)
- call Manifold%Valve(50)%AdjacentTo(51)
- !call Valve(50)%AdjacentTo(54)
- call Manifold%Valve(50)%AdjacentTo(104)
-
- call Manifold%Valve(51)%AdjacentTo(50)
- call Manifold%Valve(51)%AdjacentTo(52)
-
- call Manifold%Valve(52)%AdjacentTo(51)
- !call Valve(52)%AdjacentTo(127)
- call Manifold%Valve(52)%AdjacentTo(80)
-
- !call Valve(53)%AdjacentTo(103)
- !call Valve(53)%AdjacentTo(105)
- call Manifold%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 Manifold%Valve(56)%AdjacentTo(128)
- call Manifold%Valve(56)%AdjacentTo(127)
-
- !call Valve(57)%AdjacentTo(14)
- !call Valve(57)%AdjacentTo(103)
- !call Valve(57)%AdjacentTo(126)
-
- call Manifold%Valve(58)%AdjacentTo(78)
-
- call Manifold%Valve(59)%AdjacentTo(78)
-
- call Manifold%Valve(60)%AdjacentTo(78)
-
- call Manifold%Valve(61)%AdjacentTo(32)
- call Manifold%Valve(61)%AdjacentTo(115)
-
- call Manifold%Valve(62)%AdjacentTo(33)
- call Manifold%Valve(62)%AdjacentTo(114)
-
- call Manifold%Valve(63)%AdjacentTo(112)
- call Manifold%Valve(63)%AdjacentTo(34)
-
- call Manifold%Valve(64)%AdjacentTo(35)
- call Manifold%Valve(64)%AdjacentTo(111)
-
- call Manifold%Valve(65)%AdjacentTo(120)
-
- call Manifold%Valve(66)%AdjacentTo(120)
-
- call Manifold%Valve(67)%AdjacentTo(73)
-
- call Manifold%Valve(68)%AdjacentTo(125)
- call Manifold%Valve(68)%AdjacentTo(126)
-
- call Manifold%Valve(69)%AdjacentTo(48)
- call Manifold%Valve(69)%AdjacentTo(124)
-
- !call Valve(70)%AdjacentTo()
- !call Valve(70)%AdjacentTo()
-
- call Manifold%Valve(71)%AdjacentTo(20)
- call Manifold%Valve(71)%AdjacentTo(44)
- call Manifold%Valve(71)%AdjacentTo(59)
-
- call Manifold%Valve(72)%AdjacentTo(21)
- call Manifold%Valve(72)%AdjacentTo(23)
-
- call Manifold%Valve(73)%AdjacentTo(22)
-
- call Manifold%Valve(74)%AdjacentTo(24)
-
- !call Valve(75)%AdjacentTo()
-
- !call Valve(76)%AdjacentTo()
-
- call Manifold%Valve(77)%AdjacentTo(43)
- call Manifold%Valve(77)%AdjacentTo(58)
-
- !call Valve(78)%AdjacentTo()
-
- call Manifold%Valve(79)%AdjacentTo(48)
- call Manifold%Valve(79)%AdjacentTo(49)
-
- call Manifold%Valve(80)%AdjacentTo(52)
- call Manifold%Valve(80)%AdjacentTo(107)
-
- call Manifold%Valve(81)%AdjacentTo(53)
-
- call Manifold%Valve(82)%AdjacentTo(16)
-
- call Manifold%Valve(83)%AdjacentTo(17)
-
- call Manifold%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 Manifold%Valve(91)%AdjacentTo(6)
- call Manifold%Valve(91)%AdjacentTo(9)
- call Manifold%Valve(91)%AdjacentTo(75)
-
- call Manifold%Valve(92)%AdjacentTo(6)
- call Manifold%Valve(92)%AdjacentTo(7)
- call Manifold%Valve(92)%AdjacentTo(2)
-
- call Manifold%Valve(93)%AdjacentTo(3)
- call Manifold%Valve(93)%AdjacentTo(7)
- call Manifold%Valve(93)%AdjacentTo(8)
-
- call Manifold%Valve(94)%AdjacentTo(8)
- call Manifold%Valve(94)%AdjacentTo(10)
- call Manifold%Valve(94)%AdjacentTo(95)
-
- call Manifold%Valve(95)%AdjacentTo(76)
- call Manifold%Valve(95)%AdjacentTo(94)
-
- call Manifold%Valve(96)%AdjacentTo(9)
- call Manifold%Valve(96)%AdjacentTo(11)
- call Manifold%Valve(96)%AdjacentTo(13)
-
- call Manifold%Valve(97)%AdjacentTo(11)
- call Manifold%Valve(97)%AdjacentTo(12)
- call Manifold%Valve(97)%AdjacentTo(14)
-
- call Manifold%Valve(98)%AdjacentTo(10)
- call Manifold%Valve(98)%AdjacentTo(12)
- call Manifold%Valve(98)%AdjacentTo(15)
-
- call Manifold%Valve(99)%AdjacentTo(13)
- call Manifold%Valve(99)%AdjacentTo(15)
- call Manifold%Valve(99)%AdjacentTo(125)
-
- !call Valve(100)%AdjacentTo(16)
- call Manifold%Valve(100)%AdjacentTo(82)
- call Manifold%Valve(100)%AdjacentTo(101)
-
- !call Valve(101)%AdjacentTo(17)
- call Manifold%Valve(101)%AdjacentTo(19)
- call Manifold%Valve(101)%AdjacentTo(83)
- call Manifold%Valve(101)%AdjacentTo(100)
-
- !call Valve(102)%AdjacentTo(18)
- call Manifold%Valve(102)%AdjacentTo(19)
- call Manifold%Valve(102)%AdjacentTo(84)
-
- !call Valve(103)%AdjacentTo(53)
- !call Valve(103)%AdjacentTo(56)
- call Manifold%Valve(103)%AdjacentTo(124)
- !call Valve(103)%AdjacentTo(56)
- !call Valve(103)%AdjacentTo(78)
-
- call Manifold%Valve(104)%AdjacentTo(46)
- call Manifold%Valve(104)%AdjacentTo(47)
- call Manifold%Valve(104)%AdjacentTo(49)
- call Manifold%Valve(104)%AdjacentTo(50)
-
- !call Valve(105)%AdjacentTo(53)
- !call Valve(105)%AdjacentTo(107)
- !call Valve(105)%AdjacentTo(127)
-
- call Manifold%Valve(106)%AdjacentTo(40)
- call Manifold%Valve(106)%AdjacentTo(45)
-
-
- call Manifold%Valve(107)%AdjacentTo(41)
- !call Valve(107)%AdjacentTo(105)
- call Manifold%Valve(107)%AdjacentTo(119)
- !call Valve(107)%AdjacentTo(42)
-
- call Manifold%Valve(108)%AdjacentTo(25)
- call Manifold%Valve(108)%AdjacentTo(27)
- call Manifold%Valve(108)%AdjacentTo(28)
- call Manifold%Valve(108)%AdjacentTo(110)
-
- call Manifold%Valve(109)%AdjacentTo(26)
- call Manifold%Valve(109)%AdjacentTo(30)
- call Manifold%Valve(109)%AdjacentTo(31)
- call Manifold%Valve(109)%AdjacentTo(110)
-
- call Manifold%Valve(110)%AdjacentTo(29)
- call Manifold%Valve(110)%AdjacentTo(85)
- call Manifold%Valve(110)%AdjacentTo(108)
- call Manifold%Valve(110)%AdjacentTo(109)
-
- call Manifold%Valve(111)%AdjacentTo(37)
- call Manifold%Valve(111)%AdjacentTo(64)
- call Manifold%Valve(111)%AdjacentTo(112)
-
- call Manifold%Valve(112)%AdjacentTo(63)
- call Manifold%Valve(112)%AdjacentTo(111)
- call Manifold%Valve(112)%AdjacentTo(113)
-
- call Manifold%Valve(113)%AdjacentTo(29)
- call Manifold%Valve(113)%AdjacentTo(112)
- call Manifold%Valve(113)%AdjacentTo(114)
-
- call Manifold%Valve(114)%AdjacentTo(62)
- call Manifold%Valve(114)%AdjacentTo(113)
- call Manifold%Valve(114)%AdjacentTo(115)
-
- call Manifold%Valve(115)%AdjacentTo(36)
- call Manifold%Valve(115)%AdjacentTo(61)
- call Manifold%Valve(115)%AdjacentTo(114)
-
- call Manifold%Valve(116)%AdjacentTo(38)
- call Manifold%Valve(116)%AdjacentTo(39)
-
- call Manifold%Valve(117)%AdjacentTo(2)
- call Manifold%Valve(117)%AdjacentTo(26)
- call Manifold%Valve(117)%AdjacentTo(47)
-
- call Manifold%Valve(118)%AdjacentTo(3)
- call Manifold%Valve(118)%AdjacentTo(25)
- call Manifold%Valve(118)%AdjacentTo(46)
-
- call Manifold%Valve(119)%AdjacentTo(42)
- call Manifold%Valve(119)%AdjacentTo(60)
- call Manifold%Valve(119)%AdjacentTo(107)
-
- call Manifold%Valve(120)%AdjacentTo(71)
-
- !call Valve(121)%AdjacentTo(16)
- call Manifold%Valve(121)%AdjacentTo(1)
- call Manifold%Valve(121)%AdjacentTo(65)
-
- !call Valve(122)%AdjacentTo(17)
- call Manifold%Valve(122)%AdjacentTo(4)
- call Manifold%Valve(122)%AdjacentTo(66)
-
- !call Valve(123)%AdjacentTo(18)
- call Manifold%Valve(123)%AdjacentTo(5)
- call Manifold%Valve(123)%AdjacentTo(67)
-
- !call Valve(124)%AdjacentTo(54)
- !call Valve(124)%AdjacentTo(55)
- call Manifold%Valve(124)%AdjacentTo(69)
- call Manifold%Valve(124)%AdjacentTo(103)
-
- call Manifold%Valve(125)%AdjacentTo(68)
- call Manifold%Valve(125)%AdjacentTo(99)
- ! call Valve(125)%AdjacentTo(126)
-
- call Manifold%Valve(126)%AdjacentTo(128)
- call Manifold%Valve(126)%AdjacentTo(68)
- !call Valve(126)%AdjacentTo(125)
-
- call Manifold%Valve(127)%AdjacentTo(56)
- call Manifold%Valve(127)%AdjacentTo(78)
- !call Valve(127)%AdjacentTo(105)
-
- call Manifold%Valve(128)%AdjacentTo(56)
- call Manifold%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 Manifold%Valve(127)%RemoveAdjacent(78)
-
- call Manifold%Valve(127)%AdjacentTo(103)
- call Manifold%Valve(103)%AdjacentTo(127)
-
- #ifdef deb
- print*, 'KellyConnected()'
- !call Log_3( 'KellyConnected()')
- #endif
- Manifold%IsPathsDirty = .true.
- end subroutine
-
- subroutine KellyDisconnected()
- !use CLog3
- implicit none
-
- call Manifold%Valve(127)%RemoveAdjacent(103)
- call Manifold%Valve(103)%RemoveAdjacent(127)
-
- call Manifold%Valve(127)%AdjacentTo(78)
-
- #ifdef deb
- print*, 'KellyDisconnected()'
- !call Log_3( 'KellyDisconnected()')
- #endif
-
- Manifold%IsPathsDirty = .true.
-
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine InstallSafetyValve_KellyMode()
- implicit none
- Manifold%IsSafetyValveInstalled_KellyMode = .true.
-
- call RemoveTopDriveIBop()
-
- ! Remove Safey Valve (54)
- call Manifold%Valve(124)%RemoveAdjacent(54)
- call Manifold%Valve(54)%RemoveAdjacent(124)
-
- call Manifold%Valve(69)%RemoveAdjacent(54)
- call Manifold%Valve(54)%RemoveAdjacent(69)
-
- ! Remove 126-103 cnn
- call Manifold%Valve(128)%RemoveAdjacent(127)
- call Manifold%Valve(127)%RemoveAdjacent(128)
-
- ! now make cnn
- call Manifold%Valve(124)%AdjacentTo(69)
- call Manifold%Valve(69)%AdjacentTo(124)
-
- call Manifold%Valve(128)%AdjacentTo(56)
-
- call Manifold%Valve(56)%AdjacentTo(128)
- call Manifold%Valve(56)%AdjacentTo(127)
-
- call Manifold%Valve(127)%AdjacentTo(56)
-
- #ifdef deb
- print*, 'InstallSafetyValve_KellyMode()'
- #endif
-
- DrillingConsole%IRSafetyValveLed = 1
- call OpenSafetyValve_KellyMode()
- end subroutine
-
- subroutine RemoveSafetyValve_KellyMode()
- implicit none
- Manifold%IsSafetyValveInstalled_KellyMode = .false.
-
- call Manifold%Valve(128)%RemoveAdjacent(56)
- call Manifold%Valve(56)%RemoveAdjacent(128)
-
- call Manifold%Valve(127)%RemoveAdjacent(56)
- call Manifold%Valve(56)%RemoveAdjacent(127)
-
- call Manifold%Valve(127)%AdjacentTo(128)
- call Manifold%Valve(128)%AdjacentTo(127)
-
- DrillingConsole%IRSafetyValveLed = 0
- call CloseSafetyValve_KellyMode()
- DrillingConsole%OpenSafetyValveLed = 0
- DrillingConsole%CloseSafetyValveLed = 0
-
- #ifdef deb
- print*, 'RemoveSafetyValve_KellyMode()'
- #endif
-
- end subroutine
-
- subroutine OpenSafetyValve_KellyMode()
- implicit none
- if(.not.Manifold%IsSafetyValveInstalled_KellyMode) return
- DrillingConsole%OpenSafetyValveLed = 1
- DrillingConsole%CloseSafetyValveLed = 0
- Manifold%SafetyValve = .true.
- call ChangeValve(56, Manifold%SafetyValve)
-
- #ifdef deb
- print*, 'OpenSafetyValve_KellyMode()'
- #endif
-
- end subroutine
-
- subroutine CloseSafetyValve_KellyMode()
- implicit none
- if(.not.Manifold%IsSafetyValveInstalled_KellyMode) return
- DrillingConsole%CloseSafetyValveLed = 1
- DrillingConsole%OpenSafetyValveLed = 0
- Manifold%SafetyValve = .false.
- call ChangeValve(56, Manifold%SafetyValve)
-
- #ifdef deb
- print*, 'CloseSafetyValve_KellyMode()'
- #endif
-
- end subroutine
-
-
-
-
-
-
-
-
-
-
- subroutine InstallSafetyValve_TripMode()
- implicit none
- Manifold%IsSafetyValveInstalled_TripMode = .true.
-
- call Manifold%Valve(128)%RemoveAdjacent(56)
- call Manifold%Valve(56)%RemoveAdjacent(128)
-
- call Manifold%Valve(127)%RemoveAdjacent(56)
- call Manifold%Valve(56)%RemoveAdjacent(127)
-
- call Manifold%Valve(69)%RemoveAdjacent(124)
- call Manifold%Valve(124)%RemoveAdjacent(69)
-
-
- call Manifold%Valve(127)%AdjacentTo(128)
- call Manifold%Valve(128)%AdjacentTo(127)
-
- call Manifold%Valve(124)%AdjacentTo(54)
- call Manifold%Valve(54)%AdjacentTo(124)
-
- call Manifold%Valve(54)%AdjacentTo(69)
- call Manifold%Valve(69)%AdjacentTo(54)
-
- DrillingConsole%IRSafetyValveLed = 1
- call OpenSafetyValve_TripMode()
-
- #ifdef deb
- print*, 'InstallSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
- subroutine RemoveSafetyValve_TripMode()
- implicit none
- Manifold%IsSafetyValveInstalled_TripMode = .false.
-
- call Manifold%Valve(124)%RemoveAdjacent(54)
- call Manifold%Valve(54)%RemoveAdjacent(124)
-
- call Manifold%Valve(54)%RemoveAdjacent(69)
- call Manifold%Valve(69)%RemoveAdjacent(54)
-
- call Manifold%Valve(124)%AdjacentTo(69)
- call Manifold%Valve(69)%AdjacentTo(124)
-
- DrillingConsole%IRSafetyValveLed = 0
- call CloseSafetyValve_TripMode()
- DrillingConsole%OpenSafetyValveLed = 0
- DrillingConsole%CloseSafetyValveLed = 0
-
- #ifdef deb
- print*, 'RemoveSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
- subroutine OpenSafetyValve_TripMode()
- implicit none
- if(.not.Manifold%IsSafetyValveInstalled_TripMode) return
- DrillingConsole%OpenSafetyValveLed = 1
- DrillingConsole%CloseSafetyValveLed = 0
- Manifold%SafetyValve = .true.
- call ChangeValve(54, Manifold%SafetyValve)
-
- #ifdef deb
- print*, 'OpenSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
- subroutine CloseSafetyValve_TripMode()
- implicit none
- if(.not.Manifold%IsSafetyValveInstalled_TripMode) return
- DrillingConsole%CloseSafetyValveLed = 1
- DrillingConsole%OpenSafetyValveLed = 0
- Manifold%SafetyValve = .false.
- call ChangeValve(54, Manifold%SafetyValve)
-
- #ifdef deb
- print*, 'CloseSafetyValve_TripMode()'
- #endif
-
- end subroutine
-
-
-
-
-
-
-
-
- subroutine InstallSafetyValve_TopDrive()
- implicit none
- Manifold%IsSafetyValveInstalled_TopDrive = .true.
-
- call Manifold%Valve(128)%RemoveAdjacent(56)
- call Manifold%Valve(56)%RemoveAdjacent(128)
-
- call Manifold%Valve(127)%RemoveAdjacent(56)
- call Manifold%Valve(56)%RemoveAdjacent(127)
-
- call Manifold%Valve(69)%RemoveAdjacent(124)
- call Manifold%Valve(124)%RemoveAdjacent(69)
-
- call Manifold%Valve(124)%AdjacentTo(54)
- call Manifold%Valve(54)%AdjacentTo(124)
-
- call Manifold%Valve(54)%AdjacentTo(69)
- call Manifold%Valve(69)%AdjacentTo(54)
-
- DrillingConsole%IRSafetyValveLed = 1
- call OpenSafetyValve_TopDrive()
-
- #ifdef deb
- print*, 'InstallSafetyValve_TopDrive()'
- #endif
-
- end subroutine
-
- subroutine RemoveSafetyValve_TopDrive()
- implicit none
- Manifold%IsSafetyValveInstalled_TopDrive = .false.
-
- call Manifold%Valve(124)%RemoveAdjacent(54)
- call Manifold%Valve(54)%RemoveAdjacent(124)
-
- call Manifold%Valve(54)%RemoveAdjacent(69)
- call Manifold%Valve(69)%RemoveAdjacent(54)
-
- call Manifold%Valve(124)%AdjacentTo(69)
- call Manifold%Valve(69)%AdjacentTo(124)
-
- DrillingConsole%IRSafetyValveLed = 0
- call CloseSafetyValve_TopDrive()
- DrillingConsole%OpenSafetyValveLed = 0
- DrillingConsole%CloseSafetyValveLed = 0
-
- #ifdef deb
- print*, 'RemoveSafetyValve_TopDrive()'
- #endif
-
- end subroutine
-
- subroutine OpenSafetyValve_TopDrive()
- implicit none
- if(.not.Manifold%IsSafetyValveInstalled_TopDrive) return
- DrillingConsole%OpenSafetyValveLed = 1
- DrillingConsole%CloseSafetyValveLed = 0
- Manifold%SafetyValve = .true.
-
- #ifdef deb
- print*, 'OpenSafetyValve_TopDrive()'
- #endif
-
- call ChangeValve(54, Manifold%SafetyValve)
- end subroutine
-
- subroutine CloseSafetyValve_TopDrive()
- implicit none
- if(.not.Manifold%IsSafetyValveInstalled_TopDrive) return
- DrillingConsole%CloseSafetyValveLed = 1
- DrillingConsole%OpenSafetyValveLed = 0
- Manifold%SafetyValve = .false.
-
- #ifdef deb
- print*, 'CloseSafetyValve_TopDrive()'
- #endif
-
- call ChangeValve(54, Manifold%SafetyValve)
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine InstallIBop()
- implicit none
- Manifold%IsIBopInstalled = .true.
-
- call Manifold%Valve(103)%RemoveAdjacent(124)
- call Manifold%Valve(124)%RemoveAdjacent(103)
-
- call Manifold%Valve(55)%AdjacentTo(103)
- call Manifold%Valve(55)%AdjacentTo(124)
-
- call Manifold%Valve(103)%AdjacentTo(55)
- call Manifold%Valve(124)%AdjacentTo(55)
-
- #ifdef deb
- print*, 'InstallIBop()'
- #endif
-
- DrillingConsole%IRIBopLed = 1
- call OpenIBop()
- end subroutine
-
- subroutine RemoveIBop()
- implicit none
- Manifold%IsIBopInstalled = .false.
-
- call Manifold%Valve(55)%RemoveAdjacent(103)
- call Manifold%Valve(55)%RemoveAdjacent(124)
-
- call Manifold%Valve(103)%RemoveAdjacent(55)
- call Manifold%Valve(124)%RemoveAdjacent(55)
-
- call Manifold%Valve(103)%AdjacentTo(124)
- call Manifold%Valve(124)%AdjacentTo(103)
-
- #ifdef deb
- print*, 'RemoveIBop()'
- #endif
-
- DrillingConsole%IRIBopLed = 0
- Manifold%IBop = .false.
- call ChangeValve(55, Manifold%IBop)
- end subroutine
-
- subroutine OpenIBop()
- implicit none
- if(.not.Manifold%IsIBopInstalled) return
- Manifold%IBop = .true.
-
- #ifdef deb
- print*, 'OpenIBop()'
- #endif
-
- call ChangeValve(55, Manifold%IBop)
- end subroutine
-
- subroutine CloseIBop()
- implicit none
- if(.not.Manifold%IsIBopInstalled) return
- Manifold%IBop = .false.
-
- #ifdef deb
- print*, 'CloseIBop()'
- #endif
-
- call ChangeValve(55, Manifold%IBop)
- end subroutine
-
-
-
-
-
-
- subroutine InstallKellyCock()
- implicit none
- Manifold%IsKellyCockInstalled = .true.
-
- call Manifold%Valve(125)%RemoveAdjacent(126)
- call Manifold%Valve(126)%RemoveAdjacent(125)
-
- call Manifold%Valve(125)%AdjacentTo(68)
-
- call Manifold%Valve(68)%AdjacentTo(125)
- call Manifold%Valve(68)%AdjacentTo(126)
-
- call Manifold%Valve(126)%AdjacentTo(68)
-
- #ifdef deb
- print*, 'InstallKellyCock()'
- #endif
-
- call OpenKellyCock()
- end subroutine
-
- subroutine RemoveKellyCock()
- implicit none
- Manifold%IsKellyCockInstalled = .false.
-
- call Manifold%Valve(125)%RemoveAdjacent(68)
- call Manifold%Valve(126)%RemoveAdjacent(68)
-
- call Manifold%Valve(68)%RemoveAdjacent(125)
- call Manifold%Valve(68)%RemoveAdjacent(126)
-
- call Manifold%Valve(125)%AdjacentTo(126)
- call Manifold%Valve(126)%AdjacentTo(125)
-
- Manifold%KellyCock = .false.
- call ChangeValve(68, Manifold%KellyCock)
- DrillingConsole%CloseKellyCockLed = 0
- DrillingConsole%OpenKellyCockLed = 0
-
- #ifdef deb
- print*, 'RemoveKellyCock()'
- #endif
-
- end subroutine
-
- subroutine OpenKellyCock()
- implicit none
- if(.not.Manifold%IsKellyCockInstalled) return
- DrillingConsole%OpenKellyCockLed = 1
- DrillingConsole%CloseKellyCockLed = 0
- Manifold%KellyCock = .true.
-
- #ifdef deb
- print*, 'OpenKellyCock()'
- #endif
-
- call ChangeValve(68, Manifold%KellyCock)
- end subroutine
-
- subroutine CloseKellyCock()
- implicit none
- if(.not.Manifold%IsKellyCockInstalled) return
- DrillingConsole%CloseKellyCockLed = 1
- DrillingConsole%OpenKellyCockLed = 0
- Manifold%KellyCock = .false.
-
- #ifdef deb
- print*, 'CloseKellyCock()'
- #endif
-
- call ChangeValve(68, Manifold%KellyCock)
- end subroutine
-
-
-
-
-
-
-
-
- subroutine InstallTopDriveIBop()
- implicit none
- Manifold%IsTopDriveIBopInstalled = .true.
-
- call Manifold%Valve(126)%RemoveAdjacent(128)
- call Manifold%Valve(128)%RemoveAdjacent(126)
-
-
- call Manifold%Valve(126)%AdjacentTo(70)
- call Manifold%Valve(70)%AdjacentTo(126)
-
- call Manifold%Valve(128)%AdjacentTo(70)
- call Manifold%Valve(70)%AdjacentTo(128)
-
- #ifdef deb
- print*, 'InstallTopDriveIBop()'
- #endif
- call OpenTopDriveIBop()
- end subroutine
-
- subroutine RemoveTopDriveIBop()
- implicit none
- Manifold%IsTopDriveIBopInstalled = .false.
-
- call Manifold%Valve(126)%RemoveAdjacent(70)
- call Manifold%Valve(70)%RemoveAdjacent(126)
-
- call Manifold%Valve(128)%RemoveAdjacent(70)
- call Manifold%Valve(70)%RemoveAdjacent(128)
-
- call Manifold%Valve(126)%AdjacentTo(128)
- call Manifold%Valve(128)%AdjacentTo(126)
-
- #ifdef deb
- print*, 'RemoveTopDriveIBop()'
- #endif
- Manifold%TopDriveIBop = .false.
- call ChangeValve(70, Manifold%TopDriveIBop)
- end subroutine
-
- subroutine OpenTopDriveIBop()
- implicit none
- if(.not.Manifold%IsTopDriveIBopInstalled) return
- Manifold%TopDriveIBop = .true.
- call ChangeValve(70, Manifold%TopDriveIBop)
- #ifdef deb
- print*, 'OpenTopDriveIBop()'
- #endif
- end subroutine
-
- subroutine CloseTopDriveIBop()
- implicit none
- if(.not.Manifold%IsTopDriveIBopInstalled) return
- Manifold%TopDriveIBop = .false.
- call ChangeValve(70, Manifold%TopDriveIBop)
- #ifdef deb
- print*, 'CloseTopDriveIBop()'
- #endif
- end subroutine
-
-
-
-
-
-
-
-
-
- subroutine InstallFloatValve()
- implicit none
- Manifold%IsFloatValveInstalled = .true.
-
- call Manifold%Valve(69)%RemoveAdjacent(79)
- call Manifold%Valve(79)%RemoveAdjacent(69)
-
- call Manifold%Valve(48)%AdjacentTo(69)
- call Manifold%Valve(48)%AdjacentTo(79)
-
- call Manifold%Valve(69)%AdjacentTo(48)
- call Manifold%Valve(79)%AdjacentTo(48)
- #ifdef deb
- print*, 'InstallFloatValve()'
- #endif
- call OpenFloatValve()
- end subroutine
-
- subroutine RemoveFloatValve()
- implicit none
- Manifold%IsFloatValveInstalled = .false.
-
- call Manifold%Valve(48)%RemoveAdjacent(69)
- call Manifold%Valve(48)%RemoveAdjacent(79)
-
- call Manifold%Valve(69)%RemoveAdjacent(48)
- call Manifold%Valve(79)%RemoveAdjacent(48)
-
- call Manifold%Valve(69)%AdjacentTo(79)
- call Manifold%Valve(79)%AdjacentTo(69)
- #ifdef deb
- print*, 'RemoveFloatValve()'
- #endif
- Manifold%FloatValve = .false.
- call ChangeValve(48, Manifold%FloatValve)
- end subroutine
-
- subroutine OpenFloatValve()
- implicit none
- if(.not.Manifold%IsFloatValveInstalled) return
- Manifold%FloatValve = .true.
- #ifdef deb
- print*, 'OpenFloatValve()'
- #endif
- call ChangeValve(48, Manifold%FloatValve)
- end subroutine
-
- subroutine CloseFloatValve()
- implicit none
- if(.not.Manifold%IsFloatValveInstalled) return
- Manifold%FloatValve = .false.
- #ifdef deb
- print*, 'CloseFloatValve()'
- #endif
- call ChangeValve(48, Manifold%FloatValve)
- end subroutine
-
-
-
-
-
-
-
- subroutine ToggleFillupHead(v)
- implicit none
- logical, intent(in) :: v
- if(v) then
- call Manifold%Valve(14)%RemoveAdjacent(78)
-
- call Manifold%Valve(14)%AdjacentTo(57)
- call Manifold%Valve(57)%AdjacentTo(14)
- call Manifold%Valve(57)%AdjacentTo(103)
- call Manifold%Valve(103)%AdjacentTo(57)
-
- else
- call Manifold%Valve(14)%RemoveAdjacent(57)
- call Manifold%Valve(57)%RemoveAdjacent(14)
- call Manifold%Valve(57)%RemoveAdjacent(103)
- call Manifold%Valve(103)%RemoveAdjacent(57)
-
- call Manifold%Valve(14)%AdjacentTo(78)
- endif
- Manifold%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
- Manifold%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(Manifold%Valve(i)%Status==state) return
- Manifold%Valve(i)%Status = state
- if(i == 41 .or. i == 42) then
- if(Manifold%Valve(41)%Status == .false. .and. Manifold%Valve(42)%Status == .false.) then
- Manifold%Valve(60)%Status = .true.
- else
- Manifold%Valve(60)%Status = .false.
- endif
- endif
- #ifdef deb
- print*, 'Valve(', i, ') = ', state
- #endif
- !call Traverse()
- Manifold%IsPathsDirty = .true.
- end subroutine
-
-
-
-
-
- subroutine DisplayOpenPaths()
- implicit none
- integer :: i
- if(allocated(Manifold%OpenPaths)) then
- do i = 1, size(Manifold%OpenPaths)
- call Manifold%OpenPaths(i)%Display()
- end do
- end if
- end subroutine
-
- subroutine DisplayOpenPathsWrite()
- implicit none
- integer :: i
- if(allocated(Manifold%OpenPaths)) then
- do i = 1, size(Manifold%OpenPaths)
- call Manifold%OpenPaths(i)%DisplayWrite()
- end do
- end if
- end subroutine
-
- end module CManifolds
|