14 use mo_kind,
only: i4, dp
27 use mo_message,
only : error_message, message
28 use mo_string_utils,
only : num2str
29 use mo_utils,
only : ge
31 use mo_orderpack,
only: sort_index
32 use mo_eckhardt_filter,
only: eckhardt_filter_fit, bfi
35 real(dp),
allocatable :: baseflow(:), runoff_obs(:)
36 logical,
allocatable :: runoff_obs_mask(:)
37 integer(i4),
allocatable :: id_sort(:)
38 integer(i4) :: idomain, id, length, mask_length, tt
41 if (
nmeasperday > 1 )
call error_message(
"BFI: calculation only possible with daily discharge values!")
44 if (
size(
gauge%domainId) /=
domainmeta%nDomains)
call error_message(
"BFI: number of gauges and domains need to be equal!")
45 allocate(id_sort(
size(
gauge%domainId)))
46 id_sort = sort_index(
gauge%domainId)
51 if ( .not. (
bfi_obs(idomain) < 0.0_dp) )
then
53 " BFI: using given BFI value ", &
54 trim(adjustl(num2str(
bfi_obs(idomain)))), &
56 trim(adjustl(num2str(idomain))) &
62 if (
gauge%domainId(id) /= idomain)
call error_message(
"BFI: exactly one gauge per domain required!")
68 if (
allocated(runoff_obs_mask))
deallocate(runoff_obs_mask)
69 if (
allocated(runoff_obs))
deallocate(runoff_obs)
70 if (
allocated(baseflow))
deallocate(baseflow)
71 allocate(runoff_obs_mask(length))
72 allocate(runoff_obs(length))
73 runoff_obs =
gauge%Q(1 : length, id)
76 forall(tt = 1 : length) runoff_obs_mask(tt) = ge(runoff_obs(tt), 0.0_dp)
79 baseflow = eckhardt_filter_fit(runoff_obs, mask=runoff_obs_mask)
80 bfi_obs(idomain) = bfi(baseflow, runoff_obs, mask=runoff_obs_mask)
83 " BFI: calculated BFI value ", &
84 trim(adjustl(num2str(
bfi_obs(idomain)))), &
86 trim(adjustl(num2str(idomain))) &
Provides structures needed by mHM, mRM and/or mpr.
integer(i4), public ntstepday
integer(i4), dimension(:), allocatable, public warmingdays
type(period), dimension(:), allocatable, public evalper
Provides structures needed by mHM, mRM and/or mpr.
type(domain_meta), public domainmeta
Main global variables for mHM.
real(dp), dimension(:), allocatable, public bfi_obs
given base-flow index per domain
Module to calculate BFI form gauging stations in mHM.
subroutine, public calculate_bfi()
Calculate BFI from given discharge observation.
Global variables for mRM only.
type(gaugingstation), public gauge
integer(i4), public nmeasperday