subroutine output_initialise_storage_index
use utilities, only: string_index, indeces_in_array
integer fi, sp, i, cumsum(output_nvars)
type(output_file) :: fl
do fi = 1, output_nfiles
fl = output_files(fi)
sp = fl%space
if (sp > 3) sp = sp - 3
cumsum = 0
do i = 1, output_nvars
cumsum(i) = sum(output_is_requested(:i, sp, fl%time))
end do
output_storage_index(fi, :fl%nvars) = cumsum(fl%variable_ix(:fl%nvars))
end do
! hydrotope/subbasin storage indeces
allocate(output_hydrotope_var_ix(output_nvars))
output_hydrotope_var_ix = 0
allocate(output_subbasin_var_ix(output_nvars))
output_subbasin_var_ix = 0
allocate(output_hydrotope_requested_ix(sum(output_is_requested(:, 1, 1))))
output_hydrotope_requested_ix = 0
! Hydrotope/subbasin indeces
output_hydrotope_requested_ix = indeces_in_array( &
pack(output_requested_vars(:output_nvars), output_is_requested(:, 1, 1) == 1), &
output_hydrotope_vars)
output_hydrotope_var_ix = indeces_in_array( &
output_requested_vars(:output_nvars), output_hydrotope_vars)
output_subbasin_var_ix = indeces_in_array(&
output_requested_vars(:output_nvars), output_subbasin_vars)
end subroutine output_initialise_storage_index