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.
 
 
 
 
 
 

69 lines
2.9 KiB

  1. module CFormation
  2. use CFormationVariables
  3. use SimulationVariables
  4. use json_module
  5. implicit none
  6. contains
  7. subroutine FormationFromJson(parent)
  8. use json_module,IK =>json_ik
  9. type(json_value),pointer :: parent
  10. type(json_core) :: json
  11. type(json_value),pointer :: p,pitem,pval
  12. logical::is_found
  13. integer::i,n_children
  14. CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val
  15. call json%get(parent,'Formation',p)
  16. call json%info(p, n_children=n_children)
  17. data%Configuration%Formation%Count = n_children
  18. if (.not. allocated(data%Configuration%Formation%Formations) .or. size(data%Configuration%Formation%Formations)/=n_children) then
  19. ALLOCATE(data%Configuration%Formation%Formations(n_children))
  20. endif
  21. data%Configuration%Formation%Count = n_children
  22. do i=1,n_children
  23. call json%get_child(p, i, pitem, found=is_found)
  24. call json%get(pitem,'Top',pval)
  25. call json%get(pval,data%Configuration%Formation%Formations(i)%Top)
  26. call json%get(pitem,'Thickness',pval)
  27. call json%get(pval,data%Configuration%Formation%Formations(i)%Thickness)
  28. call json%get(pitem,'Drillablity',pval)
  29. call json%get(pval,data%Configuration%Formation%Formations(i)%Drillablity)
  30. call json%get(pitem,'Abrasiveness',pval)
  31. call json%get(pval,data%Configuration%Formation%Formations(i)%Abrasiveness)
  32. call json%get(pitem,'ThresholdWeight',pval)
  33. call json%get(pval,data%Configuration%Formation%Formations(i)%ThresholdWeight)
  34. call json%get(pitem,'PorePressureGradient',pval)
  35. call json%get(pval,data%Configuration%Formation%Formations(i)%PorePressureGradient)
  36. end do
  37. end subroutine
  38. subroutine FormationToJson(parent)
  39. type(json_value),pointer :: parent
  40. type(json_core) :: json
  41. type(json_value),pointer :: p,pform
  42. integer :: i,n
  43. ! 1. create new node
  44. call json%create_array(p,'Formations')
  45. n= data%Configuration%Formation%Count
  46. do i=1,n
  47. call json%create_object(pform,'')
  48. call json%add(pform,"Abrasiveness",data%Configuration%Formation%Formations(i)%Abrasiveness)
  49. call json%add(pform,"Drillablity",data%Configuration%Formation%Formations(i)%Drillablity)
  50. call json%add(pform,"PorePressureGradient",data%Configuration%Formation%Formations(i)%PorePressureGradient)
  51. call json%add(pform,"Thickness",data%Configuration%Formation%Formations(i)%Thickness)
  52. call json%add(pform,"ThresholdWeight",data%Configuration%Formation%Formations(i)%ThresholdWeight)
  53. call json%add(pform,"Top",data%Configuration%Formation%Formations(i)%Top)
  54. call json%add(p,pform)
  55. end do
  56. call json%add(parent,p)
  57. end subroutine
  58. end module CFormation