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.
 
 
 
 
 
 

816 lines
26 KiB

  1. # 1 "/home/admin/SimulationCore2/Simulator.f90"
  2. module Simulator
  3. use IFPORT
  4. use RedisInterface
  5. use Bop
  6. use PumpsMain
  7. use RopMain
  8. use RotaryTableMain
  9. use DrawworksMain
  10. use FluidFlowMain
  11. use TorqueDragMain
  12. use MudSystemMain
  13. use PipeRams1Main
  14. use PipeRams2Main
  15. use KillLineMain
  16. use ChokeLineMain
  17. use BlindRamsMain
  18. use AnnularMain
  19. use TopDriveMain
  20. use CManifolds
  21. use GeoMain
  22. use ChokeControlMain
  23. use COperationScenariosMain
  24. ! For Json read and write
  25. use CStringConfiguration
  26. use CFormation
  27. use CReservoir
  28. use CShoe
  29. use CAccumulator
  30. use CBopStack
  31. use CHoisting
  32. use CPower
  33. use CPumpsVariables
  34. use CRigSize
  35. use CCasingLinerChoke
  36. use CPathGeneration
  37. use CWellSurveyData
  38. use MudPropertiesModule
  39. use CBitProblems
  40. use CBopProblems
  41. use CChokeProblems
  42. use CDrillStemProblems
  43. use CGaugesProblems
  44. use CHoistingProblems
  45. use CKickProblems
  46. use CLostProblems
  47. use CMudTreatmentProblems
  48. use COtherProblems
  49. use CPumpProblems
  50. use CRotaryProblems
  51. use OperationScenariosModule
  52. use PermissionsModule
  53. use UnitySignalsModule
  54. use CBopControlPanel
  55. use CChokeControlPanel
  56. use CChokeManifold
  57. use CDataDisplayConsole
  58. use CDrillingConsole
  59. use CHook
  60. use CStandPipeManifold
  61. use CTopDrivePanel
  62. use DrillingWatchModule
  63. use CTanks
  64. use UnityModule
  65. implicit none
  66. type(json_core):: jsoncore
  67. integer :: simulationStatus,simulationSpeed,msPerStep,simulationEnd,simulationStep
  68. character(len=:),allocatable::redisInput,redisOutput
  69. enum, bind(c)
  70. enumerator :: PLAY = 1
  71. enumerator :: PAUSE = 2
  72. enumerator :: STOP = 3
  73. enumerator :: PLAY_TO_DETERMINED_TIME = 4
  74. end enum
  75. contains
  76. FUNCTION time_ms()
  77. INTEGER(8) :: time_ms
  78. integer,dimension(8)::timearray
  79. call date_and_time(values=timearray)
  80. time_ms = timearray(8)+timearray(7)*1000 + timearray(6)*60000 + timearray(5)*60000*600000 +timearray(4)*24*60000*60000
  81. RETURN
  82. END FUNCTION
  83. subroutine Simulate(redis_host,redis_port,redis_password, sim_id,stepTime)
  84. character(len=*) :: redis_host,redis_password, sim_id
  85. integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,stepTime
  86. integer(8),dimension(12)::t,t_modules
  87. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  88. do i=1,size(t_modules)
  89. t_modules(i)=0
  90. end do
  91. ! call initSimulation(configFilename)
  92. call initConnection(redis_host,redis_port,redis_password, sim_id,status)
  93. if (status<0) then
  94. print *,"Can not init connection to redis."
  95. stop
  96. endif
  97. call read_configuration()
  98. ! call read_variables()
  99. print *,"connection initialized"
  100. call init_modules()
  101. print *,"modules initialized"
  102. ! call cpu_time(T1)
  103. simulationStep = 1
  104. do while (.true.)
  105. ! print *,"simulationStep=",simulationStep
  106. t0 = time_ms()
  107. ! print *,"start reading."
  108. call read_variables()
  109. if(simulationStatus==PLAY_TO_DETERMINED_TIME .and. simulationStep>simulationEnd) exit
  110. if(simulationStatus==STOP) exit
  111. if(simulationStatus==PAUSE) then
  112. print *, "paused"
  113. call sleepqq(stepTime)
  114. go to 211
  115. endif
  116. call logg(4,"end reading")
  117. t1 = time_ms()
  118. t_read = t_read+t1-t0
  119. call logg(4,"read completed")
  120. !! Rafiee, nothing changed
  121. call BopStack_Step()
  122. t(1) = time_ms()
  123. t_modules(1) = t_modules(1)+t(1)-t1
  124. !! Tarmigh, now is rewritten
  125. call Pumps_MainSolver()
  126. t(2) = time_ms()
  127. t_modules(2) = t_modules(2)+t(2)-t(1)
  128. !call Pump2_Step()
  129. !! Rafiee
  130. call ChokeControl_Step()
  131. t(3) = time_ms()
  132. t_modules(3) = t_modules(3)+t(3)-t(2)
  133. !! Tarmigh, now is rewritten
  134. call RotaryTable_Step()
  135. t(4) = time_ms()
  136. t_modules(4) = t_modules(4)+t(4)-t(3)
  137. !! Tarmigh, now is rewritten
  138. call Drawworks_Step()
  139. t(5) = time_ms()
  140. t_modules(5) = t_modules(5)+t(5)-t(4)
  141. !! Rafiee
  142. call MudSystem_Step()
  143. !! Rafiee
  144. call PipeRams1_Step()
  145. call PipeRams2_Step()
  146. !! Rafiee
  147. call KillLine_Step()
  148. t(6) = time_ms()
  149. t_modules(6) = t_modules(6)+t(6)-t(5)
  150. !! Rafiee
  151. call ChokeLine_Step()
  152. t(7) = time_ms()
  153. t_modules(7) = t_modules(7)+t(7)-t(6)
  154. call BlindRams_Step()
  155. t(8) = time_ms()
  156. t_modules(8) = t_modules(8)+t(8)-t(7)
  157. call Annular_Step()
  158. t(9) = time_ms()
  159. t_modules(9) = t_modules(9)+t(9)-t(8)
  160. !!Tarmigh. Step must rewrittem
  161. call TopDrive_Step()
  162. t(10) = time_ms()
  163. t_modules(10) = t_modules(10)+t(10)-t(9)
  164. ! call Geo_Step()
  165. !!Ahmadi
  166. call PathFinding_Step()
  167. t(11) = time_ms()
  168. t_modules(11) = t_modules(11)+t(11)-t(10)
  169. !! Ahmadi
  170. call OperationScenarios_Step()
  171. !! Sheikh
  172. call FluidFlow_Step()
  173. !! Write variables to shared files
  174. t2 = time_ms()
  175. ! stepTime = t2-t1
  176. t_modules(12) = t_modules(12)+t2-t(11)
  177. t_exec = t_exec+t2-t1
  178. ! call date_and_time(values=timearray)
  179. ! t0 = time_ms()
  180. call write_variables()
  181. t3 = time_ms()
  182. if(t3-t0 < stepTime) then
  183. call sleepqq(stepTime-t3+t0)
  184. else
  185. print *,"Simulation step can not be complete in 100 ms. step time=",t3-t0
  186. endif
  187. t_write = t_write+t3-t2
  188. ! print *,"write completed"
  189. ! print *,"t=",t
  190. simulationStep = simulationStep + 1
  191. 211 end do
  192. ! call write_variables()
  193. ! call json%print(jsonroot,'test.json')
  194. ! call json%destroy(jsonroot)
  195. do i=1,size(t)
  196. print *,"t_modules(",i,")=",t_modules(i)
  197. end do
  198. print *,"Number of steps =",simulationStep-1
  199. print *,"Read Time (from redis) =",t_read
  200. print *,"Write Time (to redis)=",t_write
  201. print *,"Simulation Time =",t_exec
  202. print *,"Total Time =",t_read+t_write+t_exec
  203. end subroutine Simulate
  204. ! subroutine initSimulation(configFilename)
  205. ! use json_module
  206. ! use iso_c_binding, only: c_null_char,c_char
  207. ! character(len=*) :: configFilename
  208. ! ! type(json_file) :: jsonfile
  209. ! type(json_value),pointer :: jsonvalue
  210. ! type(json_core) :: jsoncore
  211. ! ! logical :: is_found
  212. ! ! character(len=:),allocatable :: password,address,datakey
  213. ! ! character(len=:),allocatable::c_address,c_password,c_datakey
  214. ! call jsonfile%initialize()
  215. ! ! print *,"init simulation with ",configFilename
  216. ! call jsonfile%load_file(configFilename);
  217. ! if (jsonfile%failed()) then
  218. ! print *,"can not open config file: ",configFilename ;
  219. ! stop
  220. ! endif
  221. ! ! print *,"file read"
  222. ! call jsonfile%json_file_get_root(jsonvalue)
  223. ! call jsoncore%get(jsonvalue,'log_level',log_level)
  224. ! print *,"log_level=",log_level
  225. ! end subroutine
  226. subroutine write_variables()
  227. use CAccumulator
  228. use json_module
  229. implicit none
  230. type(json_value),pointer :: jsonroot
  231. character(len=10)::str
  232. call jsoncore%initialize()
  233. call jsoncore%create_object(jsonroot,'')
  234. ! print *,"status=",simulationStatus
  235. ! call json%add(jsonroot,'status',simulationStatus)
  236. ! call json%add(jsonroot,'speed',simulationSpeed)
  237. ! call json%add(jsonroot,'endstep',simulationEnd)
  238. call jsoncore%add(jsonroot,'step',simulationStep)
  239. ! call ConfigurationToJson(jsonroot)
  240. call WarningsToJson(jsonroot)
  241. ! call ProblemsToJson(jsonroot)
  242. call EquipmentsToJson(jsonroot)
  243. call jsoncore%print_to_string(jsonroot,redisInput)
  244. if(log_level>4) then
  245. write(str, '(I0)') len(redisInput)
  246. print *,"Writing to redis:"//trim(str)
  247. endif
  248. call setData(redisInput)
  249. ! nullify(redisContent)
  250. ! deallocate(redisContent)
  251. ! call json%destroy(pval)
  252. call jsoncore%destroy(jsonroot)
  253. ! print *,"write ends"
  254. end subroutine
  255. subroutine read_configuration()
  256. type(json_value),pointer :: jsonroot,pval
  257. type(json_file) :: jsonfile
  258. type(json_core)::json
  259. call getData(redisOutput)
  260. ! print *,len(redisOutput)," bytes read from redis"
  261. open(1,file="redisContent.json",status="REPLACE")
  262. write(1,"(A)") redisOutput
  263. close(1)
  264. call jsonfile%initialize()
  265. call jsonfile%get_core(json)
  266. call jsonfile%deserialize(redisOutput)
  267. call jsonfile%json_file_get_root(jsonroot)
  268. ! call json%info(jsonvalue, n_children=n_children)
  269. ! print *,"n_children =",n_children
  270. call json%get(jsonroot,'status',pval)
  271. call json%get(pval,simulationStatus)
  272. call json%get(jsonroot,'speed',pval)
  273. call json%get(pval,simulationSpeed)
  274. if(simulationSpeed==0) simulationSpeed = 1
  275. msPerStep = 100/simulationSpeed
  276. call json%get(jsonroot,'endstep',pval)
  277. call json%get(pval,simulationEnd)
  278. call ConfigurationFromJson(jsonfile)
  279. call jsonfile%destroy()
  280. end subroutine
  281. subroutine read_variables()
  282. type(json_value),pointer :: jsonroot,pval
  283. type(json_file) :: jsonfile
  284. type(json_core)::json
  285. integer::stat
  286. call getData(redisOutput)
  287. print *,len(redisOutput)," bytes read from redis"
  288. open(1,file="redisContent.json",status="REPLACE")
  289. write(1,"(A)") redisOutput
  290. close(1)
  291. call jsonfile%initialize()
  292. call jsonfile%get_core(json)
  293. call jsonfile%deserialize(redisOutput)
  294. call jsonfile%json_file_get_root(jsonroot)
  295. ! call json%info(jsonvalue, n_children=n_children)
  296. ! print *,"n_children =",n_children
  297. call json%get(jsonroot,'status',pval)
  298. call json%get(pval,stat)
  299. if (stat==0) then
  300. return
  301. endif
  302. simulationStatus = stat
  303. call json%get(jsonroot,'speed',pval)
  304. call json%get(pval,simulationSpeed)
  305. if(simulationSpeed==0) simulationSpeed = 1
  306. msPerStep = 100/simulationSpeed
  307. call json%get(jsonroot,'endstep',pval)
  308. call json%get(pval,simulationEnd)
  309. print *,simulationStep,"/",simulationEnd
  310. ! call ProblemsFromJson(jsonfile)
  311. call EquipmentsFromJson(jsonfile)
  312. call jsonfile%destroy()
  313. end subroutine
  314. subroutine init_modules
  315. print *,"initializing modules"
  316. !Tarmigh
  317. call Pumps_StartUp()
  318. print *,"pump1 initialized"
  319. !call Pump2_Init()
  320. call RotaryTable_Init()
  321. print *,"RT initialized"
  322. call Drawworks_Init()
  323. call TopDrive_Init()
  324. print *,"TD initialized"
  325. !Nothing in init (and step)
  326. ! call Rop_Init()
  327. ! call TorqueDrag_Init()
  328. ! call Geo_Step()
  329. !! Rafiee
  330. call BopStack_Init()
  331. call ChokeControl_Init()
  332. call MudSystem_Init()
  333. print *,"Mudsystem initialized"
  334. !Again calls Bop_Startup
  335. ! call PipeRams1_Init()
  336. ! call PipeRams2_Step()
  337. ! call KillLine_Step()
  338. ! call ChokeLine_Step()
  339. ! call BlindRams_Step()
  340. ! call Annular_Step()
  341. !! Sheikh
  342. call FluidFlow_Init()
  343. ! print *,"Mudsystem initialized"
  344. !! Ahmadi
  345. call PathFinding_Init()
  346. ! Calls OSInitialization and that sub only subscribes some notif
  347. ! call OperationScenarios_Init()
  348. end subroutine init_modules
  349. subroutine EquipmentsFromJson(jsonfile)
  350. type(json_value),pointer :: parent
  351. type(json_value),pointer :: p
  352. type(json_file)::jsonfile
  353. integer::n_children
  354. logical::is_found
  355. ! 1. get related root
  356. ! call jsonfile%json_file_get_root(parent)
  357. ! call jsoncore%get(parent,"Equipments",p)
  358. call jsonfile%get("Equipments",p,is_found)
  359. ! call jsoncore%info(p, n_children=n_children)
  360. ! print *,"number of Equipments =",n_children
  361. ! 2. add member of data type to new node
  362. call BopControlPanelFromJson(p)
  363. call ChokeControlPanelFromJson(p)
  364. call ChokeManifoldFromJson(p)
  365. call DataDisplayConsoleFromJson(p)
  366. call DrillingConsoleFromJson(jsonfile)
  367. ! call HookFromJson(p)
  368. call StandPipeManifoldFromJson(p)
  369. call TopDrivePanelFromJson(p)
  370. ! call DrillingWatchFromJson(p)
  371. call TankFromJson(p)
  372. end subroutine
  373. subroutine EquipmentsToJson(parent)
  374. type(json_value),pointer :: parent
  375. type(json_value),pointer :: p
  376. ! 1. create new node
  377. call jsoncore%create_object(p,'Equipments')
  378. ! 2. add member of data type to new node
  379. call BopControlPanelToJson(p)
  380. call ChokeControlPanelToJson(p)
  381. call ChokeManifoldToJson(p)
  382. call DataDisplayConsoleToJson(p)
  383. call DrillingConsoleToJson(p)
  384. call HookToJson(p)
  385. call StandPipeManifoldToJson(p)
  386. call TopDrivePanelToJson(p)
  387. call DrillingWatchToJson(p)
  388. ! call TankToJson(p)
  389. ! 3. add new node to parent
  390. call jsoncore%add(parent,p)
  391. end subroutine
  392. ! subroutine ConfigurationToJson(parent)
  393. ! type(json_value),pointer :: parent
  394. ! type(json_value),pointer :: p
  395. ! ! 1. create new node
  396. ! call jsoncore%create_object(p,'Configuration')
  397. ! ! 2. add member of data type to new node
  398. ! call StringConfigurationToJson(p)
  399. ! call FormationToJson(p)
  400. ! call ReservoirToJson(p)
  401. ! call ShoeToJson(p)
  402. ! call AccumulatorToJson(p)
  403. ! call BopStackToJson(p)
  404. ! call HoistingToJson(p)
  405. ! call PowerToJson(p)
  406. ! call PumpsToJson(p)
  407. ! call RigSizeToJson(p)
  408. ! call CasingLinerChokeToJson(p)
  409. ! call PathGenerationToJson(p)
  410. ! ! call WellSurveyDataToJson(p)
  411. ! call MudPropertiesToJson(p)
  412. ! call UnityOutputsToJson(p)
  413. ! ! 3. add new node to parent
  414. ! call jsoncore%add(parent,p)
  415. ! end subroutine
  416. subroutine WarningsToJson(parent)
  417. type(json_value),pointer :: parent
  418. type(json_value),pointer :: p
  419. ! 1. create new node
  420. call jsoncore%create_object(p,'Warnings')
  421. ! 2. add member of data type to new node
  422. call jsoncore%add(p,"PumpWithKellyDisconnected",data%Warnings%PumpWithKellyDisconnected)
  423. call jsoncore%add(p,"PumpWithTopdriveDisconnected",data%Warnings%PumpWithTopdriveDisconnected)
  424. call jsoncore%add(p,"Pump1PopOffValveBlown",data%Warnings%Pump1PopOffValveBlown)
  425. call jsoncore%add(p,"Pump1Failure",data%Warnings%Pump1Failure)
  426. call jsoncore%add(p,"Pump2PopOffValveBlown",data%Warnings%Pump2PopOffValveBlown)
  427. call jsoncore%add(p,"Pump2Failure",data%Warnings%Pump2Failure)
  428. call jsoncore%add(p,"Pump3PopOffValveBlown",data%Warnings%Pump3PopOffValveBlown)
  429. call jsoncore%add(p,"Pump3Failure",data%Warnings%Pump3Failure)
  430. call jsoncore%add(p,"DrawworksGearsAbuse",data%Warnings%DrawworksGearsAbuse)
  431. call jsoncore%add(p,"RotaryGearsAbuse",data%Warnings%RotaryGearsAbuse)
  432. call jsoncore%add(p,"HoistLineBreak",data%Warnings%HoistLineBreak)
  433. call jsoncore%add(p,"PartedDrillString",data%Warnings%PartedDrillString)
  434. call jsoncore%add(p,"ActiveTankOverflow",data%Warnings%ActiveTankOverflow)
  435. call jsoncore%add(p,"ActiveTankUnderVolume",data%Warnings%ActiveTankUnderVolume)
  436. call jsoncore%add(p,"TripTankOverflow",data%Warnings%TripTankOverflow)
  437. call jsoncore%add(p,"DrillPipeTwistOff",data%Warnings%DrillPipeTwistOff)
  438. call jsoncore%add(p,"DrillPipeParted",data%Warnings%DrillPipeParted)
  439. call jsoncore%add(p,"TripWithSlipsSet",data%Warnings%TripWithSlipsSet)
  440. call jsoncore%add(p,"Blowout",data%Warnings%Blowout)
  441. call jsoncore%add(p,"UndergroundBlowout",data%Warnings%UndergroundBlowout)
  442. call jsoncore%add(p,"MaximumWellDepthExceeded",data%Warnings%MaximumWellDepthExceeded)
  443. call jsoncore%add(p,"CrownCollision",data%Warnings%CrownCollision)
  444. call jsoncore%add(p,"FloorCollision",data%Warnings%FloorCollision)
  445. call jsoncore%add(p,"TopdriveRotaryTableConfilict",data%Warnings%TopdriveRotaryTableConfilict)
  446. ! 3. add new node to parent
  447. call jsoncore%add(parent,p)
  448. end subroutine
  449. subroutine ProblemsToJson(parent)
  450. type(json_value),pointer :: parent
  451. type(json_value),pointer :: p
  452. ! 1. create new node
  453. call jsoncore%create_object(p,'Problems')
  454. ! 2. add member of data type to new node
  455. call BitProblemsToJson(p)
  456. call BopProblemsToJson(p)
  457. call ChokeProblemsToJson(p)
  458. call DrillStemProblemsToJson(p)
  459. call GaugesProblemsToJson(p)
  460. call HoistingProblemsToJson(p)
  461. call KickProblemsToJson(p)
  462. call LostProblemsToJson(p)
  463. call MudTreatmentProblemsToJson(p)
  464. call OtherProblemsToJson(p)
  465. call PumpProblemsToJson(p)
  466. call RotaryProblemsToJson(p)
  467. ! 3. add new node to parent
  468. call jsoncore%add(parent,p)
  469. end subroutine
  470. subroutine StateToJson(parent)
  471. type(json_value),pointer :: parent
  472. type(json_value),pointer :: p
  473. ! 1. create new node
  474. call jsoncore%create_object(p,'State')
  475. ! call OperationScenarioToJson(p)
  476. call notificationsToJson(p)
  477. ! call permissionsToJson(p)
  478. ! call unitySignalsToJson(p)
  479. ! call StudentStationToJson(p)
  480. ! call BopStackInputToJson(p)
  481. ! call BopStackAccToJson(p)
  482. ! call RamLineToJson(p)
  483. ! call AnnularComputationalToJson(p)
  484. ! call AnnularToJson(p)
  485. ! call PipeRam1ToJson(p)
  486. ! call ShearRamToJson(p)
  487. ! call PipeRam2ToJson(p)
  488. ! call ChokeLineToJson(p)
  489. ! call KillLineToJson(p)
  490. ! call PumpsToJson(p)
  491. ! call RAMToJson(p)
  492. ! call RAMSToJson(p)
  493. ! call ChokeToJson(p)
  494. ! call AirDrivenPumpToJson(p)
  495. ! call AirPumpLineToJson(p)
  496. ! call CHOOKEToJson(p)
  497. ! call DrawworksToJson(p)
  498. ! call MudSystemToJson(p)
  499. ! call MUDToJson(p)
  500. ! call MPumpsToJson(p)
  501. ! call PUMPToJson(p)
  502. ! call RTableToJson(p)
  503. ! call TDSToJson(p)
  504. ! call GasType(3)ToJson(p)
  505. ! call PressureDisplayToJson(p)
  506. ! call FricPressDropToJson(p)
  507. ! call ROP_SpecToJson(p)
  508. ! call ROP_BitToJson(p)
  509. ! call TDGeoToJson(p)
  510. ! call F_String(:)ToJson(p)
  511. ! call F_CountsToJson(p)
  512. ! call F_Interval(:)ToJson(p)
  513. ! call OD_Annulus(4)ToJson(p)
  514. ! call TD_DrillStemToJson(p)
  515. ! call TD_DrillStemsToJson(p)
  516. ! call TD_StringToJson(p)
  517. ! call TD_CountToJson(p)
  518. ! call G_StringElementToJson(p)
  519. ! call TD_VolToJson(p)
  520. ! call TD_GeneralToJson(p)
  521. ! call TD_BOPToJson(p)
  522. ! call TD_BOPElement(4)ToJson(p)
  523. ! call TD_StConnToJson(p)
  524. ! call TD_LoadToJson(p)
  525. ! call TD_WellElToJson(p)
  526. ! call TD_CasingToJson(p)
  527. ! call TD_LinerToJson(p)
  528. ! call TD_OpenHoleToJson(p)
  529. ! call TD_ROPHoleToJson(p)
  530. ! call TD_WellGeneralToJson(p)
  531. ! call TD_WellGeo(:)ToJson(p)
  532. ! 2. add member of data type to new node
  533. ! 3. add new node to parent
  534. call jsoncore%add(parent,p)
  535. end subroutine
  536. !use this as a template
  537. subroutine notificationsToJson(parent)
  538. type(json_value),pointer :: parent
  539. type(json_value),pointer :: p
  540. ! 1. create new node
  541. call jsoncore%create_object(p,'Notifications')
  542. ! 2. add member of data type to new node
  543. ! 3. add new node to parent
  544. call jsoncore%add(parent,p)
  545. end subroutine
  546. subroutine ConfigurationFromJson(jsonfile)
  547. type(json_file)::jsonfile
  548. type(json_value),pointer :: parent
  549. type(json_value),pointer :: p
  550. ! 1. get related root
  551. call jsonfile%json_file_get_root(parent)
  552. call jsoncore%get(parent,"Configuration",p)
  553. call StringConfigurationFromJson(p)
  554. call FormationFromJson(p)
  555. call ReservoirFromJson(p)
  556. call ShoeFromJson(p)
  557. call AccumulatorFromJson(p)
  558. call BopStackFromJson(p)
  559. call HoistingFromJson(p)
  560. call PowerFromJson(p)
  561. call PumpsFromJson(p)
  562. call RigSizeFromJson(p)
  563. call CasingLinerChokeFromJson(p)
  564. call PathGenerationFromJson(p)
  565. call MudPropertiesFromJson(p)
  566. call UnityInputsFromJson(p)
  567. ! 3. add new node to parent
  568. ! nullify(parent)
  569. end subroutine
  570. subroutine WarningsFromJson(parent)
  571. type(json_value),pointer :: parent
  572. type(json_value),pointer :: p
  573. type(json_value),pointer :: pval
  574. ! 1. get node
  575. call jsoncore%get(parent,'Warnings',p)
  576. ! ! 2. add member of data type to new node
  577. call jsoncore%get(p,'PumpWithKellyDisconnected',pval)
  578. call jsoncore%get(pval,data%Warnings%PumpWithKellyDisconnected)
  579. call jsoncore%get(p,'PumpWithTopdriveDisconnected',pval)
  580. call jsoncore%get(pval,data%Warnings%PumpWithTopdriveDisconnected)
  581. call jsoncore%get(p,'Pump1PopOffValveBlown',pval)
  582. call jsoncore%get(pval,data%Warnings%Pump1PopOffValveBlown)
  583. call jsoncore%get(p,'Pump1Failure',pval)
  584. call jsoncore%get(pval,data%Warnings%Pump1Failure)
  585. call jsoncore%get(p,'Pump2PopOffValveBlown',pval)
  586. call jsoncore%get(pval,data%Warnings%Pump2PopOffValveBlown)
  587. call jsoncore%get(p,'Pump2Failure',pval)
  588. call jsoncore%get(pval,data%Warnings%Pump2Failure)
  589. call jsoncore%get(p,'Pump3PopOffValveBlown',pval)
  590. call jsoncore%get(pval,data%Warnings%Pump3PopOffValveBlown)
  591. call jsoncore%get(p,'Pump3Failure',pval)
  592. call jsoncore%get(pval,data%Warnings%Pump3Failure)
  593. call jsoncore%get(p,'DrawworksGearsAbuse',pval)
  594. call jsoncore%get(pval,data%Warnings%DrawworksGearsAbuse)
  595. call jsoncore%get(p,'RotaryGearsAbuse',pval)
  596. call jsoncore%get(pval,data%Warnings%RotaryGearsAbuse)
  597. call jsoncore%get(p,'HoistLineBreak',pval)
  598. call jsoncore%get(pval,data%Warnings%HoistLineBreak)
  599. call jsoncore%get(p,'PartedDrillString',pval)
  600. call jsoncore%get(pval,data%Warnings%PartedDrillString)
  601. call jsoncore%get(p,'ActiveTankOverflow',pval)
  602. call jsoncore%get(pval,data%Warnings%ActiveTankOverflow)
  603. call jsoncore%get(p,'ActiveTankUnderVolume',pval)
  604. call jsoncore%get(pval,data%Warnings%ActiveTankUnderVolume)
  605. call jsoncore%get(p,'TripTankOverflow',pval)
  606. call jsoncore%get(pval,data%Warnings%TripTankOverflow)
  607. call jsoncore%get(p,'DrillPipeTwistOff',pval)
  608. call jsoncore%get(pval,data%Warnings%DrillPipeTwistOff)
  609. call jsoncore%get(p,'DrillPipeParted',pval)
  610. call jsoncore%get(pval,data%Warnings%DrillPipeParted)
  611. call jsoncore%get(p,'TripWithSlipsSet',pval)
  612. call jsoncore%get(pval,data%Warnings%TripWithSlipsSet)
  613. call jsoncore%get(p,'Blowout',pval)
  614. call jsoncore%get(pval,data%Warnings%Blowout)
  615. call jsoncore%get(p,'UndergroundBlowout',pval)
  616. call jsoncore%get(pval,data%Warnings%UndergroundBlowout)
  617. call jsoncore%get(p,'MaximumWellDepthExceeded',pval)
  618. call jsoncore%get(pval,data%Warnings%MaximumWellDepthExceeded)
  619. call jsoncore%get(p,'CrownCollision',pval)
  620. call jsoncore%get(pval,data%Warnings%CrownCollision)
  621. call jsoncore%get(p,'FloorCollision',pval)
  622. call jsoncore%get(pval,data%Warnings%FloorCollision)
  623. call jsoncore%get(p,'TopdriveRotaryTableConfilict',pval)
  624. call jsoncore%get(pval,data%Warnings%TopdriveRotaryTableConfilict)
  625. end subroutine
  626. subroutine ProblemsFromJson(jsonfile)
  627. type(json_value),pointer :: parent
  628. type(json_value),pointer :: p
  629. type(json_file)::jsonfile
  630. call jsonfile%json_file_get_root(parent)
  631. call jsoncore%get(parent,'Warnings',p)
  632. call BitProblemsToJson(p)
  633. call BopProblemsFromJson(p)
  634. call ChokeProblemsFromJson(p)
  635. call DrillStemProblemsFromJson(p)
  636. call GaugesProblemsFromJson(p)
  637. call HoistingProblemsFromJson(p)
  638. call KickProblemsFromJson(p)
  639. call LostProblemsFromJson(p)
  640. call MudTreatmentProblemsFromJson(p)
  641. call OtherProblemsFromJson(p)
  642. call PumpProblemsFromJson(p)
  643. call RotaryProblemsFromJson(p)
  644. end subroutine
  645. subroutine StateFromJson(parent)
  646. type(json_value),pointer :: parent
  647. type(json_value),pointer :: p
  648. ! 1. create new node
  649. ! call json%create_object(p,'State')
  650. ! ! call OperationScenarioFromJson(p)
  651. ! call notificationsFromJson(p)
  652. ! call permissionsFromJson(p)
  653. ! call unitySignalsFromJson(p)
  654. ! call StudentStationFromJson(p)
  655. ! call BopStackInputFromJson(p)
  656. ! call BopStackAccFromJson(p)
  657. ! call RamLineFromJson(p)
  658. ! call AnnularComputationalFromJson(p)
  659. ! call AnnularFromJson(p)
  660. ! call PipeRam1FromJson(p)
  661. ! call ShearRamFromJson(p)
  662. ! call PipeRam2FromJson(p)
  663. ! call ChokeLineFromJson(p)
  664. ! call KillLineFromJson(p)
  665. ! call PumpsFromJson(p)
  666. ! call RAMFromJson(p)
  667. ! call RAMSFromJson(p)
  668. ! call ChokeFromJson(p)
  669. ! call AirDrivenPumpFromJson(p)
  670. ! call AirPumpLineFromJson(p)
  671. ! call CHOOKEFromJson(p)
  672. ! call DrawworksFromJson(p)
  673. ! call MudSystemFromJson(p)
  674. ! call MUDFromJson(p)
  675. ! call MPumpsFromJson(p)
  676. ! call PUMPFromJson(p)
  677. ! call RTableFromJson(p)
  678. ! call TDSFromJson(p)
  679. ! call GasType(3)FromJson(p)
  680. ! call PressureDisplayFromJson(p)
  681. ! call FricPressDropFromJson(p)
  682. ! call ROP_SpecFromJson(p)
  683. ! call ROP_BitFromJson(p)
  684. ! call TDGeoFromJson(p)
  685. ! call F_String(:)FromJson(p)
  686. ! call F_CountsFromJson(p)
  687. ! call F_Interval(:)FromJson(p)
  688. ! call OD_Annulus(4)FromJson(p)
  689. ! call TD_DrillStemFromJson(p)
  690. ! call TD_DrillStemsFromJson(p)
  691. ! call TD_StringFromJson(p)
  692. ! call TD_CountFromJson(p)
  693. ! call G_StringElementFromJson(p)
  694. ! call TD_VolFromJson(p)
  695. ! call TD_GeneralFromJson(p)
  696. ! call TD_BOPFromJson(p)
  697. ! call TD_BOPElement(4)FromJson(p)
  698. ! call TD_StConnFromJson(p)
  699. ! call TD_LoadFromJson(p)
  700. ! call TD_WellElFromJson(p)
  701. ! call TD_CasingFromJson(p)
  702. ! call TD_LinerFromJson(p)
  703. ! call TD_OpenHoleFromJson(p)
  704. ! call TD_ROPHoleFromJson(p)
  705. ! call TD_WellGeneralFromJson(p)
  706. ! call TD_WellGeo(:)FromJson(p)
  707. ! 2. add member of data type to new node
  708. ! 3. add new node to parent
  709. ! call jsoncore%add(parent,p)
  710. end subroutine
  711. !use this as a template
  712. subroutine notificationsFromJson(parent)
  713. type(json_value),pointer :: parent
  714. !
  715. ! type(json_value),pointer :: p
  716. ! 1. create new node
  717. ! call json%create_object(p,'Notifications')
  718. ! ! 2. add member of data type to new node
  719. ! ! 3. add new node to parent
  720. ! call json%add(parent,p)
  721. end subroutine
  722. end module Simulator