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.

CFormation.f90 2.8 KiB

1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. do i=1,n_children
  22. call json%get_child(p, i, pitem, found=is_found)
  23. call json%get(pitem,'Top',pval)
  24. call json%get(pval,data%Configuration%Formation%Formations(i)%Top)
  25. call json%get(pitem,'Thickness',pval)
  26. call json%get(pval,data%Configuration%Formation%Formations(i)%Thickness)
  27. call json%get(pitem,'Drillablity',pval)
  28. call json%get(pval,data%Configuration%Formation%Formations(i)%Drillablity)
  29. call json%get(pitem,'Abrasiveness',pval)
  30. call json%get(pval,data%Configuration%Formation%Formations(i)%Abrasiveness)
  31. call json%get(pitem,'ThresholdWeight',pval)
  32. call json%get(pval,data%Configuration%Formation%Formations(i)%ThresholdWeight)
  33. call json%get(pitem,'PorePressureGradient',pval)
  34. call json%get(pval,data%Configuration%Formation%Formations(i)%PorePressureGradient)
  35. end do
  36. end subroutine
  37. subroutine FormationToJson(parent)
  38. type(json_value),pointer :: parent
  39. type(json_core) :: json
  40. type(json_value),pointer :: p,pform
  41. integer :: i,n
  42. ! 1. create new node
  43. call json%create_array(p,'Formations')
  44. n= data%Configuration%Formation%Count
  45. do i=1,n
  46. call json%create_object(pform,'')
  47. call json%add(pform,"Abrasiveness",data%Configuration%Formation%Formations(i)%Abrasiveness)
  48. call json%add(pform,"Drillablity",data%Configuration%Formation%Formations(i)%Drillablity)
  49. call json%add(pform,"PorePressureGradient",data%Configuration%Formation%Formations(i)%PorePressureGradient)
  50. call json%add(pform,"Thickness",data%Configuration%Formation%Formations(i)%Thickness)
  51. call json%add(pform,"ThresholdWeight",data%Configuration%Formation%Formations(i)%ThresholdWeight)
  52. call json%add(pform,"Top",data%Configuration%Formation%Formations(i)%Top)
  53. call json%add(p,pform)
  54. end do
  55. call json%add(parent,p)
  56. end subroutine
  57. end module CFormation