Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / hydro / Routing / Reservoirs / RFC_Forecasts / module_rfc_forecasts_state.F90
blobe71d6c1f05c167edd145475846dafec28980e3be
1 ! This module defines and instantiates objects
2 ! for an rfc forecasts type reservoir's state.
3 ! State holds and tracks dynamic/changing variables
4 ! that are only relevant to the given rfc forecasts
5 ! reservoir object and not other modules or areas
6 ! of the system.
8 module module_rfc_forecasts_state
10     use module_levelpool, only: levelpool
11     use module_reservoir, only: reservoir_state
12     implicit none
14     ! Extend/derive rfc forecasts state from the abstract base
15     ! type for reservoir state.
16     type, extends(reservoir_state) :: rfc_forecasts_state_interface
17         real                               :: water_elevation           ! meters AMSL
18         real                               :: levelpool_water_elevation ! meters AMSL
19         real, allocatable, dimension(:)    :: discharges
20         logical, allocatable, dimension(:) :: synthetic_values
21         integer                         :: time_series_update_time  ! seconds
22         integer                         :: current_time             ! seconds
23         integer                         :: time_series_index
24         logical                         :: forecast_found
25         logical                         :: all_discharges_synthetic
26         integer                         :: dynamic_reservoir_type    ! dynamic reservoir type sent to lake out files
27         real                            :: assimilated_value
28         character(len=256)              :: assimilated_source_file
29         integer                         :: levelpool_reservoir_type    ! reservoir type for levelpool
30         real                            :: levelpool_assimilated_value ! levelpool assimilated sentinel value
31         character(len=256)              :: levelpool_assimilated_source_file ! empty string for levelpool assimilated source
33         type (levelpool), pointer :: levelpool_ptr   ! pointer to levelpool object
35     contains
37         procedure :: init => rfc_forecasts_state_init
38         procedure :: destroy => rfc_forecasts_state_destroy
40     end type rfc_forecasts_state_interface
42 contains
44     ! RFC Forecasts State Constructor
45     subroutine rfc_forecasts_state_init(this, water_elevation, lake_area, lake_max_water_elevation, orifice_elevation, initial_fractional_depth)
46         implicit none
47         class(rfc_forecasts_state_interface), intent(inout) :: this ! the type object being initialized
48         real, intent(in) :: water_elevation           ! meters AMSL
49         real, intent(in) :: lake_area                 ! area of lake (km^2)
50         real, intent(in) :: lake_max_water_elevation  ! max water elevation (meters)
51         real, intent(in) :: orifice_elevation         ! orifice elevation (meters AMSL)
52         real, intent(in) :: initial_fractional_depth  ! initial fraction water depth
54         ! Initialize the state water elevation in same manner as in module_RT.F
55         this%water_elevation = orifice_elevation + ((lake_max_water_elevation - orifice_elevation) * initial_fractional_depth)
56         this%levelpool_water_elevation = this%water_elevation
57         this%time_series_update_time = 0
58         this%current_time = 0
59         this%time_series_index = 1
60         this%forecast_found = .FALSE.
61         this%all_discharges_synthetic = .FALSE.
63         ! Initialize dynamic_reservoir_type to 4 for RFC type reservoir
64         this%dynamic_reservoir_type = 4
66         ! Initialize to default sentinel, -9999.0
67         this%assimilated_value = -9999.0
69         ! Initialize to default empty string
70         this%assimilated_source_file = ""
72         ! Levelpool reservoir type set to 1
73         this%levelpool_reservoir_type = 1
75         ! Set to default sentinel, -999.0
76         this%levelpool_assimilated_value = -9999.0
78         ! Set to default string
79         this%levelpool_assimilated_source_file = ""
81     end subroutine rfc_forecasts_state_init
83     ! RFC Forecasts State Destructor
84     subroutine rfc_forecasts_state_destroy(this)
85         implicit none
86         class(rfc_forecasts_state_interface), intent(inout) :: this ! the type object being destroyed
88     end subroutine rfc_forecasts_state_destroy
90 end module module_rfc_forecasts_state