Simulation Core
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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