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.

CPower.f90 2.3 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. module CPower
  2. use SimulationVariables
  3. use json_module
  4. implicit none
  5. public
  6. contains
  7. subroutine PowerToJson(parent)
  8. type(json_value),pointer :: parent
  9. type(json_core) :: json
  10. type(json_value),pointer :: p
  11. ! 1. create new node
  12. call json%create_object(p,'Power')
  13. ! 2. add member of data type to new node
  14. ! call StringConfigurationToJson(p)
  15. ! call FormationToJson(p)
  16. call json%add(p,"CementPump",data%Configuration%Power%CementPump)
  17. call json%add(p,"Drawworks",data%Configuration%Power%Drawworks)
  18. call json%add(p,"GeneratorPowerRating",data%Configuration%Power%GeneratorPowerRating)
  19. call json%add(p,"MudPump1",data%Configuration%Power%MudPump1)
  20. call json%add(p,"MudPump2",data%Configuration%Power%MudPump2)
  21. call json%add(p,"NumberOfgenerators",data%Configuration%Power%NumberOfgenerators)
  22. call json%add(p,"RotaryTable",data%Configuration%Power%RotaryTable)
  23. call json%add(p,"TopDrive",data%Configuration%Power%TopDrive)
  24. ! 3. add new node to parent
  25. call json%add(parent,p)
  26. end subroutine
  27. subroutine PowerFromJson(parent)
  28. use json_module,IK =>json_ik
  29. type(json_value),pointer :: parent
  30. type(json_core) :: json
  31. type(json_value),pointer :: p,pitems,pitem,pval,pbit
  32. call json%get(parent,'Power',p)
  33. call json%get(p,"CementPump",pitem)
  34. call json%get(pitem,data%Configuration%Power%CementPump)
  35. call json%get(p,"Drawworks",pitem)
  36. call json%get(pitem,data%Configuration%Power%Drawworks)
  37. call json%get(p,"GeneratorPowerRating",pitem)
  38. call json%get(pitem,data%Configuration%Power%GeneratorPowerRating)
  39. call json%get(p,"MudPump1",pitem)
  40. call json%get(pitem,data%Configuration%Power%MudPump1)
  41. call json%get(p,"MudPump2",pitem)
  42. call json%get(pitem,data%Configuration%Power%MudPump2)
  43. call json%get(p,"NumberOfgenerators",pitem)
  44. call json%get(pitem,data%Configuration%Power%NumberOfgenerators)
  45. call json%get(p,"RotaryTable",pitem)
  46. call json%get(pitem,data%Configuration%Power%RotaryTable)
  47. call json%get(p,"TopDrive",pitem)
  48. call json%get(pitem,data%Configuration%Power%TopDrive)
  49. end subroutine
  50. end module CPower