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.
 
 
 
 
 
 

71 lines
2.9 KiB

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