Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CManifolds.f90 40 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390
  1. module CManifolds
  2. use CStack
  3. use CArrangement
  4. use CPathChangeEvents
  5. use CDrillingConsoleVariables!, only: DrillingConsole%IRSafetyValveLed, DrillingConsole%IRIBopLed, DrillingConsole%OpenKellyCockLed, DrillingConsole%CloseKellyCockLed, DrillingConsole%OpenSafetyValveLed, DrillingConsole%CloseSafetyValveLed
  6. implicit none
  7. public
  8. integer, parameter :: ValveCount = 128
  9. integer, parameter :: MinSource = 71
  10. integer, parameter :: MaxSource = 90
  11. integer, parameter :: MinRelation = 91
  12. integer, parameter :: MaxRelation = 128
  13. Type::ManifoldType
  14. type(Arrangement) :: Valve(ValveCount)
  15. type(Path), allocatable :: OpenPaths(:)
  16. type(Stack) :: Fringe
  17. logical :: IsRepititveOutput
  18. logical :: IsSafetyValveInstalled
  19. logical :: IsSafetyValveInstalled_KellyMode
  20. logical :: IsSafetyValveInstalled_TripMode
  21. logical :: IsSafetyValveInstalled_TopDrive
  22. logical :: SafetyValve
  23. logical :: IsIBopInstalled
  24. logical :: IBop
  25. logical :: IsKellyCockInstalled
  26. logical :: KellyCock
  27. logical :: IsTopDriveIBopInstalled
  28. logical :: TopDriveIBop
  29. logical :: IsFloatValveInstalled
  30. logical :: FloatValve
  31. logical :: IsPathsDirty = .false.
  32. logical :: IsTraverse = .false.
  33. End type ManifoldType
  34. type(ManifoldType)::Manifold
  35. contains
  36. subroutine PathFinding_Setup()
  37. use CSimulationVariables
  38. implicit none
  39. Manifold%IsTraverse = .false.
  40. call Setup()
  41. !call OnSimulationInitialization%Add(PathFinding_Init)
  42. !call OnSimulationStop%Add(PathFinding_Init)
  43. !call OnPathFindingStep%Add(PathFinding_Step)
  44. !call OnPathFindingOutput%Add(PathFinding_Output)
  45. call OnPathFindingMain%Add(PathFindingMainBody)
  46. end subroutine
  47. subroutine PathFinding_Init
  48. implicit none
  49. Manifold%IsTraverse = .false.
  50. call Setup()
  51. end subroutine PathFinding_Init
  52. subroutine PathFinding_Step
  53. implicit none
  54. end subroutine PathFinding_Step
  55. subroutine PathFinding_Output
  56. implicit none
  57. end subroutine PathFinding_Output
  58. subroutine PathFindingMainBody
  59. use CSimulationVariables
  60. implicit none
  61. loop : do
  62. if(IsStopped) call Quit()
  63. call sleepqq(50)
  64. if (Manifold%IsPathsDirty) then
  65. Manifold%IsPathsDirty = .false.
  66. call Traverse()
  67. endif
  68. end do loop
  69. end subroutine PathFindingMainBody
  70. subroutine Traverse()
  71. use CLog5
  72. implicit none
  73. integer :: i, Duration
  74. integer, dimension(8) :: StartTime,EndTime !TODO: clean up
  75. call DATE_AND_TIME(values=StartTime) !TODO: clean up
  76. call BeforeTraverse%RunAll()
  77. if(allocated(Manifold%OpenPaths)) deallocate(Manifold%OpenPaths)
  78. do i=MinSource, MaxSource
  79. if(IsValveOpen(i)) then
  80. call AddRootNode(i)
  81. call AddChildren(Manifold%Valve(i))
  82. endif
  83. enddo
  84. call PostProcess(Manifold%OpenPaths)
  85. call AfterTraverse%RunAll()
  86. Manifold%IsTraverse = .true.
  87. !TODO: clean up
  88. #ifdef Log5
  89. CALL DATE_AND_TIME(values=EndTime)
  90. Duration= EndTime(8) - StartTime(8)
  91. !print*, 'Duration= ', Duration, 'ms'
  92. call Log_5('Duration= ', Duration)
  93. call DisplayOpenPaths()
  94. call Log_5('==========================================')
  95. #endif
  96. endsubroutine
  97. subroutine PostProcess(pathArr)
  98. implicit none
  99. type(Path), allocatable, intent(inout) :: pathArr(:)
  100. integer :: i
  101. if(.not.allocated(pathArr)) return
  102. i = 1
  103. do
  104. call pathArr(i)%Purge(MinRelation, MaxRelation)
  105. if(pathArr(i)%Length() <= 2) then
  106. call RemovePath(pathArr, i)
  107. else
  108. i = i + 1
  109. endif
  110. if(i > size(pathArr)) exit
  111. enddo
  112. end subroutine
  113. subroutine AddRootNode(valve)
  114. implicit none
  115. integer, intent(in) :: valve
  116. call Manifold%Fringe%Push(valve)
  117. end subroutine
  118. recursive subroutine AddChildren(node)
  119. implicit none
  120. type(Arrangement), intent(inout) :: node
  121. integer :: i,t
  122. do i=1, Manifold%Valve(node%Number)%Length()
  123. t = Manifold%Valve(node%Number)%Adjacent(i)
  124. if(IsValveOpen(t)) then
  125. if(Manifold%Fringe%DoesHave(t)) cycle
  126. call Manifold%Fringe%Push(t)
  127. if(Manifold%Valve(t)%IsSource()) then
  128. call AddPath(Manifold%OpenPaths, Manifold%Fringe%List)
  129. call Manifold%Fringe%Pop()
  130. cycle
  131. endif
  132. call AddChildren(Manifold%Valve(node%Adjacent(i)))
  133. end if
  134. enddo
  135. call Manifold%Fringe%Pop()
  136. end subroutine
  137. logical function IsValveOpen(no)
  138. implicit none
  139. integer, intent(in) :: no
  140. IsValveOpen = Manifold%Valve(no)%Status
  141. end function
  142. subroutine AddPath(pathArr, p)
  143. implicit none
  144. type(Path), intent(in) :: p
  145. type(Path), allocatable, intent(inout) :: pathArr(:)
  146. type(Path), allocatable :: tempArr(:)
  147. integer :: i, isize
  148. if(p%IsNull()) return
  149. if(p%Length()<=1) return
  150. call OnPathOpen%RunAll(p%Valves)
  151. if(allocated(pathArr)) then
  152. isize = size(pathArr)
  153. ! check to see if already have a path same as p
  154. do i=1,isize
  155. if(pathArr(i)%First()==p%First() .and. pathArr(i)%Last()==p%Last()) then
  156. ! if there is then
  157. ! check to see if both have exacly a same length
  158. if(pathArr(i)%Length()==p%Length())then
  159. ! now they are the same so ignore adding this one
  160. return
  161. else
  162. !if they have different lengths then choose the shorter one
  163. if(pathArr(i)%Length()>p%Length())pathArr(i) = p
  164. return
  165. endif
  166. endif
  167. end do
  168. !TODO: if p last valve is input source then ignore adding it
  169. !TODO: if p start valve is output source then ignore adding it
  170. ! if p is a new entry then add it to the collections of found paths
  171. allocate(tempArr(isize+1))
  172. do i=1,isize
  173. tempArr(i) = pathArr(i)
  174. end do
  175. tempArr(isize+1) = p
  176. deallocate(pathArr)
  177. call move_alloc(tempArr, pathArr)
  178. else
  179. allocate(pathArr(1))
  180. pathArr(1) = p
  181. end if
  182. endsubroutine
  183. subroutine RemovePath(pathArr, index)
  184. implicit none
  185. integer, intent(in) :: index
  186. type(Path), allocatable, intent(inout) :: pathArr(:)
  187. type(Path), allocatable :: tempArr(:)
  188. integer :: i
  189. logical :: found
  190. if(index <= 0 .or. index > size(pathArr)) return
  191. if(.not.allocated(pathArr))return
  192. allocate(tempArr(size(pathArr)-1))
  193. found = .false.
  194. do i=1, size(pathArr)
  195. if(i==index) then
  196. found = .true.
  197. cycle
  198. end if
  199. if(found) then
  200. tempArr(i-1) = pathArr(i)
  201. !call OnPathClose%RunAll(pathArr(i)%Valves)
  202. else
  203. tempArr(i) = pathArr(i)
  204. endif
  205. end do
  206. deallocate(pathArr)
  207. call move_alloc(tempArr, pathArr)
  208. endsubroutine
  209. subroutine Setup()
  210. implicit none
  211. integer :: i
  212. ! initialize all valves
  213. do i = 1, ValveCount
  214. call Manifold%Valve(i)%init(i)
  215. end do
  216. ! open source valves
  217. do i = MinSource , MaxSource
  218. Manifold%Valve(i)%Status = .true.
  219. Manifold%Valve(i)%ValveType = InputOutput
  220. end do
  221. do i = MinRelation , MaxRelation
  222. Manifold%Valve(i)%Status = .true.
  223. Manifold%Valve(i)%ValveType = Relation
  224. end do
  225. ! make adjustments
  226. call Manifold%Valve(1)%AdjacentTo(91)
  227. call Manifold%Valve(2)%AdjacentTo(92)
  228. call Manifold%Valve(2)%AdjacentTo(117)
  229. call Manifold%Valve(3)%AdjacentTo(93)
  230. call Manifold%Valve(3)%AdjacentTo(118)
  231. call Manifold%Valve(4)%AdjacentTo(94)
  232. call Manifold%Valve(5)%AdjacentTo(95)
  233. call Manifold%Valve(6)%AdjacentTo(91)
  234. call Manifold%Valve(6)%AdjacentTo(92)
  235. call Manifold%Valve(7)%AdjacentTo(92)
  236. call Manifold%Valve(7)%AdjacentTo(93)
  237. call Manifold%Valve(8)%AdjacentTo(93)
  238. call Manifold%Valve(8)%AdjacentTo(94)
  239. call Manifold%Valve(9)%AdjacentTo(91)
  240. call Manifold%Valve(9)%AdjacentTo(96)
  241. call Manifold%Valve(10)%AdjacentTo(94)
  242. call Manifold%Valve(10)%AdjacentTo(98)
  243. call Manifold%Valve(11)%AdjacentTo(96)
  244. call Manifold%Valve(11)%AdjacentTo(97)
  245. call Manifold%Valve(12)%AdjacentTo(97)
  246. call Manifold%Valve(12)%AdjacentTo(98)
  247. call Manifold%Valve(13)%AdjacentTo(96)
  248. call Manifold%Valve(13)%AdjacentTo(99)
  249. call Manifold%Valve(14)%AdjacentTo(78)
  250. call Manifold%Valve(14)%AdjacentTo(97)
  251. !call Valve(14)%AdjacentTo(126)
  252. call Manifold%Valve(15)%AdjacentTo(98)
  253. call Manifold%Valve(15)%AdjacentTo(99)
  254. call Manifold%Valve(16)%AdjacentTo(121)
  255. !call Valve(16)%AdjacentTo()
  256. call Manifold%Valve(17)%AdjacentTo(122)
  257. !call Valve(17)%AdjacentTo()
  258. call Manifold%Valve(18)%AdjacentTo(123)
  259. !call Valve(18)%AdjacentTo()
  260. call Manifold%Valve(19)%AdjacentTo(101)
  261. call Manifold%Valve(19)%AdjacentTo(102)
  262. call Manifold%Valve(20)%AdjacentTo(100)
  263. call Manifold%Valve(21)%AdjacentTo(101)
  264. call Manifold%Valve(22)%AdjacentTo(102)
  265. call Manifold%Valve(23)%AdjacentTo(71)
  266. call Manifold%Valve(24)%AdjacentTo(71)
  267. call Manifold%Valve(25)%AdjacentTo(108)
  268. call Manifold%Valve(25)%AdjacentTo(118)
  269. call Manifold%Valve(26)%AdjacentTo(109)
  270. call Manifold%Valve(26)%AdjacentTo(117)
  271. call Manifold%Valve(27)%AdjacentTo(32)
  272. call Manifold%Valve(27)%AdjacentTo(108)
  273. call Manifold%Valve(28)%AdjacentTo(33)
  274. call Manifold%Valve(28)%AdjacentTo(108)
  275. call Manifold%Valve(29)%AdjacentTo(110)
  276. call Manifold%Valve(29)%AdjacentTo(113)
  277. call Manifold%Valve(30)%AdjacentTo(34)
  278. call Manifold%Valve(30)%AdjacentTo(109)
  279. call Manifold%Valve(31)%AdjacentTo(35)
  280. call Manifold%Valve(31)%AdjacentTo(109)
  281. call Manifold%Valve(32)%AdjacentTo(27)
  282. call Manifold%Valve(32)%AdjacentTo(61)
  283. call Manifold%Valve(33)%AdjacentTo(28)
  284. call Manifold%Valve(33)%AdjacentTo(62)
  285. call Manifold%Valve(34)%AdjacentTo(30)
  286. call Manifold%Valve(34)%AdjacentTo(63)
  287. call Manifold%Valve(35)%AdjacentTo(31)
  288. call Manifold%Valve(35)%AdjacentTo(64)
  289. call Manifold%Valve(36)%AdjacentTo(116)
  290. call Manifold%Valve(37)%AdjacentTo(78)
  291. call Manifold%Valve(38)%AdjacentTo(71)
  292. call Manifold%Valve(39)%AdjacentTo(77)
  293. !call Valve(40)%AdjacentTo(105)
  294. call Manifold%Valve(40)%AdjacentTo(80)
  295. call Manifold%Valve(41)%AdjacentTo(77)
  296. call Manifold%Valve(42)%AdjacentTo(71)
  297. call Manifold%Valve(43)%AdjacentTo(106)
  298. call Manifold%Valve(44)%AdjacentTo(77)
  299. call Manifold%Valve(45)%AdjacentTo(71)
  300. call Manifold%Valve(46)%AdjacentTo(104)
  301. call Manifold%Valve(47)%AdjacentTo(104)
  302. call Manifold%Valve(47)%AdjacentTo(117)
  303. call Manifold%Valve(48)%AdjacentTo(69)
  304. call Manifold%Valve(48)%AdjacentTo(79)
  305. call Manifold%Valve(49)%AdjacentTo(104)
  306. call Manifold%Valve(49)%AdjacentTo(79)
  307. !call Valve(50)%AdjacentTo(48)
  308. call Manifold%Valve(50)%AdjacentTo(51)
  309. !call Valve(50)%AdjacentTo(54)
  310. call Manifold%Valve(50)%AdjacentTo(104)
  311. call Manifold%Valve(51)%AdjacentTo(50)
  312. call Manifold%Valve(51)%AdjacentTo(52)
  313. call Manifold%Valve(52)%AdjacentTo(51)
  314. !call Valve(52)%AdjacentTo(127)
  315. call Manifold%Valve(52)%AdjacentTo(80)
  316. !call Valve(53)%AdjacentTo(103)
  317. !call Valve(53)%AdjacentTo(105)
  318. call Manifold%Valve(53)%AdjacentTo(80)
  319. !call Valve(54)%AdjacentTo(69)
  320. !call Valve(54)%AdjacentTo(124)
  321. !call Valve(55)%AdjacentTo(103)
  322. !call Valve(55)%AdjacentTo(124)
  323. call Manifold%Valve(56)%AdjacentTo(128)
  324. call Manifold%Valve(56)%AdjacentTo(127)
  325. !call Valve(57)%AdjacentTo(14)
  326. !call Valve(57)%AdjacentTo(103)
  327. !call Valve(57)%AdjacentTo(126)
  328. call Manifold%Valve(58)%AdjacentTo(78)
  329. call Manifold%Valve(59)%AdjacentTo(78)
  330. call Manifold%Valve(60)%AdjacentTo(78)
  331. call Manifold%Valve(61)%AdjacentTo(32)
  332. call Manifold%Valve(61)%AdjacentTo(115)
  333. call Manifold%Valve(62)%AdjacentTo(33)
  334. call Manifold%Valve(62)%AdjacentTo(114)
  335. call Manifold%Valve(63)%AdjacentTo(112)
  336. call Manifold%Valve(63)%AdjacentTo(34)
  337. call Manifold%Valve(64)%AdjacentTo(35)
  338. call Manifold%Valve(64)%AdjacentTo(111)
  339. call Manifold%Valve(65)%AdjacentTo(120)
  340. call Manifold%Valve(66)%AdjacentTo(120)
  341. call Manifold%Valve(67)%AdjacentTo(73)
  342. call Manifold%Valve(68)%AdjacentTo(125)
  343. call Manifold%Valve(68)%AdjacentTo(126)
  344. call Manifold%Valve(69)%AdjacentTo(48)
  345. call Manifold%Valve(69)%AdjacentTo(124)
  346. !call Valve(70)%AdjacentTo()
  347. !call Valve(70)%AdjacentTo()
  348. call Manifold%Valve(71)%AdjacentTo(20)
  349. call Manifold%Valve(71)%AdjacentTo(44)
  350. call Manifold%Valve(71)%AdjacentTo(59)
  351. call Manifold%Valve(72)%AdjacentTo(21)
  352. call Manifold%Valve(72)%AdjacentTo(23)
  353. call Manifold%Valve(73)%AdjacentTo(22)
  354. call Manifold%Valve(74)%AdjacentTo(24)
  355. !call Valve(75)%AdjacentTo()
  356. !call Valve(76)%AdjacentTo()
  357. call Manifold%Valve(77)%AdjacentTo(43)
  358. call Manifold%Valve(77)%AdjacentTo(58)
  359. !call Valve(78)%AdjacentTo()
  360. call Manifold%Valve(79)%AdjacentTo(48)
  361. call Manifold%Valve(79)%AdjacentTo(49)
  362. call Manifold%Valve(80)%AdjacentTo(52)
  363. call Manifold%Valve(80)%AdjacentTo(107)
  364. call Manifold%Valve(81)%AdjacentTo(53)
  365. call Manifold%Valve(82)%AdjacentTo(16)
  366. call Manifold%Valve(83)%AdjacentTo(17)
  367. call Manifold%Valve(84)%AdjacentTo(18)
  368. !call Valve(85)%AdjacentTo()
  369. !call Valve(86)%AdjacentTo()
  370. !call Valve(87)%AdjacentTo()
  371. !call Valve(88)%AdjacentTo()
  372. !!call Valve(89)%AdjacentTo()
  373. !call Valve(90)%AdjacentTo()
  374. call Manifold%Valve(91)%AdjacentTo(6)
  375. call Manifold%Valve(91)%AdjacentTo(9)
  376. call Manifold%Valve(91)%AdjacentTo(75)
  377. call Manifold%Valve(92)%AdjacentTo(6)
  378. call Manifold%Valve(92)%AdjacentTo(7)
  379. call Manifold%Valve(92)%AdjacentTo(2)
  380. call Manifold%Valve(93)%AdjacentTo(3)
  381. call Manifold%Valve(93)%AdjacentTo(7)
  382. call Manifold%Valve(93)%AdjacentTo(8)
  383. call Manifold%Valve(94)%AdjacentTo(8)
  384. call Manifold%Valve(94)%AdjacentTo(10)
  385. call Manifold%Valve(94)%AdjacentTo(95)
  386. call Manifold%Valve(95)%AdjacentTo(76)
  387. call Manifold%Valve(95)%AdjacentTo(94)
  388. call Manifold%Valve(96)%AdjacentTo(9)
  389. call Manifold%Valve(96)%AdjacentTo(11)
  390. call Manifold%Valve(96)%AdjacentTo(13)
  391. call Manifold%Valve(97)%AdjacentTo(11)
  392. call Manifold%Valve(97)%AdjacentTo(12)
  393. call Manifold%Valve(97)%AdjacentTo(14)
  394. call Manifold%Valve(98)%AdjacentTo(10)
  395. call Manifold%Valve(98)%AdjacentTo(12)
  396. call Manifold%Valve(98)%AdjacentTo(15)
  397. call Manifold%Valve(99)%AdjacentTo(13)
  398. call Manifold%Valve(99)%AdjacentTo(15)
  399. call Manifold%Valve(99)%AdjacentTo(125)
  400. !call Valve(100)%AdjacentTo(16)
  401. call Manifold%Valve(100)%AdjacentTo(82)
  402. call Manifold%Valve(100)%AdjacentTo(101)
  403. !call Valve(101)%AdjacentTo(17)
  404. call Manifold%Valve(101)%AdjacentTo(19)
  405. call Manifold%Valve(101)%AdjacentTo(83)
  406. call Manifold%Valve(101)%AdjacentTo(100)
  407. !call Valve(102)%AdjacentTo(18)
  408. call Manifold%Valve(102)%AdjacentTo(19)
  409. call Manifold%Valve(102)%AdjacentTo(84)
  410. !call Valve(103)%AdjacentTo(53)
  411. !call Valve(103)%AdjacentTo(56)
  412. call Manifold%Valve(103)%AdjacentTo(124)
  413. !call Valve(103)%AdjacentTo(56)
  414. !call Valve(103)%AdjacentTo(78)
  415. call Manifold%Valve(104)%AdjacentTo(46)
  416. call Manifold%Valve(104)%AdjacentTo(47)
  417. call Manifold%Valve(104)%AdjacentTo(49)
  418. call Manifold%Valve(104)%AdjacentTo(50)
  419. !call Valve(105)%AdjacentTo(53)
  420. !call Valve(105)%AdjacentTo(107)
  421. !call Valve(105)%AdjacentTo(127)
  422. call Manifold%Valve(106)%AdjacentTo(40)
  423. call Manifold%Valve(106)%AdjacentTo(45)
  424. call Manifold%Valve(107)%AdjacentTo(41)
  425. !call Valve(107)%AdjacentTo(105)
  426. call Manifold%Valve(107)%AdjacentTo(119)
  427. !call Valve(107)%AdjacentTo(42)
  428. call Manifold%Valve(108)%AdjacentTo(25)
  429. call Manifold%Valve(108)%AdjacentTo(27)
  430. call Manifold%Valve(108)%AdjacentTo(28)
  431. call Manifold%Valve(108)%AdjacentTo(110)
  432. call Manifold%Valve(109)%AdjacentTo(26)
  433. call Manifold%Valve(109)%AdjacentTo(30)
  434. call Manifold%Valve(109)%AdjacentTo(31)
  435. call Manifold%Valve(109)%AdjacentTo(110)
  436. call Manifold%Valve(110)%AdjacentTo(29)
  437. call Manifold%Valve(110)%AdjacentTo(85)
  438. call Manifold%Valve(110)%AdjacentTo(108)
  439. call Manifold%Valve(110)%AdjacentTo(109)
  440. call Manifold%Valve(111)%AdjacentTo(37)
  441. call Manifold%Valve(111)%AdjacentTo(64)
  442. call Manifold%Valve(111)%AdjacentTo(112)
  443. call Manifold%Valve(112)%AdjacentTo(63)
  444. call Manifold%Valve(112)%AdjacentTo(111)
  445. call Manifold%Valve(112)%AdjacentTo(113)
  446. call Manifold%Valve(113)%AdjacentTo(29)
  447. call Manifold%Valve(113)%AdjacentTo(112)
  448. call Manifold%Valve(113)%AdjacentTo(114)
  449. call Manifold%Valve(114)%AdjacentTo(62)
  450. call Manifold%Valve(114)%AdjacentTo(113)
  451. call Manifold%Valve(114)%AdjacentTo(115)
  452. call Manifold%Valve(115)%AdjacentTo(36)
  453. call Manifold%Valve(115)%AdjacentTo(61)
  454. call Manifold%Valve(115)%AdjacentTo(114)
  455. call Manifold%Valve(116)%AdjacentTo(38)
  456. call Manifold%Valve(116)%AdjacentTo(39)
  457. call Manifold%Valve(117)%AdjacentTo(2)
  458. call Manifold%Valve(117)%AdjacentTo(26)
  459. call Manifold%Valve(117)%AdjacentTo(47)
  460. call Manifold%Valve(118)%AdjacentTo(3)
  461. call Manifold%Valve(118)%AdjacentTo(25)
  462. call Manifold%Valve(118)%AdjacentTo(46)
  463. call Manifold%Valve(119)%AdjacentTo(42)
  464. call Manifold%Valve(119)%AdjacentTo(60)
  465. call Manifold%Valve(119)%AdjacentTo(107)
  466. call Manifold%Valve(120)%AdjacentTo(71)
  467. !call Valve(121)%AdjacentTo(16)
  468. call Manifold%Valve(121)%AdjacentTo(1)
  469. call Manifold%Valve(121)%AdjacentTo(65)
  470. !call Valve(122)%AdjacentTo(17)
  471. call Manifold%Valve(122)%AdjacentTo(4)
  472. call Manifold%Valve(122)%AdjacentTo(66)
  473. !call Valve(123)%AdjacentTo(18)
  474. call Manifold%Valve(123)%AdjacentTo(5)
  475. call Manifold%Valve(123)%AdjacentTo(67)
  476. !call Valve(124)%AdjacentTo(54)
  477. !call Valve(124)%AdjacentTo(55)
  478. call Manifold%Valve(124)%AdjacentTo(69)
  479. call Manifold%Valve(124)%AdjacentTo(103)
  480. call Manifold%Valve(125)%AdjacentTo(68)
  481. call Manifold%Valve(125)%AdjacentTo(99)
  482. ! call Valve(125)%AdjacentTo(126)
  483. call Manifold%Valve(126)%AdjacentTo(128)
  484. call Manifold%Valve(126)%AdjacentTo(68)
  485. !call Valve(126)%AdjacentTo(125)
  486. call Manifold%Valve(127)%AdjacentTo(56)
  487. call Manifold%Valve(127)%AdjacentTo(78)
  488. !call Valve(127)%AdjacentTo(105)
  489. call Manifold%Valve(128)%AdjacentTo(56)
  490. call Manifold%Valve(128)%AdjacentTo(126)
  491. ! initialization
  492. call ChangeValve(60, .true.)
  493. call RemoveIBop()
  494. call ToggleFillupHead(.false.)
  495. call ToggleMudBox(.false.)
  496. call RemoveTopDriveIBop()
  497. call InstallSafetyValve_KellyMode()
  498. call KellyDisconnected()
  499. end subroutine
  500. subroutine KellyConnected()
  501. !use CLog3
  502. implicit none
  503. call Manifold%Valve(127)%RemoveAdjacent(78)
  504. call Manifold%Valve(127)%AdjacentTo(103)
  505. call Manifold%Valve(103)%AdjacentTo(127)
  506. #ifdef deb
  507. print*, 'KellyConnected()'
  508. !call Log_3( 'KellyConnected()')
  509. #endif
  510. Manifold%IsPathsDirty = .true.
  511. end subroutine
  512. subroutine KellyDisconnected()
  513. !use CLog3
  514. implicit none
  515. call Manifold%Valve(127)%RemoveAdjacent(103)
  516. call Manifold%Valve(103)%RemoveAdjacent(127)
  517. call Manifold%Valve(127)%AdjacentTo(78)
  518. #ifdef deb
  519. print*, 'KellyDisconnected()'
  520. !call Log_3( 'KellyDisconnected()')
  521. #endif
  522. Manifold%IsPathsDirty = .true.
  523. end subroutine
  524. subroutine InstallSafetyValve_KellyMode()
  525. implicit none
  526. Manifold%IsSafetyValveInstalled_KellyMode = .true.
  527. call RemoveTopDriveIBop()
  528. ! Remove Safey Valve (54)
  529. call Manifold%Valve(124)%RemoveAdjacent(54)
  530. call Manifold%Valve(54)%RemoveAdjacent(124)
  531. call Manifold%Valve(69)%RemoveAdjacent(54)
  532. call Manifold%Valve(54)%RemoveAdjacent(69)
  533. ! Remove 126-103 cnn
  534. call Manifold%Valve(128)%RemoveAdjacent(127)
  535. call Manifold%Valve(127)%RemoveAdjacent(128)
  536. ! now make cnn
  537. call Manifold%Valve(124)%AdjacentTo(69)
  538. call Manifold%Valve(69)%AdjacentTo(124)
  539. call Manifold%Valve(128)%AdjacentTo(56)
  540. call Manifold%Valve(56)%AdjacentTo(128)
  541. call Manifold%Valve(56)%AdjacentTo(127)
  542. call Manifold%Valve(127)%AdjacentTo(56)
  543. #ifdef deb
  544. print*, 'InstallSafetyValve_KellyMode()'
  545. #endif
  546. DrillingConsole%IRSafetyValveLed = 1
  547. call OpenSafetyValve_KellyMode()
  548. end subroutine
  549. subroutine RemoveSafetyValve_KellyMode()
  550. implicit none
  551. Manifold%IsSafetyValveInstalled_KellyMode = .false.
  552. call Manifold%Valve(128)%RemoveAdjacent(56)
  553. call Manifold%Valve(56)%RemoveAdjacent(128)
  554. call Manifold%Valve(127)%RemoveAdjacent(56)
  555. call Manifold%Valve(56)%RemoveAdjacent(127)
  556. call Manifold%Valve(127)%AdjacentTo(128)
  557. call Manifold%Valve(128)%AdjacentTo(127)
  558. DrillingConsole%IRSafetyValveLed = 0
  559. call CloseSafetyValve_KellyMode()
  560. DrillingConsole%OpenSafetyValveLed = 0
  561. DrillingConsole%CloseSafetyValveLed = 0
  562. #ifdef deb
  563. print*, 'RemoveSafetyValve_KellyMode()'
  564. #endif
  565. end subroutine
  566. subroutine OpenSafetyValve_KellyMode()
  567. implicit none
  568. if(.not.Manifold%IsSafetyValveInstalled_KellyMode) return
  569. DrillingConsole%OpenSafetyValveLed = 1
  570. DrillingConsole%CloseSafetyValveLed = 0
  571. Manifold%SafetyValve = .true.
  572. call ChangeValve(56, Manifold%SafetyValve)
  573. #ifdef deb
  574. print*, 'OpenSafetyValve_KellyMode()'
  575. #endif
  576. end subroutine
  577. subroutine CloseSafetyValve_KellyMode()
  578. implicit none
  579. if(.not.Manifold%IsSafetyValveInstalled_KellyMode) return
  580. DrillingConsole%CloseSafetyValveLed = 1
  581. DrillingConsole%OpenSafetyValveLed = 0
  582. Manifold%SafetyValve = .false.
  583. call ChangeValve(56, Manifold%SafetyValve)
  584. #ifdef deb
  585. print*, 'CloseSafetyValve_KellyMode()'
  586. #endif
  587. end subroutine
  588. subroutine InstallSafetyValve_TripMode()
  589. implicit none
  590. Manifold%IsSafetyValveInstalled_TripMode = .true.
  591. call Manifold%Valve(128)%RemoveAdjacent(56)
  592. call Manifold%Valve(56)%RemoveAdjacent(128)
  593. call Manifold%Valve(127)%RemoveAdjacent(56)
  594. call Manifold%Valve(56)%RemoveAdjacent(127)
  595. call Manifold%Valve(69)%RemoveAdjacent(124)
  596. call Manifold%Valve(124)%RemoveAdjacent(69)
  597. call Manifold%Valve(127)%AdjacentTo(128)
  598. call Manifold%Valve(128)%AdjacentTo(127)
  599. call Manifold%Valve(124)%AdjacentTo(54)
  600. call Manifold%Valve(54)%AdjacentTo(124)
  601. call Manifold%Valve(54)%AdjacentTo(69)
  602. call Manifold%Valve(69)%AdjacentTo(54)
  603. DrillingConsole%IRSafetyValveLed = 1
  604. call OpenSafetyValve_TripMode()
  605. #ifdef deb
  606. print*, 'InstallSafetyValve_TripMode()'
  607. #endif
  608. end subroutine
  609. subroutine RemoveSafetyValve_TripMode()
  610. implicit none
  611. Manifold%IsSafetyValveInstalled_TripMode = .false.
  612. call Manifold%Valve(124)%RemoveAdjacent(54)
  613. call Manifold%Valve(54)%RemoveAdjacent(124)
  614. call Manifold%Valve(54)%RemoveAdjacent(69)
  615. call Manifold%Valve(69)%RemoveAdjacent(54)
  616. call Manifold%Valve(124)%AdjacentTo(69)
  617. call Manifold%Valve(69)%AdjacentTo(124)
  618. DrillingConsole%IRSafetyValveLed = 0
  619. call CloseSafetyValve_TripMode()
  620. DrillingConsole%OpenSafetyValveLed = 0
  621. DrillingConsole%CloseSafetyValveLed = 0
  622. #ifdef deb
  623. print*, 'RemoveSafetyValve_TripMode()'
  624. #endif
  625. end subroutine
  626. subroutine OpenSafetyValve_TripMode()
  627. implicit none
  628. if(.not.Manifold%IsSafetyValveInstalled_TripMode) return
  629. DrillingConsole%OpenSafetyValveLed = 1
  630. DrillingConsole%CloseSafetyValveLed = 0
  631. Manifold%SafetyValve = .true.
  632. call ChangeValve(54, Manifold%SafetyValve)
  633. #ifdef deb
  634. print*, 'OpenSafetyValve_TripMode()'
  635. #endif
  636. end subroutine
  637. subroutine CloseSafetyValve_TripMode()
  638. implicit none
  639. if(.not.Manifold%IsSafetyValveInstalled_TripMode) return
  640. DrillingConsole%CloseSafetyValveLed = 1
  641. DrillingConsole%OpenSafetyValveLed = 0
  642. Manifold%SafetyValve = .false.
  643. call ChangeValve(54, Manifold%SafetyValve)
  644. #ifdef deb
  645. print*, 'CloseSafetyValve_TripMode()'
  646. #endif
  647. end subroutine
  648. subroutine InstallSafetyValve_TopDrive()
  649. implicit none
  650. Manifold%IsSafetyValveInstalled_TopDrive = .true.
  651. call Manifold%Valve(128)%RemoveAdjacent(56)
  652. call Manifold%Valve(56)%RemoveAdjacent(128)
  653. call Manifold%Valve(127)%RemoveAdjacent(56)
  654. call Manifold%Valve(56)%RemoveAdjacent(127)
  655. call Manifold%Valve(69)%RemoveAdjacent(124)
  656. call Manifold%Valve(124)%RemoveAdjacent(69)
  657. call Manifold%Valve(124)%AdjacentTo(54)
  658. call Manifold%Valve(54)%AdjacentTo(124)
  659. call Manifold%Valve(54)%AdjacentTo(69)
  660. call Manifold%Valve(69)%AdjacentTo(54)
  661. DrillingConsole%IRSafetyValveLed = 1
  662. call OpenSafetyValve_TopDrive()
  663. #ifdef deb
  664. print*, 'InstallSafetyValve_TopDrive()'
  665. #endif
  666. end subroutine
  667. subroutine RemoveSafetyValve_TopDrive()
  668. implicit none
  669. Manifold%IsSafetyValveInstalled_TopDrive = .false.
  670. call Manifold%Valve(124)%RemoveAdjacent(54)
  671. call Manifold%Valve(54)%RemoveAdjacent(124)
  672. call Manifold%Valve(54)%RemoveAdjacent(69)
  673. call Manifold%Valve(69)%RemoveAdjacent(54)
  674. call Manifold%Valve(124)%AdjacentTo(69)
  675. call Manifold%Valve(69)%AdjacentTo(124)
  676. DrillingConsole%IRSafetyValveLed = 0
  677. call CloseSafetyValve_TopDrive()
  678. DrillingConsole%OpenSafetyValveLed = 0
  679. DrillingConsole%CloseSafetyValveLed = 0
  680. #ifdef deb
  681. print*, 'RemoveSafetyValve_TopDrive()'
  682. #endif
  683. end subroutine
  684. subroutine OpenSafetyValve_TopDrive()
  685. implicit none
  686. if(.not.Manifold%IsSafetyValveInstalled_TopDrive) return
  687. DrillingConsole%OpenSafetyValveLed = 1
  688. DrillingConsole%CloseSafetyValveLed = 0
  689. Manifold%SafetyValve = .true.
  690. #ifdef deb
  691. print*, 'OpenSafetyValve_TopDrive()'
  692. #endif
  693. call ChangeValve(54, Manifold%SafetyValve)
  694. end subroutine
  695. subroutine CloseSafetyValve_TopDrive()
  696. implicit none
  697. if(.not.Manifold%IsSafetyValveInstalled_TopDrive) return
  698. DrillingConsole%CloseSafetyValveLed = 1
  699. DrillingConsole%OpenSafetyValveLed = 0
  700. Manifold%SafetyValve = .false.
  701. #ifdef deb
  702. print*, 'CloseSafetyValve_TopDrive()'
  703. #endif
  704. call ChangeValve(54, Manifold%SafetyValve)
  705. end subroutine
  706. subroutine InstallIBop()
  707. implicit none
  708. Manifold%IsIBopInstalled = .true.
  709. call Manifold%Valve(103)%RemoveAdjacent(124)
  710. call Manifold%Valve(124)%RemoveAdjacent(103)
  711. call Manifold%Valve(55)%AdjacentTo(103)
  712. call Manifold%Valve(55)%AdjacentTo(124)
  713. call Manifold%Valve(103)%AdjacentTo(55)
  714. call Manifold%Valve(124)%AdjacentTo(55)
  715. #ifdef deb
  716. print*, 'InstallIBop()'
  717. #endif
  718. DrillingConsole%IRIBopLed = 1
  719. call OpenIBop()
  720. end subroutine
  721. subroutine RemoveIBop()
  722. implicit none
  723. Manifold%IsIBopInstalled = .false.
  724. call Manifold%Valve(55)%RemoveAdjacent(103)
  725. call Manifold%Valve(55)%RemoveAdjacent(124)
  726. call Manifold%Valve(103)%RemoveAdjacent(55)
  727. call Manifold%Valve(124)%RemoveAdjacent(55)
  728. call Manifold%Valve(103)%AdjacentTo(124)
  729. call Manifold%Valve(124)%AdjacentTo(103)
  730. #ifdef deb
  731. print*, 'RemoveIBop()'
  732. #endif
  733. DrillingConsole%IRIBopLed = 0
  734. Manifold%IBop = .false.
  735. call ChangeValve(55, Manifold%IBop)
  736. end subroutine
  737. subroutine OpenIBop()
  738. implicit none
  739. if(.not.Manifold%IsIBopInstalled) return
  740. Manifold%IBop = .true.
  741. #ifdef deb
  742. print*, 'OpenIBop()'
  743. #endif
  744. call ChangeValve(55, Manifold%IBop)
  745. end subroutine
  746. subroutine CloseIBop()
  747. implicit none
  748. if(.not.Manifold%IsIBopInstalled) return
  749. Manifold%IBop = .false.
  750. #ifdef deb
  751. print*, 'CloseIBop()'
  752. #endif
  753. call ChangeValve(55, Manifold%IBop)
  754. end subroutine
  755. subroutine InstallKellyCock()
  756. implicit none
  757. Manifold%IsKellyCockInstalled = .true.
  758. call Manifold%Valve(125)%RemoveAdjacent(126)
  759. call Manifold%Valve(126)%RemoveAdjacent(125)
  760. call Manifold%Valve(125)%AdjacentTo(68)
  761. call Manifold%Valve(68)%AdjacentTo(125)
  762. call Manifold%Valve(68)%AdjacentTo(126)
  763. call Manifold%Valve(126)%AdjacentTo(68)
  764. #ifdef deb
  765. print*, 'InstallKellyCock()'
  766. #endif
  767. call OpenKellyCock()
  768. end subroutine
  769. subroutine RemoveKellyCock()
  770. implicit none
  771. Manifold%IsKellyCockInstalled = .false.
  772. call Manifold%Valve(125)%RemoveAdjacent(68)
  773. call Manifold%Valve(126)%RemoveAdjacent(68)
  774. call Manifold%Valve(68)%RemoveAdjacent(125)
  775. call Manifold%Valve(68)%RemoveAdjacent(126)
  776. call Manifold%Valve(125)%AdjacentTo(126)
  777. call Manifold%Valve(126)%AdjacentTo(125)
  778. Manifold%KellyCock = .false.
  779. call ChangeValve(68, Manifold%KellyCock)
  780. DrillingConsole%CloseKellyCockLed = 0
  781. DrillingConsole%OpenKellyCockLed = 0
  782. #ifdef deb
  783. print*, 'RemoveKellyCock()'
  784. #endif
  785. end subroutine
  786. subroutine OpenKellyCock()
  787. implicit none
  788. if(.not.Manifold%IsKellyCockInstalled) return
  789. DrillingConsole%OpenKellyCockLed = 1
  790. DrillingConsole%CloseKellyCockLed = 0
  791. Manifold%KellyCock = .true.
  792. #ifdef deb
  793. print*, 'OpenKellyCock()'
  794. #endif
  795. call ChangeValve(68, Manifold%KellyCock)
  796. end subroutine
  797. subroutine CloseKellyCock()
  798. implicit none
  799. if(.not.Manifold%IsKellyCockInstalled) return
  800. DrillingConsole%CloseKellyCockLed = 1
  801. DrillingConsole%OpenKellyCockLed = 0
  802. Manifold%KellyCock = .false.
  803. #ifdef deb
  804. print*, 'CloseKellyCock()'
  805. #endif
  806. call ChangeValve(68, Manifold%KellyCock)
  807. end subroutine
  808. subroutine InstallTopDriveIBop()
  809. implicit none
  810. Manifold%IsTopDriveIBopInstalled = .true.
  811. call Manifold%Valve(126)%RemoveAdjacent(128)
  812. call Manifold%Valve(128)%RemoveAdjacent(126)
  813. call Manifold%Valve(126)%AdjacentTo(70)
  814. call Manifold%Valve(70)%AdjacentTo(126)
  815. call Manifold%Valve(128)%AdjacentTo(70)
  816. call Manifold%Valve(70)%AdjacentTo(128)
  817. #ifdef deb
  818. print*, 'InstallTopDriveIBop()'
  819. #endif
  820. call OpenTopDriveIBop()
  821. end subroutine
  822. subroutine RemoveTopDriveIBop()
  823. implicit none
  824. Manifold%IsTopDriveIBopInstalled = .false.
  825. call Manifold%Valve(126)%RemoveAdjacent(70)
  826. call Manifold%Valve(70)%RemoveAdjacent(126)
  827. call Manifold%Valve(128)%RemoveAdjacent(70)
  828. call Manifold%Valve(70)%RemoveAdjacent(128)
  829. call Manifold%Valve(126)%AdjacentTo(128)
  830. call Manifold%Valve(128)%AdjacentTo(126)
  831. #ifdef deb
  832. print*, 'RemoveTopDriveIBop()'
  833. #endif
  834. Manifold%TopDriveIBop = .false.
  835. call ChangeValve(70, Manifold%TopDriveIBop)
  836. end subroutine
  837. subroutine OpenTopDriveIBop()
  838. implicit none
  839. if(.not.Manifold%IsTopDriveIBopInstalled) return
  840. Manifold%TopDriveIBop = .true.
  841. call ChangeValve(70, Manifold%TopDriveIBop)
  842. #ifdef deb
  843. print*, 'OpenTopDriveIBop()'
  844. #endif
  845. end subroutine
  846. subroutine CloseTopDriveIBop()
  847. implicit none
  848. if(.not.Manifold%IsTopDriveIBopInstalled) return
  849. Manifold%TopDriveIBop = .false.
  850. call ChangeValve(70, Manifold%TopDriveIBop)
  851. #ifdef deb
  852. print*, 'CloseTopDriveIBop()'
  853. #endif
  854. end subroutine
  855. subroutine InstallFloatValve()
  856. implicit none
  857. Manifold%IsFloatValveInstalled = .true.
  858. call Manifold%Valve(69)%RemoveAdjacent(79)
  859. call Manifold%Valve(79)%RemoveAdjacent(69)
  860. call Manifold%Valve(48)%AdjacentTo(69)
  861. call Manifold%Valve(48)%AdjacentTo(79)
  862. call Manifold%Valve(69)%AdjacentTo(48)
  863. call Manifold%Valve(79)%AdjacentTo(48)
  864. #ifdef deb
  865. print*, 'InstallFloatValve()'
  866. #endif
  867. call OpenFloatValve()
  868. end subroutine
  869. subroutine RemoveFloatValve()
  870. implicit none
  871. Manifold%IsFloatValveInstalled = .false.
  872. call Manifold%Valve(48)%RemoveAdjacent(69)
  873. call Manifold%Valve(48)%RemoveAdjacent(79)
  874. call Manifold%Valve(69)%RemoveAdjacent(48)
  875. call Manifold%Valve(79)%RemoveAdjacent(48)
  876. call Manifold%Valve(69)%AdjacentTo(79)
  877. call Manifold%Valve(79)%AdjacentTo(69)
  878. #ifdef deb
  879. print*, 'RemoveFloatValve()'
  880. #endif
  881. Manifold%FloatValve = .false.
  882. call ChangeValve(48, Manifold%FloatValve)
  883. end subroutine
  884. subroutine OpenFloatValve()
  885. implicit none
  886. if(.not.Manifold%IsFloatValveInstalled) return
  887. Manifold%FloatValve = .true.
  888. #ifdef deb
  889. print*, 'OpenFloatValve()'
  890. #endif
  891. call ChangeValve(48, Manifold%FloatValve)
  892. end subroutine
  893. subroutine CloseFloatValve()
  894. implicit none
  895. if(.not.Manifold%IsFloatValveInstalled) return
  896. Manifold%FloatValve = .false.
  897. #ifdef deb
  898. print*, 'CloseFloatValve()'
  899. #endif
  900. call ChangeValve(48, Manifold%FloatValve)
  901. end subroutine
  902. subroutine ToggleFillupHead(v)
  903. implicit none
  904. logical, intent(in) :: v
  905. if(v) then
  906. call Manifold%Valve(14)%RemoveAdjacent(78)
  907. call Manifold%Valve(14)%AdjacentTo(57)
  908. call Manifold%Valve(57)%AdjacentTo(14)
  909. call Manifold%Valve(57)%AdjacentTo(103)
  910. call Manifold%Valve(103)%AdjacentTo(57)
  911. else
  912. call Manifold%Valve(14)%RemoveAdjacent(57)
  913. call Manifold%Valve(57)%RemoveAdjacent(14)
  914. call Manifold%Valve(57)%RemoveAdjacent(103)
  915. call Manifold%Valve(103)%RemoveAdjacent(57)
  916. call Manifold%Valve(14)%AdjacentTo(78)
  917. endif
  918. Manifold%IsPathsDirty = .true.
  919. call ChangeValve(57, .true.)
  920. end subroutine
  921. subroutine ToggleMudBox(v)
  922. implicit none
  923. logical, intent(in) :: v
  924. call ChangeValve(53, v)
  925. end subroutine
  926. subroutine ToggleMiddleRams(v)
  927. implicit none
  928. logical, intent(in) :: v
  929. Manifold%Valve(50)%Status = v
  930. call ChangeValve(69, v)
  931. end subroutine
  932. subroutine ChangeValve(i, state)
  933. implicit none
  934. integer, intent(in) :: i
  935. logical, intent(in) :: state
  936. if(Manifold%Valve(i)%Status==state) return
  937. Manifold%Valve(i)%Status = state
  938. if(i == 41 .or. i == 42) then
  939. if(Manifold%Valve(41)%Status == .false. .and. Manifold%Valve(42)%Status == .false.) then
  940. Manifold%Valve(60)%Status = .true.
  941. else
  942. Manifold%Valve(60)%Status = .false.
  943. endif
  944. endif
  945. #ifdef deb
  946. print*, 'Valve(', i, ') = ', state
  947. #endif
  948. !call Traverse()
  949. Manifold%IsPathsDirty = .true.
  950. end subroutine
  951. subroutine DisplayOpenPaths()
  952. implicit none
  953. integer :: i
  954. if(allocated(Manifold%OpenPaths)) then
  955. do i = 1, size(Manifold%OpenPaths)
  956. call Manifold%OpenPaths(i)%Display()
  957. end do
  958. end if
  959. end subroutine
  960. subroutine DisplayOpenPathsWrite()
  961. implicit none
  962. integer :: i
  963. if(allocated(Manifold%OpenPaths)) then
  964. do i = 1, size(Manifold%OpenPaths)
  965. call Manifold%OpenPaths(i)%DisplayWrite()
  966. end do
  967. end if
  968. end subroutine
  969. end module CManifolds