Simulation Core
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

827 Zeilen
26 KiB

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