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.
 
 
 
 
 
 

813 regels
25 KiB

  1. # 1 "/mnt/c/Projects/VSIM/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_file) :: jsonfile
  67. type(json_core):: json
  68. integer :: simulationStatus,simulationSpeed,msPerStep,simulationEnd,simulationStep
  69. real :: stepTime !time for each step
  70. character(len=:),allocatable::redisInput,redisOutput
  71. enum, bind(c)
  72. enumerator :: PLAY = 1
  73. enumerator :: PAUSE = 2
  74. enumerator :: STOP = 3
  75. enumerator :: PLAY_TO_DETERMINED_TIME = 4
  76. end enum
  77. contains
  78. FUNCTION time_ms()
  79. INTEGER(8) :: time_ms
  80. integer,dimension(8)::timearray
  81. call date_and_time(values=timearray)
  82. time_ms = timearray(8)+timearray(7)*1000 + timearray(6)*60000 + timearray(5)*60000*600000 +timearray(4)*24*60000*60000
  83. RETURN
  84. END FUNCTION
  85. subroutine Simulate(redis_host,redis_port,redis_password, sim_id,log_level)
  86. character(len=*) :: redis_host,redis_password, sim_id
  87. integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,log_level
  88. integer(8),dimension(12)::t,t_modules
  89. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  90. do i=1,size(t_modules)
  91. t_modules(i)=0
  92. end do
  93. logging = log_level
  94. ! call initSimulation(configFilename)
  95. call initConnection(redis_host,redis_port,redis_password, sim_id,status)
  96. if (status<0) then
  97. print *,"Can not init connection to redis."
  98. stop
  99. endif
  100. call read_configuration()
  101. ! call read_variables()
  102. print *,"connection initialized"
  103. call init_modules()
  104. print *,"modules initialized"
  105. ! call cpu_time(T1)
  106. simulationStep = 1
  107. do while (.true.)
  108. ! print *,"simulationStep=",simulationStep
  109. t0 = time_ms()
  110. ! print *,"start reading."
  111. call read_variables()
  112. if(simulationStatus==PLAY_TO_DETERMINED_TIME .and. simulationStep>simulationEnd) exit
  113. if(simulationStatus==STOP) exit
  114. if(simulationStatus==PAUSE) then
  115. print *, "paused"
  116. go to 211
  117. endif
  118. if(logging>4) print *,"end reading"
  119. t1 = time_ms()
  120. t_read = t_read+t1-t0
  121. if(logging>4) print *,"read completed"
  122. !! Rafiee, nothing changed
  123. call BopStack_Step()
  124. t(1) = time_ms()
  125. t_modules(1) = t_modules(1)+t(1)-t1
  126. !! Tarmigh, now is rewritten
  127. call Pump1_Step()
  128. t(2) = time_ms()
  129. t_modules(2) = t_modules(2)+t(2)-t(1)
  130. !call Pump2_Step()
  131. !! Rafiee
  132. call ChokeControl_Step()
  133. t(3) = time_ms()
  134. t_modules(3) = t_modules(3)+t(3)-t(2)
  135. !! Tarmigh, now is rewritten
  136. call RotaryTable_Step()
  137. t(4) = time_ms()
  138. t_modules(4) = t_modules(4)+t(4)-t(3)
  139. !! Tarmigh, now is rewritten
  140. call Drawworks_Step()
  141. t(5) = time_ms()
  142. t_modules(5) = t_modules(5)+t(5)-t(4)
  143. !! Rafiee
  144. call MudSystem_Step()
  145. !! Rafiee
  146. call PipeRams1_Step()
  147. call PipeRams2_Step()
  148. !! Rafiee
  149. call KillLine_Step()
  150. t(6) = time_ms()
  151. t_modules(6) = t_modules(6)+t(6)-t(5)
  152. !! Rafiee
  153. call ChokeLine_Step()
  154. t(7) = time_ms()
  155. t_modules(7) = t_modules(7)+t(7)-t(6)
  156. call BlindRams_Step()
  157. t(8) = time_ms()
  158. t_modules(8) = t_modules(8)+t(8)-t(7)
  159. call Annular_Step()
  160. t(9) = time_ms()
  161. t_modules(9) = t_modules(9)+t(9)-t(8)
  162. !!Tarmigh. Step must rewrittem
  163. call TopDrive_Step()
  164. t(10) = time_ms()
  165. t_modules(10) = t_modules(10)+t(10)-t(9)
  166. ! call Geo_Step()
  167. !!Ahmadi
  168. call PathFinding_Step()
  169. t(11) = time_ms()
  170. t_modules(11) = t_modules(11)+t(11)-t(10)
  171. !! Sheikh
  172. ! call FluidFlow_Step()
  173. !! Ahmadi
  174. call OperationScenarios_Step()
  175. !! Write variables to shared files
  176. t2 = time_ms()
  177. ! stepTime = t2-t1
  178. t_modules(12) = t_modules(12)+t2-t(11)
  179. t_exec = t_exec+t2-t1
  180. ! call date_and_time(values=timearray)
  181. ! t0 = time_ms()
  182. call write_variables()
  183. t3 = time_ms()
  184. if(t3-t0 < 100) then
  185. call sleepqq(t3-t0)
  186. else
  187. print *,"Simulation step can not be complete in 100 ms. step time=",t3-t0
  188. endif
  189. t_write = t_write+t3-t2
  190. ! print *,"write completed"
  191. ! print *,"t=",t
  192. simulationStep = simulationStep + 1
  193. 211 end do
  194. ! call write_variables()
  195. ! call json%print(jsonroot,'test.json')
  196. ! call json%destroy(jsonroot)
  197. do i=1,size(t)
  198. print *,"t_modules(",i,")=",t_modules(i)
  199. end do
  200. print *,"Number of steps =",simulationStep-1
  201. print *,"Read Time (from redis) =",t_read
  202. print *,"Write Time (to redis)=",t_write
  203. print *,"Simulation Time =",t_exec
  204. print *,"Total Time =",t_read+t_write+t_exec
  205. end subroutine Simulate
  206. ! subroutine initSimulation(configFilename)
  207. ! use json_module
  208. ! use iso_c_binding, only: c_null_char,c_char
  209. ! character(len=*) :: configFilename
  210. ! ! type(json_file) :: jsonfile
  211. ! type(json_value),pointer :: jsonvalue
  212. ! type(json_core) :: jsoncore
  213. ! ! logical :: is_found
  214. ! ! character(len=:),allocatable :: password,address,datakey
  215. ! ! character(len=:),allocatable::c_address,c_password,c_datakey
  216. ! call jsonfile%initialize()
  217. ! ! print *,"init simulation with ",configFilename
  218. ! call jsonfile%load_file(configFilename);
  219. ! if (jsonfile%failed()) then
  220. ! print *,"can not open config file: ",configFilename ;
  221. ! stop
  222. ! endif
  223. ! ! print *,"file read"
  224. ! call jsonfile%json_file_get_root(jsonvalue)
  225. ! call jsoncore%get(jsonvalue,'logging',logging)
  226. ! print *,"logging=",logging
  227. ! end subroutine
  228. subroutine write_variables()
  229. use CAccumulator
  230. use json_module
  231. implicit none
  232. type(json_value),pointer :: jsonroot
  233. character(len=20)::fn
  234. ! integer::n_children
  235. call json%initialize()
  236. call json%create_object(jsonroot,'')
  237. ! print *,"status=",simulationStatus
  238. ! call json%add(jsonroot,'status',simulationStatus)
  239. ! call json%add(jsonroot,'speed',simulationSpeed)
  240. ! call json%add(jsonroot,'endstep',simulationEnd)
  241. call json%add(jsonroot,'step',simulationStep)
  242. ! call ConfigurationToJson(jsonroot)
  243. call WarningsToJson(jsonroot)
  244. ! call ProblemsToJson(jsonroot)
  245. call EquipmentsToJson(jsonroot)
  246. ! print *,"write starts"
  247. write (fn,*) "data",simulationStep
  248. ! call json%print(jsonroot,trim(fn)//".json")
  249. call json%serialize(jsonroot,redisInput)
  250. ! call compress_string(redisContent)
  251. if(logging>4) print *,"Writing to redis:",len(redisInput)
  252. call setData(redisInput)
  253. ! nullify(redisContent)
  254. ! deallocate(redisContent)
  255. ! call json%destroy(pval)
  256. call json%destroy(jsonroot)
  257. ! print *,"write ends"
  258. end subroutine
  259. subroutine read_configuration()
  260. type(json_value),pointer :: jsonroot
  261. type(json_value),pointer :: pval
  262. call getData(redisOutput)
  263. ! print *,len(redisOutput)," bytes read from redis"
  264. open(1,file="redisContent.json",status="REPLACE")
  265. write(1,"(A)") redisOutput
  266. close(1)
  267. ! call json%initialize()
  268. call jsonfile%initialize()
  269. ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
  270. call jsonfile%deserialize(redisOutput)
  271. call jsonfile%json_file_get_root(jsonroot)
  272. ! call json%info(jsonvalue, n_children=n_children)
  273. ! print *,"n_children =",n_children
  274. call json%get(jsonroot,'status',pval)
  275. call json%get(pval,simulationStatus)
  276. call json%get(jsonroot,'speed',pval)
  277. call json%get(pval,simulationSpeed)
  278. if(simulationSpeed==0) simulationSpeed = 1
  279. msPerStep = 100/simulationSpeed
  280. call json%get(jsonroot,'endstep',pval)
  281. call json%get(pval,simulationEnd)
  282. call ConfigurationFromJson(jsonroot)
  283. ! call WarningsFromJson(jsonroot)
  284. ! call ProblemsFromJson(jsonvalue)
  285. ! call EquipmentsFromJson(jsonroot)
  286. ! deallocate(redisContent)
  287. ! call json%destroy(pval)
  288. ! call json%destroy(jsonroot)
  289. end subroutine
  290. subroutine read_variables()
  291. type(json_value),pointer :: jsonroot,pval
  292. call getData(redisOutput)
  293. ! print *,len(redisOutput)," bytes read from redis"
  294. ! open(1,file="redisContent.json",status="REPLACE")
  295. ! write(1,"(A)") redisContent
  296. ! close(1)
  297. call jsonfile%initialize()
  298. call jsonfile%deserialize(redisOutput)
  299. ! call jsonfile%initialize()
  300. ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
  301. call jsonfile%json_file_get_root(jsonroot)
  302. ! call json%info(jsonvalue, n_children=n_children)
  303. ! print *,"n_children =",n_children
  304. call json%get(jsonroot,'status',pval)
  305. call json%get(pval,simulationStatus)
  306. call json%get(jsonroot,'speed',pval)
  307. call json%get(pval,simulationSpeed)
  308. if(simulationSpeed==0) simulationSpeed = 1
  309. msPerStep = 100/simulationSpeed
  310. call json%get(jsonroot,'endstep',pval)
  311. call json%get(pval,simulationEnd)
  312. print *,simulationStep,"/",simulationEnd
  313. ! call ConfigurationFromJson(jsonroot)
  314. ! call WarningsFromJson(jsonroot)
  315. call ProblemsFromJson(jsonroot)
  316. call EquipmentsFromJson(jsonroot)
  317. ! deallocate(redisContent)
  318. ! call json%destroy(pval)
  319. ! call json%destroy(jsonroot)
  320. end subroutine
  321. subroutine init_modules
  322. print *,"initializing modules"
  323. !Tarmigh
  324. call Pump1_Init()
  325. print *,"pump1 initialized"
  326. !call Pump2_Init()
  327. call RotaryTable_Init()
  328. print *,"RT initialized"
  329. call Drawworks_Init()
  330. call TopDrive_Init()
  331. print *,"TD initialized"
  332. !Nothing in init (and step)
  333. ! call Rop_Init()
  334. ! call TorqueDrag_Init()
  335. ! call Geo_Step()
  336. !! Rafiee
  337. call BopStack_Init()
  338. call ChokeControl_Init()
  339. call MudSystem_Init()
  340. print *,"Mudsystem initialized"
  341. !Again calls Bop_Startup
  342. ! call PipeRams1_Init()
  343. ! call PipeRams2_Step()
  344. ! call KillLine_Step()
  345. ! call ChokeLine_Step()
  346. ! call BlindRams_Step()
  347. ! call Annular_Step()
  348. !! Sheikh
  349. ! call FluidFlow_Init()
  350. ! print *,"Mudsystem initialized"
  351. !! Ahmadi
  352. call PathFinding_Init()
  353. ! Calls OSInitialization and that sub only subscribes some notif
  354. ! call OperationScenarios_Init()
  355. end subroutine init_modules
  356. subroutine EquipmentsFromJson(parent)
  357. type(json_value),pointer :: parent
  358. type(json_value),pointer :: p
  359. ! 1. get related root
  360. call json%get(parent,"Equipments",p)
  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(p)
  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 json%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 json%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 json%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 json%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 json%create_object(p,'Warnings')
  421. ! 2. add member of data type to new node
  422. call json%add(p,"PumpWithKellyDisconnected",data%Warnings%PumpWithKellyDisconnected)
  423. call json%add(p,"PumpWithTopdriveDisconnected",data%Warnings%PumpWithTopdriveDisconnected)
  424. call json%add(p,"Pump1PopOffValveBlown",data%Warnings%Pump1PopOffValveBlown)
  425. call json%add(p,"Pump1Failure",data%Warnings%Pump1Failure)
  426. call json%add(p,"Pump2PopOffValveBlown",data%Warnings%Pump2PopOffValveBlown)
  427. call json%add(p,"Pump2Failure",data%Warnings%Pump2Failure)
  428. call json%add(p,"Pump3PopOffValveBlown",data%Warnings%Pump3PopOffValveBlown)
  429. call json%add(p,"Pump3Failure",data%Warnings%Pump3Failure)
  430. call json%add(p,"DrawworksGearsAbuse",data%Warnings%DrawworksGearsAbuse)
  431. call json%add(p,"RotaryGearsAbuse",data%Warnings%RotaryGearsAbuse)
  432. call json%add(p,"HoistLineBreak",data%Warnings%HoistLineBreak)
  433. call json%add(p,"PartedDrillString",data%Warnings%PartedDrillString)
  434. call json%add(p,"ActiveTankOverflow",data%Warnings%ActiveTankOverflow)
  435. call json%add(p,"ActiveTankUnderVolume",data%Warnings%ActiveTankUnderVolume)
  436. call json%add(p,"TripTankOverflow",data%Warnings%TripTankOverflow)
  437. call json%add(p,"DrillPipeTwistOff",data%Warnings%DrillPipeTwistOff)
  438. call json%add(p,"DrillPipeParted",data%Warnings%DrillPipeParted)
  439. call json%add(p,"TripWithSlipsSet",data%Warnings%TripWithSlipsSet)
  440. call json%add(p,"Blowout",data%Warnings%Blowout)
  441. call json%add(p,"UndergroundBlowout",data%Warnings%UndergroundBlowout)
  442. call json%add(p,"MaximumWellDepthExceeded",data%Warnings%MaximumWellDepthExceeded)
  443. call json%add(p,"CrownCollision",data%Warnings%CrownCollision)
  444. call json%add(p,"FloorCollision",data%Warnings%FloorCollision)
  445. call json%add(p,"TopdriveRotaryTableConfilict",data%Warnings%TopdriveRotaryTableConfilict)
  446. ! 3. add new node to parent
  447. call json%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 json%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 json%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 json%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 json%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 json%create_object(p,'Notifications')
  542. ! 2. add member of data type to new node
  543. ! 3. add new node to parent
  544. call json%add(parent,p)
  545. end subroutine
  546. subroutine ConfigurationFromJson(parent)
  547. type(json_value),pointer :: parent
  548. type(json_value),pointer :: p
  549. ! 1. get related root
  550. call json%get(parent,"Configuration",p)
  551. call StringConfigurationFromJson(p)
  552. call FormationFromJson(p)
  553. call ReservoirFromJson(p)
  554. call ShoeFromJson(p)
  555. call AccumulatorFromJson(p)
  556. call BopStackFromJson(p)
  557. call HoistingFromJson(p)
  558. call PowerFromJson(p)
  559. call PumpsFromJson(p)
  560. call RigSizeFromJson(p)
  561. call CasingLinerChokeFromJson(p)
  562. call PathGenerationFromJson(p)
  563. call MudPropertiesFromJson(p)
  564. call UnityInputsFromJson(p)
  565. ! 3. add new node to parent
  566. call json%add(parent,p)
  567. end subroutine
  568. subroutine WarningsFromJson(parent)
  569. type(json_value),pointer :: parent
  570. type(json_value),pointer :: p
  571. type(json_value),pointer :: pval
  572. ! 1. get node
  573. call json%get(parent,'Warnings',p)
  574. ! ! 2. add member of data type to new node
  575. call json%get(p,'PumpWithKellyDisconnected',pval)
  576. call json%get(pval,data%Warnings%PumpWithKellyDisconnected)
  577. call json%get(p,'PumpWithTopdriveDisconnected',pval)
  578. call json%get(pval,data%Warnings%PumpWithTopdriveDisconnected)
  579. call json%get(p,'Pump1PopOffValveBlown',pval)
  580. call json%get(pval,data%Warnings%Pump1PopOffValveBlown)
  581. call json%get(p,'Pump1Failure',pval)
  582. call json%get(pval,data%Warnings%Pump1Failure)
  583. call json%get(p,'Pump2PopOffValveBlown',pval)
  584. call json%get(pval,data%Warnings%Pump2PopOffValveBlown)
  585. call json%get(p,'Pump2Failure',pval)
  586. call json%get(pval,data%Warnings%Pump2Failure)
  587. call json%get(p,'Pump3PopOffValveBlown',pval)
  588. call json%get(pval,data%Warnings%Pump3PopOffValveBlown)
  589. call json%get(p,'Pump3Failure',pval)
  590. call json%get(pval,data%Warnings%Pump3Failure)
  591. call json%get(p,'DrawworksGearsAbuse',pval)
  592. call json%get(pval,data%Warnings%DrawworksGearsAbuse)
  593. call json%get(p,'RotaryGearsAbuse',pval)
  594. call json%get(pval,data%Warnings%RotaryGearsAbuse)
  595. call json%get(p,'HoistLineBreak',pval)
  596. call json%get(pval,data%Warnings%HoistLineBreak)
  597. call json%get(p,'PartedDrillString',pval)
  598. call json%get(pval,data%Warnings%PartedDrillString)
  599. call json%get(p,'ActiveTankOverflow',pval)
  600. call json%get(pval,data%Warnings%ActiveTankOverflow)
  601. call json%get(p,'ActiveTankUnderVolume',pval)
  602. call json%get(pval,data%Warnings%ActiveTankUnderVolume)
  603. call json%get(p,'TripTankOverflow',pval)
  604. call json%get(pval,data%Warnings%TripTankOverflow)
  605. call json%get(p,'DrillPipeTwistOff',pval)
  606. call json%get(pval,data%Warnings%DrillPipeTwistOff)
  607. call json%get(p,'DrillPipeParted',pval)
  608. call json%get(pval,data%Warnings%DrillPipeParted)
  609. call json%get(p,'TripWithSlipsSet',pval)
  610. call json%get(pval,data%Warnings%TripWithSlipsSet)
  611. call json%get(p,'Blowout',pval)
  612. call json%get(pval,data%Warnings%Blowout)
  613. call json%get(p,'UndergroundBlowout',pval)
  614. call json%get(pval,data%Warnings%UndergroundBlowout)
  615. call json%get(p,'MaximumWellDepthExceeded',pval)
  616. call json%get(pval,data%Warnings%MaximumWellDepthExceeded)
  617. call json%get(p,'CrownCollision',pval)
  618. call json%get(pval,data%Warnings%CrownCollision)
  619. call json%get(p,'FloorCollision',pval)
  620. call json%get(pval,data%Warnings%FloorCollision)
  621. call json%get(p,'TopdriveRotaryTableConfilict',pval)
  622. call json%get(pval,data%Warnings%TopdriveRotaryTableConfilict)
  623. end subroutine
  624. subroutine ProblemsFromJson(parent)
  625. type(json_value),pointer :: parent
  626. type(json_value),pointer :: p
  627. call json%get(parent,'Warnings',p)
  628. call BitProblemsToJson(p)
  629. call BopProblemsFromJson(p)
  630. call ChokeProblemsFromJson(p)
  631. call DrillStemProblemsFromJson(p)
  632. call GaugesProblemsFromJson(p)
  633. call HoistingProblemsFromJson(p)
  634. call KickProblemsFromJson(p)
  635. call LostProblemsFromJson(p)
  636. call MudTreatmentProblemsFromJson(p)
  637. call OtherProblemsFromJson(p)
  638. call PumpProblemsFromJson(p)
  639. call RotaryProblemsFromJson(p)
  640. end subroutine
  641. subroutine StateFromJson(parent)
  642. type(json_value),pointer :: parent
  643. type(json_value),pointer :: p
  644. ! 1. create new node
  645. ! call json%create_object(p,'State')
  646. ! ! call OperationScenarioFromJson(p)
  647. ! call notificationsFromJson(p)
  648. ! call permissionsFromJson(p)
  649. ! call unitySignalsFromJson(p)
  650. ! call StudentStationFromJson(p)
  651. ! call BopStackInputFromJson(p)
  652. ! call BopStackAccFromJson(p)
  653. ! call RamLineFromJson(p)
  654. ! call AnnularComputationalFromJson(p)
  655. ! call AnnularFromJson(p)
  656. ! call PipeRam1FromJson(p)
  657. ! call ShearRamFromJson(p)
  658. ! call PipeRam2FromJson(p)
  659. ! call ChokeLineFromJson(p)
  660. ! call KillLineFromJson(p)
  661. ! call PumpsFromJson(p)
  662. ! call RAMFromJson(p)
  663. ! call RAMSFromJson(p)
  664. ! call ChokeFromJson(p)
  665. ! call AirDrivenPumpFromJson(p)
  666. ! call AirPumpLineFromJson(p)
  667. ! call CHOOKEFromJson(p)
  668. ! call DrawworksFromJson(p)
  669. ! call MudSystemFromJson(p)
  670. ! call MUDFromJson(p)
  671. ! call MPumpsFromJson(p)
  672. ! call PUMPFromJson(p)
  673. ! call RTableFromJson(p)
  674. ! call TDSFromJson(p)
  675. ! call GasType(3)FromJson(p)
  676. ! call PressureDisplayFromJson(p)
  677. ! call FricPressDropFromJson(p)
  678. ! call ROP_SpecFromJson(p)
  679. ! call ROP_BitFromJson(p)
  680. ! call TDGeoFromJson(p)
  681. ! call F_String(:)FromJson(p)
  682. ! call F_CountsFromJson(p)
  683. ! call F_Interval(:)FromJson(p)
  684. ! call OD_Annulus(4)FromJson(p)
  685. ! call TD_DrillStemFromJson(p)
  686. ! call TD_DrillStemsFromJson(p)
  687. ! call TD_StringFromJson(p)
  688. ! call TD_CountFromJson(p)
  689. ! call G_StringElementFromJson(p)
  690. ! call TD_VolFromJson(p)
  691. ! call TD_GeneralFromJson(p)
  692. ! call TD_BOPFromJson(p)
  693. ! call TD_BOPElement(4)FromJson(p)
  694. ! call TD_StConnFromJson(p)
  695. ! call TD_LoadFromJson(p)
  696. ! call TD_WellElFromJson(p)
  697. ! call TD_CasingFromJson(p)
  698. ! call TD_LinerFromJson(p)
  699. ! call TD_OpenHoleFromJson(p)
  700. ! call TD_ROPHoleFromJson(p)
  701. ! call TD_WellGeneralFromJson(p)
  702. ! call TD_WellGeo(:)FromJson(p)
  703. ! 2. add member of data type to new node
  704. ! 3. add new node to parent
  705. call json%add(parent,p)
  706. end subroutine
  707. !use this as a template
  708. subroutine notificationsFromJson(parent)
  709. type(json_value),pointer :: parent
  710. !
  711. ! type(json_value),pointer :: p
  712. ! 1. create new node
  713. ! call json%create_object(p,'Notifications')
  714. ! ! 2. add member of data type to new node
  715. ! ! 3. add new node to parent
  716. ! call json%add(parent,p)
  717. end subroutine
  718. end module Simulator