Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(:) | :: | hydrotope_id | ||
real, | intent(in), | dimension(:) | :: | hydrotope_area | ||
integer, | intent(in), | dimension(:) | :: | hydrotope_subbasin | ||
integer, | intent(in), | dimension(:) | :: | subbasin_id | ||
integer, | intent(in), | dimension(:) | :: | subbasin_nhydrotopes | ||
integer, | intent(in), | dimension(:) | :: | subbasin_catchment | ||
integer, | intent(in), | dimension(:) | :: | catchment_id | ||
integer, | intent(in) | :: | hydrotope_input_fid | |||
integer, | intent(in) | :: | subbasin_input_fid |
subroutine output_initialise(hydrotope_id, hydrotope_area, hydrotope_subbasin, &
subbasin_id, subbasin_nhydrotopes, subbasin_catchment, catchment_id, &
hydrotope_input_fid, subbasin_input_fid)
! Process user input before variables are registered
use utilities, only: string_index
integer, dimension(:), intent(in) :: &
! Hydrotope IDs and subbasin mapping (must be same length)
hydrotope_id, hydrotope_subbasin, &
! Subbasin IDs and catchment mapping (must be same length)
subbasin_id, subbasin_nhydrotopes, subbasin_catchment, &
!Catchment IDs
catchment_id
! Hydrotope area for weighted averages
real, dimension(:), intent(in) :: hydrotope_area
! File ids to read output labels
integer, intent(in) :: hydrotope_input_fid
integer, intent(in) :: subbasin_input_fid
integer s
! Hydrotope arrays
output_nhydrotopes = size(hydrotope_id)
allocate(output_hydrotope_id(output_nhydrotopes))
allocate(output_hydrotope_subbasin_ix(output_nhydrotopes))
allocate(output_hydrotope_subbasin_share(output_nhydrotopes))
output_hydrotope_id = hydrotope_id
! Subbasin arrays
output_nsubbasins = size(subbasin_id)
allocate(output_subbasin_id(output_nsubbasins))
allocate(output_subbasin_catchment_ix(output_nsubbasins))
! initialised with 2 because if catchment ids not read with subcatch = False
! 2 is the index of the default catchment ID, 1 being the total catchment
output_subbasin_catchment_ix = 2
allocate(output_subbasin_catchment_share(output_nsubbasins))
output_subbasin_id = subbasin_id
allocate(output_subbasin_nhydrotopes(output_nsubbasins))
output_subbasin_nhydrotopes = subbasin_nhydrotopes
allocate(output_subbasin_hydrotope_stix(output_nsubbasins))
output_subbasin_hydrotope_stix = 0
! Make cumsum out of sparse hydrotope numbers for quick start index
do s = 1, output_nsubbasins-1
output_subbasin_hydrotope_stix(s+1) = &
output_subbasin_hydrotope_stix(s) + subbasin_nhydrotopes(s)
end do
! Catchment arrays
output_ncatchments = size(catchment_id) + 1 ! one extra for catchment total
allocate(output_catchment_id(output_ncatchments))
allocate(output_catchment_basin_share(output_ncatchments))
output_catchment_id(1) = 0
output_catchment_id(2:output_ncatchments) = catchment_id
allocate(output_storage_index(output_nfiles, output_nvars))
output_storage_index = 0
call output_initialise_unit_shares(hydrotope_subbasin, subbasin_catchment, hydrotope_area)
call output_initialise_time
! Fill convenience matrix
call output_initialise_is_requested
call output_initialise_storage(hydrotope_input_fid, subbasin_input_fid)
call output_allocate(output_nsubbasins, output_nsubbasins)
end subroutine output_initialise