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.
 
 
 
 
 
 

102 lines
3.9 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/WellProfile/CPathGeneration.f90"
  2. module CPathGeneration
  3. use SimulationVariables !@
  4. use json_module
  5. implicit none
  6. public
  7. contains
  8. subroutine PathGenerationToJson(parent)
  9. type(json_value),pointer :: parent
  10. type(json_core) :: json
  11. type(json_value),pointer :: ppath,pitems,p
  12. integer::i,n
  13. ! 1. create new node
  14. call json%create_object(ppath,'Path')
  15. call json%create_array(pitems,'Items')
  16. n = data%Configuration%Path%ItemCount
  17. do i=1,n
  18. call json%create_object(p,'')
  19. call json%add(p,"HoleType",data%Configuration%Path%items(i)%HoleType)
  20. call json%add(p,"Angle",data%Configuration%Path%items(i)%Angle)
  21. call json%add(p,"Length",data%Configuration%Path%items(i)%Length)
  22. call json%add(p,"FinalAngle",data%Configuration%Path%items(i)%FinalAngle)
  23. call json%add(p,"TotalLength",data%Configuration%Path%items(i)%TotalLength)
  24. call json%add(p,"MeasuredDepth",data%Configuration%Path%items(i)%MeasuredDepth)
  25. call json%add(p,"TotalVerticalDepth",data%Configuration%Path%items(i)%TotalVerticalDepth)
  26. call json%add(pitems,p)
  27. end do
  28. ! call json%create_array(pdp,'DataPoints')
  29. ! do i=1,data%Configuration%Path%DataPointsCount
  30. ! call json%create_object(p,'')
  31. ! call json%add(p,"X",data%Configuration%Path%DataPoints(i)%X)
  32. ! call json%add(p,"Y",data%Configuration%Path%DataPoints(i)%Y)
  33. ! call json%add(pdp,p)
  34. ! end do
  35. ! 3. add new node to parent
  36. call json%add(ppath,pitems)
  37. ! call json%add(ppath,pdp)
  38. call json%add(parent,ppath)
  39. end subroutine
  40. subroutine PathGenerationFromJson(parent)
  41. use json_module,IK =>json_ik
  42. type(json_value),pointer :: parent
  43. type(json_core) :: json
  44. type(json_value),pointer :: p,pitems,pitem,pval
  45. logical::is_found
  46. integer::i,n_children
  47. call json%get(parent,'Path',p)
  48. call json%get(p,'Items',pitems)
  49. call json%info(pitems, n_children=n_children)
  50. if (.not. allocated(data%Configuration%Path%Items)) then
  51. ALLOCATE(data%Configuration%Path%Items(n_children))
  52. endif
  53. if(size(data%Configuration%Path%Items)/=n_children) then
  54. DEALLOCATE(data%Configuration%Path%Items)
  55. ALLOCATE(data%Configuration%Path%Items(n_children))
  56. endif
  57. do i=1,n_children
  58. call json%get_child(pitems, i, pitem, found=is_found)
  59. call json%get(pitem,"HoleType",pval)
  60. call json%get(pval,data%Configuration%Path%Items(i)%HoleType)
  61. call json%get(pitem,"Angle",pval)
  62. call json%get(pval,data%Configuration%Path%Items(i)%Angle)
  63. call json%get(pitem,"Length",pval)
  64. call json%get(pval,data%Configuration%Path%Items(i)%Length)
  65. call json%get(pitem,"FinalAngle",pval)
  66. call json%get(pval,data%Configuration%Path%Items(i)%FinalAngle)
  67. call json%get(pitem,"TotalLength",pval)
  68. call json%get(pval,data%Configuration%Path%Items(i)%TotalLength)
  69. call json%get(pitem,"MeasuredDepth",pval)
  70. call json%get(pval,data%Configuration%Path%Items(i)%MeasuredDepth)
  71. call json%get(pitem,"TotalVerticalDepth",pval)
  72. call json%get(pval,data%Configuration%Path%Items(i)%TotalVerticalDepth)
  73. end do
  74. ! call json%get(p,'DataPoints',dpoints)
  75. ! call json%info(dpoints, n_children=n_children)
  76. ! if (.not. allocated(data%Configuration%Path%DataPoints) .or. size(data%Configuration%Path%DataPoints)/=n_children) then
  77. ! ALLOCATE(data%Configuration%Path%DataPoints(n_children))
  78. ! endif
  79. ! do i=1,n_children
  80. ! call json%get_child(dpoints, i, dpoint, found=is_found)
  81. ! call json%get(dpoint,"X",pval)
  82. ! call json%get(pval,data%Configuration%Path%DataPoints(i)%X)
  83. ! call json%get(dpoint,"Y",pval)
  84. ! call json%get(pval,data%Configuration%Path%DataPoints(i)%Y)
  85. ! end do
  86. end subroutine
  87. end module CPathGeneration