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.
 
 
 
 
 
 

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