1 module module_subsurface_state
4 type subsurface_state_interface
5 ! total flow from boundary cells to outside of domain; on routing grid
8 ! subsurface flow (m^3/s)
9 real, allocatable, dimension(:,:) :: qsubrt
11 ! flow from boundary cells to outside of domain on routing grid
12 real, allocatable, dimension(:,:) :: qsubbdryrt
14 procedure :: init => subsurface_state_init
15 procedure :: destroy => subsurface_state_destroy
16 end type subsurface_state_interface
20 subroutine subsurface_state_init(this, ix, jx)
22 class(subsurface_state_interface), intent(inout) :: this ! the type object being initialized
23 integer, intent(in) :: ix ! x grid size
24 integer, intent(in) :: jx ! y grid size
26 logical :: allocation_error = .false.
28 this%qsubbdrytrt = 0.0
30 if ( .not. allocated(this%qsubrt) ) then
31 allocate( this%qsubrt(ix,jx) )
34 allocation_error = .true.
37 if ( .not. allocated(this%qsubbdryrt) ) then
38 allocate( this%qsubbdryrt(ix,jx) )
41 allocation_error = .true.
44 if ( allocation_error ) &
45 write(0,*) "attempt to allocate data in members of subsurface io structure&
46 &that where already allocated. The allocated members where not changed"
48 end subroutine subsurface_state_init
50 subroutine subsurface_state_destroy(this)
52 class(subsurface_state_interface), intent(inout) :: this ! the type object being initialized
54 logical :: allocation_error = .false.
56 if ( allocated(this%qsubrt) ) then
57 deallocate( this%qsubrt )
59 allocation_error = .true.
62 if ( allocated(this%qsubbdryrt) ) then
63 deallocate( this%qsubbdryrt )
65 allocation_error = .true.
68 if ( allocation_error ) &
69 write(0,*) "attempt to deallocate data in members of subsurface io structure&
70 &that where not allocated. The unallocated members where not changed"
72 end subroutine subsurface_state_destroy
74 end module module_subsurface_state