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.
 
 
 
 
 
 

810 lines
28 KiB

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