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.
 
 
 
 
 
 

823 lines
26 KiB

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