Simulation Core
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

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