1 module module_subsurface_properties
5 type subsurface_properties_interface
6 ! disaggregated lateral hydraulic conductivity, on the routing grid, with adjustment factor applied (Noah_distr_routing.F: 2641*) LKSAT*LKSATFAC*[0..1]
7 real, allocatable, dimension(:,:) :: lksatrt
9 ! water table depth (meters) (module_HYDRO_io.F: 1962*)
10 real, allocatable, dimension(:,:) :: zwattablrt
12 ! soil depth on routing grid
13 real, allocatable, dimension(:,:) :: soldeprt
16 real, allocatable, dimension(:) :: sldpth
19 real, dimension(100) :: zsoil
21 ! shared properties -- the following variables are shared from overland properties module
23 ! terrian slope in the x direction (m/m)
24 real, pointer, dimension(:,:) :: surface_slope_x => null()
26 ! terrian slope in the y direction (m/m)
27 real, pointer, dimension(:,:) :: surface_slope_y => null()
29 ! terrain surface slope in 8 ordinal directions (m/m) !
30 ! TODO verify this correct, check with Wei?
42 real, pointer, dimension(:,:,:) :: surface_slope => null()
44 ! index of neighboring cell in the direction of steepest terrain surface slope, used with surface_slope
45 integer, pointer, dimension(:,:,:) :: max_surface_slope_index => null()
47 ! centerpoint distance to each neighbor (m)
48 real, pointer, dimension(:,:,:) :: distance_to_neighbor => null()
50 ! disaggregated lksat decay exponent
51 real, allocatable, dimension(:,:) :: nexprt
55 procedure :: init => subsurface_properties_init
56 procedure :: destroy => subsurface_properties_destroy
57 end type subsurface_properties_interface
61 subroutine subsurface_properties_init(this,ix,jx,nsoil,overland_data)
63 class(subsurface_properties_interface), intent(inout) :: this ! the type object being initalized
64 integer, intent(in) :: ix ! x grid size
65 integer, intent(in) :: jx ! y grid size
66 integer, intent(in) :: nsoil ! number of soil layers
67 class(overland_struct), intent(inout) :: overland_data
69 logical :: allocation_error = .false.
71 ! allocate the array only if not already allocated
72 if ( .not. allocated(this%lksatrt) ) then
73 allocate( this%lksatrt(ix,jx) )
76 allocation_error = .true.
79 ! allocate the array only if not already allocated
80 if ( .not. allocated(this%zwattablrt) ) then
81 allocate( this%zwattablrt(ix,jx) )
84 allocation_error = .true.
87 ! allocate the array only if not already allocated
88 if ( .not. allocated(this%soldeprt) ) then
89 allocate( this%soldeprt(ix,jx) )
92 allocation_error = .true.
95 !allocate storage for sldpth
96 if ( .not. allocated(this%sldpth) ) then
97 allocate( this%sldpth(nsoil) )
100 allocation_error = .true.
105 ! now initalize the shared properties from overland data
107 if ( associated(overland_data%properties%surface_slope_x) ) then
108 this%surface_slope_x => overland_data%properties%surface_slope_x
110 allocation_error = .true.
113 if ( associated(overland_data%properties%surface_slope_y) ) then
114 this%surface_slope_y => overland_data%properties%surface_slope_y
116 allocation_error = .true.
119 if ( associated(overland_data%properties%surface_slope) ) then
120 this%surface_slope => overland_data%properties%surface_slope
122 allocation_error = .true.
125 if ( associated(overland_data%properties%max_surface_slope_index) ) then
126 this%max_surface_slope_index => overland_data%properties%max_surface_slope_index
128 allocation_error = .true.
131 if ( associated(overland_data%properties%distance_to_neighbor) ) then
132 this%distance_to_neighbor => overland_data%properties%distance_to_neighbor
134 allocation_error = .true.
137 ! allocate the array only if not already allocated
138 if ( .not. allocated(this%nexprt) ) then
139 allocate( this%nexprt(ix,jx) )
142 allocation_error = .true.
145 if ( allocation_error ) &
146 write(0,*) "attempt to allocate data in members of subsurface properties structure&
147 &that where already allocated. The allocated members where not changed"
149 end subroutine subsurface_properties_init
151 subroutine subsurface_properties_destroy(this)
153 class(subsurface_properties_interface), intent(inout) :: this ! the type object being destroyed
155 logical :: allocation_error = .false.
157 ! only deallocated if already allocated
158 if ( allocated(this%lksatrt) ) then
159 deallocate( this%lksatrt)
161 allocation_error = .true.
164 ! only deallocated if already allocated
165 if ( allocated(this%zwattablrt) ) then
166 deallocate( this%zwattablrt)
168 allocation_error = .true.
171 ! only deallocated if already allocated
172 if ( allocated(this%soldeprt) ) then
173 deallocate( this%soldeprt)
175 allocation_error = .true.
178 ! only deallocated if already allocated
179 if ( allocated(this%sldpth) ) then
180 deallocate( this%sldpth)
182 allocation_error = .true.
186 ! now release the shared properties from overland data
188 if ( associated(this%surface_slope_x) ) then
189 this%surface_slope_x => null()
191 allocation_error = .true.
194 if ( associated(this%surface_slope_y) ) then
195 this%surface_slope_y => null()
197 allocation_error = .true.
200 if ( associated(this%surface_slope) ) then
201 this%surface_slope => null()
203 allocation_error = .true.
206 if ( associated(this%max_surface_slope_index) ) then
207 this%max_surface_slope_index => null()
209 allocation_error = .true.
212 if ( associated(this%distance_to_neighbor) ) then
213 this%distance_to_neighbor => null()
215 allocation_error = .true.
218 ! only deallocated if already allocated
219 if ( allocated(this%nexprt) ) then
220 deallocate( this%nexprt)
222 allocation_error = .true.
225 if ( allocation_error ) &
226 write(0,*) "attempt to deallocate data in members of subsurface properties structure&
227 &that where not allocated. The unallocated members where not changed"
229 end subroutine subsurface_properties_destroy
231 end module module_subsurface_properties