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.

CProblemDifinition.f90 3.0 KiB

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. module CProblemDifinition
  2. use CIActionReference
  3. implicit none
  4. public
  5. ! procedure (ActionInteger), pointer :: Nil => null()
  6. integer, parameter :: Time_ProblemType = 0
  7. integer, parameter :: PumpStrokes_ProblemType = 1
  8. integer, parameter :: VolumePumped_ProblemType = 2
  9. integer, parameter :: DistanceDrilled_ProblemType = 3
  10. integer, parameter :: Clear_StatusType = 0
  11. integer, parameter :: Now_StatusType = 1
  12. integer, parameter :: Later_StatusType = 2
  13. integer, parameter :: Executed_StatusType = 3
  14. type, bind(c), public :: CProblem
  15. integer :: ProblemType
  16. integer :: StatusType
  17. real(8) :: Value
  18. real(8) :: DueValue
  19. end type CProblem
  20. contains
  21. subroutine Execute(problem, action)
  22. type(CProblem), intent(inout) :: problem
  23. procedure (ActionInteger), pointer, intent(in) :: action
  24. problem%StatusType = Executed_StatusType
  25. if(problem%StatusType == Executed_StatusType .and. associated(action)) call action(Executed_StatusType)
  26. end subroutine
  27. subroutine ProcessDueTime(problem, action, time)
  28. use CLog3
  29. implicit none
  30. type(CProblem) :: problem
  31. procedure (ActionInteger), pointer, intent(in) :: action
  32. integer :: time
  33. if(problem%ProblemType == Time_ProblemType .and. problem%StatusType /= Executed_StatusType .and. problem%StatusType /= Clear_StatusType) then
  34. if(time >= int(problem%DueValue)) call Execute(problem, action)
  35. end if
  36. end subroutine
  37. subroutine ProcessDuePumpStrokes(problem, action, strokes)
  38. implicit none
  39. type(CProblem) :: problem
  40. procedure (ActionInteger), pointer, intent(in) :: action
  41. integer :: strokes
  42. if(problem%ProblemType == PumpStrokes_ProblemType .and. problem%StatusType /= Executed_StatusType .and. problem%StatusType /= Clear_StatusType) then
  43. if(strokes >= int(problem%DueValue)) call Execute(problem, action)
  44. end if
  45. end subroutine
  46. subroutine ProcessDueVolumePumped(problem, action, volume)
  47. implicit none
  48. type(CProblem) :: problem
  49. procedure (ActionInteger), pointer, intent(in) :: action
  50. real(8) :: volume
  51. if(problem%ProblemType == VolumePumped_ProblemType .and. problem%StatusType /= Executed_StatusType .and. problem%StatusType /= Clear_StatusType) then
  52. if(volume >= problem%DueValue) call Execute(problem, action)
  53. end if
  54. end subroutine
  55. subroutine ProcessDueDistanceDrilled(problem, action, distance)
  56. implicit none
  57. type(CProblem) :: problem
  58. procedure (ActionInteger), pointer, intent(in) :: action
  59. real(8) :: distance
  60. if(problem%ProblemType == DistanceDrilled_ProblemType .and. problem%StatusType /= Executed_StatusType .and. problem%StatusType /= Clear_StatusType) then
  61. if(distance >= problem%DueValue) call Execute(problem, action)
  62. end if
  63. end subroutine
  64. end module CProblemDifinition