Simulation Core
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

811 lignes
26 KiB

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