63 USE mo_kind,
ONLY : i4, dp
64 use mo_optimization_utils,
only : eval_interface
65 use mo_message,
only: message, error_message
66 use mo_string_utils,
only : num2str
127 REAL(dp),
DIMENSION(:),
INTENT(IN) :: parameterset
129 procedure(eval_interface),
INTENT(IN),
POINTER :: eval
131 real(dp),
optional,
intent(in) :: arg1
133 real(dp),
optional,
intent(out) :: arg2
135 real(dp),
optional,
intent(out) :: arg3
192 call error_message(
"Error objective: This opti_function is either not implemented yet or is not a single-objective one.")
246 REAL(dp),
DIMENSION(:),
INTENT(IN) :: parameterset
248 procedure(eval_interface),
INTENT(IN),
POINTER :: eval
250 real(dp),
optional,
intent(in) :: arg1
252 real(dp),
optional,
intent(out) :: arg2
254 real(dp),
optional,
intent(out) :: arg3
258 REAL(dp) :: partial_objective
261 real(dp),
parameter :: onesixth = 1.0_dp / 6.0_dp
263 integer(i4) :: iproc, nproc
265 integer(i4) :: ierror
267 type(mpi_status) :: status
270 call distribute_parameterset(parameterset)
272 case(1 : 3, 5, 6, 9, 31)
273 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
275 do iproc = 1, nproc - 1
276 call mpi_recv(partial_objective, 1, mpi_double_precision, iproc, 0,
domainmeta%comMaster, status, ierror)
281 call mpi_comm_size(
domainmeta%comMaster, nproc, ierror)
283 do iproc = 1, nproc - 1
284 call mpi_recv(partial_objective, 1, mpi_double_precision, iproc, 0,
domainmeta%comMaster, status, ierror)
289 call message(
"case 4, 7, 8 are not implemented in parallel yet")
291 call error_message(
"Error single_objective_runoff_master:", raise=.false.)
292 call error_message(
"This opti_function is either not implemented yet or is not a single-objective one.")
306 call error_message(
"case 4, loglikelihood_stddev not implemented in parallel yet")
315 call error_message(
"case 7, single_objective_runoff_master not implemented in parallel yet")
317 call error_message(
"case 8, loglikelihood_evin2013_2 not implemented in parallel yet")
332 call error_message(
"Error single_objective_runoff_master:", raise=.false.)
333 call error_message(
"This opti_function is either not implemented yet or is not a single-objective one.", raise=.false.)
334 call error_message(
"This part of the code should never be executed.")
387 procedure(eval_interface),
INTENT(IN),
POINTER :: eval
389 real(dp),
optional,
intent(in) :: arg1
391 real(dp),
optional,
intent(out) :: arg2
393 real(dp),
optional,
intent(out) :: arg3
395 REAL(dp) :: partial_single_objective_runoff
397 REAL(dp),
DIMENSION(:),
allocatable :: parameterset
399 integer(i4) :: ierror
401 type(mpi_status) :: status
403 logical :: do_obj_loop
407 call mpi_recv(do_obj_loop, 1, mpi_logical, 0, 0,
domainmeta%comMaster, status, ierror)
409 if (.not. do_obj_loop)
exit
411 call get_parameterset(parameterset)
415 partial_single_objective_runoff =
objective_nse(parameterset, eval)
426 call error_message(
"Error single_objective_runoff_subprocess: case 4 with optimethod 0 not supported")
436 partial_single_objective_runoff =
objective_sse(parameterset, eval)
440 call error_message(
"Error single_objective_runoff_subprocess: case 7 not supported")
445 call error_message(
"Error single_objective_runoff_subprocess: case 8 with optimethod 0 not supported")
454 partial_single_objective_runoff =
objective_kge(parameterset, eval)
466 call error_message(
"Error single_objective_runoff_subprocess:", raise=.false.)
467 call error_message(
"This opti_function is either not implemented yet or is not a single-objective one.")
471 case (1 : 3, 5, 6, 9, 14, 31)
472 call mpi_send(partial_single_objective_runoff,1, mpi_double_precision,0,0,
domainmeta%comMaster,ierror)
474 call error_message(
"Error objective_subprocess: this part should not be executed -> error in the code.")
476 deallocate(parameterset)
516 REAL(dp),
DIMENSION(:),
INTENT(IN) :: parameterset
518 procedure(eval_interface),
INTENT(IN),
pointer :: eval
520 REAL(dp),
DIMENSION(:),
ALLOCATABLE,
INTENT(OUT) :: multi_objectives
541 call error_message(
"Error objective: Either this opti_function is not implemented yet or it is not a multi-objective one.")
586 use mo_append,
only : append
587 use mo_linfit,
only : linfit
588 use mo_moment,
only : correlation, mean
592 real(dp),
dimension(:),
intent(in) :: parameterset
594 procedure(eval_interface),
INTENT(IN),
pointer :: eval
597 real(dp),
intent(in) :: stddev
601 real(dp),
intent(out),
optional :: stddev_new
604 real(dp),
intent(out),
optional :: likeli_new
610 real(dp),
dimension(:, :),
allocatable :: runoff
616 real(dp),
dimension(:),
allocatable :: runoff_agg
619 real(dp),
dimension(:),
allocatable :: runoff_obs
622 logical,
dimension(:),
allocatable :: runoff_obs_mask
626 real(dp),
dimension(:),
allocatable :: errors
628 real(dp),
dimension(:),
allocatable :: obs, calc, out
632 real(dp) :: stddev_tmp
635 call eval(parameterset, runoff = runoff)
638 do gg = 1,
size(runoff, dim = 2)
640 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
642 call append(obs, runoff_obs)
643 call append(calc, runoff_agg)
648 nmeas =
size(obs, dim = 1)
650 allocate(out(nmeas), errors(nmeas))
651 errors(:) = abs(calc(:) - obs(:))
656 out = linfit(calc, errors, a = a, b = b, model2 = .false.)
657 errors(:) = errors(:) - (a + calc(:) * b)
660 c = correlation(errors(2 : nmeas), errors(1 : nmeas - 1))
661 errors(1 : nmeas - 1) = errors(2 : nmeas) - c * errors(1 : nmeas - 1)
662 errors(nmeas) = 0.0_dp
671 stddev_tmp = sqrt(sum((errors(:) - mean(errors)) * (errors(:) - mean(errors))) / real(nmeas - 1, dp))
672 if (
present(stddev_new))
then
673 stddev_new = stddev_tmp
675 if (
present(likeli_new))
then
676 likeli_new = sum(errors(:) * errors(:) / stddev_tmp**2)
677 likeli_new = -0.5_dp * likeli_new
680 deallocate(runoff, runoff_agg, runoff_obs_mask, runoff_obs)
681 deallocate(obs, calc, out, errors)
728 use mo_append,
only : append
730 use mo_constants,
only : pi_dp
731 use mo_moment,
only : correlation
732 use mo_utils,
only : eq
736 real(dp),
dimension(:),
intent(in) :: parameterset
738 procedure(eval_interface),
INTENT(IN),
pointer :: eval
740 logical,
optional,
intent(in) :: regularize
746 real(dp),
dimension(:, :),
allocatable :: runoff
755 real(dp),
dimension(:),
allocatable :: runoff_agg
758 real(dp),
dimension(:),
allocatable :: runoff_obs
761 logical,
dimension(:),
allocatable :: runoff_obs_mask
765 real(dp),
dimension(:),
allocatable :: errors, sigma, eta, y
767 real(dp),
dimension(:),
allocatable :: obs, calc, out
769 real(dp) :: a, b, c, vary, vary1, ln2pi, tmp
773 logical :: iregularize
776 iregularize = .false.
777 if (
present(regularize)) iregularize = regularize
779 npara =
size(parameterset)
780 call eval(parameterset(1 : npara - 2), runoff = runoff)
783 do gg = 1,
size(runoff, dim = 2)
785 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
787 call append(obs, runoff_obs)
788 call append(calc, runoff_agg)
794 nmeas =
size(obs, dim = 1)
796 allocate(out(nmeas), errors(nmeas), sigma(nmeas), eta(nmeas), y(nmeas))
798 errors(:) = calc(:) - obs(:)
801 a = parameterset(npara - 1)
802 b = parameterset(npara)
803 sigma(:) = a + b * calc(:)
805 eta(:) = errors(:) / sigma(:)
808 c = correlation(eta(2 : nmeas), eta(1 : nmeas - 1))
810 y(2 : nmeas) = eta(2 : nmeas) - c * eta(1 : nmeas - 1)
813 ln2pi = log(sqrt(2.0_dp * pi_dp))
814 vary = 1.0_dp - c * c
815 vary1 = 1.0_dp / vary
817 - real(nmeas - 1, dp) * log(sqrt(2.0_dp * pi_dp * vary)) &
818 - sum(0.5_dp * y(2 : nmeas) * y(2 : nmeas) * vary1) - sum(log(sigma(2 : nmeas)))
820 if (iregularize)
then
823 parameterset(1 : npara - 2), &
830 '-loglikelihood_evin2013_2, + penalty, chi^2: ', &
833 num2str(-tmp / real(nmeas, dp)))
837 '-loglikelihood_evin2013_2, chi^2: ', &
842 deallocate(runoff, runoff_agg, runoff_obs_mask, runoff_obs)
843 deallocate(obs, calc, out, errors, sigma, eta, y)
870 use mo_constants,
only : pi_dp
874 real(dp),
dimension(:),
intent(in) :: paraset
876 real(dp),
dimension(size(paraset)),
intent(in) :: prior
879 real(dp),
dimension(size(paraset), 2),
intent(in) :: bounds
881 logical,
dimension(size(paraset)),
intent(in) :: mask
889 real(dp),
parameter :: onetwelveth = 1._dp / 12._dp
891 real(dp),
dimension(size(paraset)) :: sigma
894 npara =
size(paraset, 1)
896 sigma = sqrt(onetwelveth * (bounds(:, 2) - bounds(:, 1))**2)
900 if (mask(ipara))
then
904 0.5_dp * ((paraset(ipara) - prior(ipara)) / sigma(ipara))**2
954 use mo_append,
only : append
955 use mo_linfit,
only : linfit
956 use mo_moment,
only : stddev
960 real(dp),
dimension(:),
intent(in) :: parameterset
962 procedure(eval_interface),
INTENT(IN),
pointer :: eval
965 real(dp),
intent(in) :: stddev_old
968 real(dp),
intent(out),
optional :: stddev_new
971 real(dp),
intent(out),
optional :: likeli_new
977 real(dp),
dimension(:, :),
allocatable :: runoff
983 real(dp),
dimension(:),
allocatable :: runoff_agg
986 real(dp),
dimension(:),
allocatable :: runoff_obs
989 logical,
dimension(:),
allocatable :: runoff_obs_mask
993 real(dp),
dimension(:),
allocatable :: errors
995 real(dp),
dimension(:),
allocatable :: obs, calc, out
999 real(dp) :: stddev_tmp
1002 call eval(parameterset, runoff = runoff)
1005 do gg = 1,
size(runoff, dim = 2)
1007 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1009 call append(obs, runoff_obs)
1010 call append(calc, runoff_agg)
1015 nmeas =
size(obs, dim = 1)
1018 allocate(out(nmeas), errors(nmeas))
1019 errors(:) = abs(calc(:) - obs(:))
1022 out = linfit(calc, errors, a = a, b = b, model2 = .false.)
1023 errors(:) = errors(:) - (a + calc(:) * b)
1033 if (
present(stddev_new) .or.
present(likeli_new))
then
1034 stddev_tmp = stddev(errors(:))
1036 if (
present(stddev_new))
then
1037 stddev_new = stddev_tmp
1039 if (
present(likeli_new))
then
1040 likeli_new = sum(errors(:) * errors(:) / stddev_tmp**2)
1041 likeli_new = -0.5_dp * likeli_new
1044 deallocate(runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1045 deallocate(obs, calc, out, errors)
1087 use mo_errormeasures,
only : lnnse
1091 real(dp),
dimension(:),
intent(in) :: parameterset
1093 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1099 real(dp),
allocatable,
dimension(:, :) :: runoff
1104 integer(i4) :: ngaugestotal
1107 real(dp),
dimension(:),
allocatable :: runoff_agg
1110 real(dp),
dimension(:),
allocatable :: runoff_obs
1113 logical,
dimension(:),
allocatable :: runoff_obs_mask
1116 call eval(parameterset, runoff = runoff)
1117 ngaugestotal =
size(runoff, dim = 2)
1120 do gg = 1, ngaugestotal
1122 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1125 lnnse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1135 deallocate(runoff_agg, runoff_obs, runoff_obs_mask)
1176 use mo_errormeasures,
only : sse
1180 real(dp),
dimension(:),
intent(in) :: parameterset
1182 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1188 real(dp),
allocatable,
dimension(:, :) :: runoff
1193 integer(i4) :: ngaugestotal
1196 real(dp),
dimension(:),
allocatable :: runoff_agg
1199 real(dp),
dimension(:),
allocatable :: runoff_obs
1202 logical,
dimension(:),
allocatable :: runoff_obs_mask
1205 call eval(parameterset, runoff = runoff)
1206 ngaugestotal =
size(runoff, dim = 2)
1209 do gg = 1, ngaugestotal
1211 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1214 sse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1224 deallocate(runoff_agg, runoff_obs, runoff_obs_mask)
1266 use mo_errormeasures,
only : nse
1270 real(dp),
dimension(:),
intent(in) :: parameterset
1272 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1278 real(dp),
allocatable,
dimension(:, :) :: runoff
1283 integer(i4) :: ngaugestotal
1286 real(dp),
dimension(:),
allocatable :: runoff_agg
1289 real(dp),
dimension(:),
allocatable :: runoff_obs
1292 logical,
dimension(:),
allocatable :: runoff_obs_mask
1295 call eval(parameterset, runoff = runoff)
1296 ngaugestotal =
size(runoff, dim = 2)
1299 do gg = 1, ngaugestotal
1301 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1304 nse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1310 call message(
'objective_nse (i.e., 1 - NSE) = ', num2str(
objective_nse))
1314 deallocate(runoff_agg, runoff_obs, runoff_obs_mask)
1359 use mo_errormeasures,
only : lnnse, nse
1363 real(dp),
dimension(:),
intent(in) :: parameterset
1365 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1371 real(dp),
allocatable,
dimension(:, :) :: runoff
1376 integer(i4) :: ngaugestotal
1379 real(dp),
dimension(:),
allocatable :: runoff_obs
1382 real(dp),
dimension(:),
allocatable :: runoff_agg
1385 logical,
dimension(:),
allocatable :: runoff_obs_mask
1388 call eval(parameterset, runoff = runoff)
1389 ngaugestotal =
size(runoff, dim = 2)
1392 do gg = 1, ngaugestotal
1394 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1398 0.5_dp * nse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1401 0.5_dp * lnnse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1411 deallocate(runoff_agg, runoff_obs)
1412 deallocate(runoff_obs_mask)
1456 use mo_errormeasures,
only : lnnse, nse
1460 real(dp),
dimension(:),
intent(in) :: parameterset
1462 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1468 real(dp),
allocatable,
dimension(:, :) :: runoff
1473 integer(i4) :: ngaugestotal
1476 real(dp),
dimension(:),
allocatable :: runoff_obs
1479 real(dp),
dimension(:),
allocatable :: runoff_agg
1482 logical,
dimension(:),
allocatable :: runoff_obs_mask
1486 call eval(parameterset, runoff = runoff)
1487 ngaugestotal =
size(runoff, dim = 2)
1490 do gg = 1, ngaugestotal
1492 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1496 nse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1499 lnnse(runoff_obs, runoff_agg, mask = runoff_obs_mask)
1507 deallocate(runoff_agg, runoff_obs)
1508 deallocate(runoff_obs_mask)
1561 use mo_errormeasures,
only : lnnse
1562 use mo_percentile,
only : percentile
1566 real(dp),
dimension(:),
intent(in) :: parameterset
1568 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1573 real(dp),
dimension(:, :),
allocatable :: runoff
1578 integer(i4) :: ngaugestotal
1581 real(dp),
dimension(:),
allocatable :: runoff_obs
1584 real(dp),
dimension(:),
allocatable :: runoff_agg
1587 logical,
dimension(:),
allocatable :: runoff_obs_mask
1596 integer(i4) :: nrunoff
1602 logical,
dimension(:),
allocatable :: lowflow_mask
1605 logical,
dimension(:),
allocatable :: highflow_mask
1609 call eval(parameterset, runoff = runoff)
1610 ngaugestotal =
size(runoff, dim = 2)
1613 do gg = 1, ngaugestotal
1616 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1617 nrunoff =
size(runoff_obs, dim = 1)
1621 if (
allocated(highflow_mask))
deallocate(highflow_mask)
1622 allocate(highflow_mask(nrunoff))
1623 highflow_mask = .false.
1624 q_high = percentile(runoff_obs, 95._dp, mask = runoff_obs_mask)
1625 forall(tt = 1 : nrunoff) highflow_mask(tt) = (runoff_obs(tt) > q_high .and. runoff_obs_mask(tt))
1629 if (
allocated(lowflow_mask))
deallocate(lowflow_mask)
1630 allocate(lowflow_mask(nrunoff))
1631 lowflow_mask = .false.
1632 q_low = minval(runoff_obs, mask = runoff_obs_mask) &
1633 + 0.05_dp * (maxval(runoff_obs, mask = runoff_obs_mask) - minval(runoff_obs, mask = runoff_obs_mask))
1634 forall(tt = 1 : nrunoff) lowflow_mask(tt) = (runoff_obs(tt) < q_low .and. runoff_obs_mask(tt))
1639 lnnse(runoff_obs, runoff_agg, mask = highflow_mask)
1643 lnnse(runoff_obs, runoff_agg, mask = lowflow_mask)
1652 deallocate(runoff_agg, runoff_obs)
1653 deallocate(runoff_obs_mask)
1705 use mo_errormeasures,
only : lnnse
1709 real(dp),
dimension(:),
intent(in) :: parameterset
1711 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1716 real(dp),
dimension(:, :),
allocatable :: runoff
1721 integer(i4) :: ngaugestotal
1724 real(dp),
dimension(:),
allocatable :: runoff_obs
1727 real(dp),
dimension(:),
allocatable :: runoff_agg
1730 logical,
dimension(:),
allocatable :: runoff_obs_mask
1736 integer(i4) :: nrunoff
1742 logical,
dimension(:),
allocatable :: lowflow_mask
1745 logical,
dimension(:),
allocatable :: highflow_mask
1749 call eval(parameterset, runoff = runoff)
1750 ngaugestotal =
size(runoff, dim = 2)
1753 do gg = 1, ngaugestotal
1756 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1757 nrunoff =
size(runoff_obs, dim = 1)
1761 if (
allocated(lowflow_mask))
deallocate(lowflow_mask)
1762 allocate(lowflow_mask(nrunoff))
1763 lowflow_mask = .false.
1764 q_low = minval(runoff_obs, mask = runoff_obs_mask) &
1765 + 0.05_dp * (maxval(runoff_obs, mask = runoff_obs_mask) - minval(runoff_obs, mask = runoff_obs_mask))
1766 forall(tt = 1 : nrunoff) lowflow_mask(tt) = (runoff_obs(tt) < q_low .and. runoff_obs_mask(tt))
1770 if (
allocated(highflow_mask))
deallocate(highflow_mask)
1771 allocate(highflow_mask(nrunoff))
1772 highflow_mask = (.not. lowflow_mask) .and. runoff_obs_mask
1777 lnnse(runoff_obs, runoff_agg, mask = highflow_mask)
1781 lnnse(runoff_obs, runoff_agg, mask = lowflow_mask)
1790 deallocate(runoff_agg, runoff_obs)
1791 deallocate(runoff_obs_mask)
1838 use mo_errormeasures,
only : nse
1839 use mo_julian,
only : dec2date
1845 real(dp),
dimension(:),
intent(in) :: parameterset
1847 procedure(eval_interface),
INTENT(IN),
pointer :: eval
1852 real(dp),
dimension(:, :),
allocatable :: runoff
1861 integer(i4) :: idomain
1864 real(dp),
dimension(:),
allocatable :: runoff_obs
1867 real(dp),
dimension(:),
allocatable :: runoff_agg
1870 logical,
dimension(:),
allocatable :: runoff_obs_mask
1873 integer(i4) :: nrunoff
1879 integer(i4) :: month
1882 real(dp) :: current_time
1885 logical,
dimension(:),
allocatable :: djf_mask
1888 real(dp),
dimension(10) :: quantiles
1891 integer(i4) :: nquantiles
1894 real(dp),
dimension(size(quantiles)) :: fdc
1904 call eval(parameterset, runoff = runoff)
1906 nquantiles =
size(quantiles)
1907 forall(tt = 1 : nquantiles) quantiles(tt) = real(tt, dp) / real(nquantiles, dp)
1913 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
1914 nrunoff =
size(runoff_obs, dim = 1)
1917 if (
allocated(djf_mask))
deallocate(djf_mask)
1918 allocate(djf_mask(nrunoff))
1921 idomain =
gauge%domainId(gg)
1924 call dec2date(current_time, mm = month)
1925 if ((month == 1 .or. month == 2 .or. month == 12) .and. runoff_obs_mask(tt)) djf_mask(tt) = .true.
1929 fdc =
flowdurationcurve(runoff_obs, quantiles, mask = runoff_obs_mask, low_segment_volume = lsv_obs)
1930 fdc =
flowdurationcurve(runoff_agg, quantiles, mask = runoff_obs_mask, low_segment_volume = lsv_mod)
1935 abs(lsv_obs - lsv_mod)
1939 nse(runoff_obs, runoff_agg, mask = djf_mask)
1947 call message(
'multi_objective_ae_fdc_lsv_nse_djf = [', &
1952 deallocate(runoff_agg, runoff_obs)
1953 deallocate(runoff_obs_mask)
1999 use mo_errormeasures,
only : lnnse, nse
2003 real(dp),
dimension(:),
intent(in) :: parameterset
2005 procedure(eval_interface),
INTENT(IN),
pointer :: eval
2011 real(dp),
allocatable,
dimension(:, :) :: runoff
2016 integer(i4) :: ngaugestotal
2019 real(dp),
dimension(:),
allocatable :: runoff_agg
2022 real(dp),
dimension(:),
allocatable :: runoff_obs
2025 logical,
dimension(:),
allocatable :: runoff_obs_mask
2027 real(dp),
parameter :: onesixth = 1.0_dp / 6.0_dp
2030 call eval(parameterset, runoff = runoff)
2031 ngaugestotal =
size(runoff, dim = 2)
2034 do gg = 1, ngaugestotal
2036 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
2039 ((1.0_dp - nse(runoff_obs, runoff_agg, mask = runoff_obs_mask))**6 + &
2040 (1.0_dp - lnnse(runoff_obs, runoff_agg, mask = runoff_obs_mask))**6)**onesixth
2050 deallocate(runoff_agg, runoff_obs, runoff_obs_mask)
2099 use mo_errormeasures,
only : kge
2103 real(dp),
dimension(:),
intent(in) :: parameterset
2105 procedure(eval_interface),
INTENT(IN),
pointer :: eval
2111 real(dp),
allocatable,
dimension(:, :) :: runoff
2116 integer(i4) :: ngaugestotal
2119 real(dp),
dimension(:),
allocatable :: runoff_agg
2122 real(dp),
dimension(:),
allocatable :: runoff_obs
2125 logical,
dimension(:),
allocatable :: runoff_obs_mask
2129 call eval(parameterset, runoff = runoff)
2130 ngaugestotal =
size(runoff, dim = 2)
2133 do gg = 1, ngaugestotal
2135 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
2138 kge(runoff_obs, runoff_agg, mask = runoff_obs_mask)
2144 call message(
'objective_kge (i.e., 1 - KGE) = ', num2str(
objective_kge))
2148 deallocate(runoff_agg, runoff_obs, runoff_obs_mask)
2201 use mo_errormeasures,
only : kge
2205 real(dp),
dimension(:),
intent(in) :: parameterset
2207 procedure(eval_interface),
INTENT(IN),
pointer :: eval
2211 real(dp),
parameter :: onesixth = 1.0_dp / 6.0_dp
2215 real(dp),
allocatable,
dimension(:, :) :: runoff
2220 integer(i4) :: ngaugestotal
2223 real(dp),
dimension(:),
allocatable :: runoff_agg
2226 real(dp),
dimension(:),
allocatable :: runoff_obs
2229 logical,
dimension(:),
allocatable :: runoff_obs_mask
2233 call eval(parameterset, runoff = runoff)
2234 ngaugestotal =
size(runoff, dim = 2)
2237 do gg = 1, ngaugestotal
2239 call extract_runoff(gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
2242 ((1.0_dp - kge(runoff_obs, runoff_agg, mask = runoff_obs_mask)) / real(ngaugestotal, dp))**6
2249 deallocate(runoff_agg, runoff_obs, runoff_obs_mask)
2289 use mo_errormeasures,
only : wnse
2293 real(dp),
dimension(:),
intent(in) :: parameterset
2295 procedure(eval_interface),
INTENT(IN),
pointer :: eval
2301 real(dp),
allocatable,
dimension(:,:) :: runoff
2306 integer(i4) :: ngaugestotal
2309 real(dp),
dimension(:),
allocatable :: runoff_agg
2312 real(dp),
dimension(:),
allocatable :: runoff_obs
2315 logical,
dimension(:),
allocatable :: runoff_obs_mask
2318 call eval(parameterset, runoff=runoff)
2319 ngaugestotal =
size(runoff, dim=2)
2322 do gg=1, ngaugestotal
2324 call extract_runoff( gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask )
2327 wnse( runoff_obs, runoff_agg, mask=runoff_obs_mask)
2337 deallocate( runoff_agg, runoff_obs, runoff_obs_mask )
2382 use mo_errormeasures,
only: sse
2383 use mo_boxcox,
only: boxcox
2387 real(dp),
dimension(:),
intent(in) :: parameterset
2389 procedure(eval_interface),
INTENT(IN),
pointer :: eval
2395 real(dp),
allocatable,
dimension(:,:) :: runoff
2400 integer(i4) :: ngaugestotal
2403 real(dp),
dimension(:),
allocatable :: runoff_agg
2406 real(dp),
dimension(:),
allocatable :: runoff_obs
2409 logical,
dimension(:),
allocatable :: runoff_obs_mask
2421 call eval(parameterset, runoff=runoff)
2422 ngaugestotal =
size(runoff, dim=2)
2425 do gg=1, ngaugestotal
2427 call extract_runoff( gg, runoff, runoff_agg, runoff_obs, runoff_obs_mask )
2430 sse( boxcox(runoff_obs, lambda, mask=runoff_obs_mask), boxcox(runoff_agg, lambda), mask=runoff_obs_mask)
2440 deallocate( runoff_agg, runoff_obs, runoff_obs_mask )
2482 use mo_utils,
only : ge
2487 integer(i4),
intent(in) :: gaugeid
2490 real(dp),
dimension(:, :),
intent(in) :: runoff
2493 real(dp),
dimension(:),
allocatable,
intent(out) :: runoff_agg
2496 real(dp),
dimension(:),
allocatable,
intent(out) :: runoff_obs
2499 logical,
dimension(:),
allocatable,
intent(out) :: runoff_obs_mask
2502 integer(i4) :: idomain
2508 integer(i4) :: length
2511 integer(i4) :: factor
2514 integer(i4) :: tpd_sim
2517 integer(i4) :: tpd_obs
2519 real(dp),
dimension(:),
allocatable :: dummy
2527 if (modulo(tpd_sim, tpd_obs) .eq. 0)
then
2528 factor = tpd_sim / tpd_obs
2530 call error_message(
' Error: Number of modelled datapoints is no multiple of measured datapoints per day')
2534 idomain =
gauge%domainId(gaugeid)
2537 length = (
evalper(idomain)%julEnd -
evalper(idomain)%julStart + 1) * tpd_obs
2540 if (
allocated(runoff_obs))
deallocate(runoff_obs)
2541 allocate(runoff_obs(length))
2542 runoff_obs =
gauge%Q(1 : length, gaugeid)
2545 if (
allocated(runoff_obs_mask))
deallocate(runoff_obs_mask)
2546 allocate(runoff_obs_mask(length))
2547 runoff_obs_mask = .false.
2548 forall(tt = 1 : length) runoff_obs_mask(tt) = ge(runoff_obs(tt), 0.0_dp)
2551 if (
allocated(runoff_agg))
deallocate(runoff_agg)
2552 allocate(runoff_agg(length))
2554 length = (
evalper(idomain)%julEnd -
evalper(idomain)%julStart + 1) * tpd_sim
2555 allocate(dummy(length))
2558 length = (
evalper(idomain)%julEnd -
evalper(idomain)%julStart + 1) * tpd_obs
2559 forall(tt = 1 : length) runoff_agg(tt) = sum(dummy((tt - 1) * factor + 1 : tt * factor)) / &
Provides structures needed by mHM, mRM and/or mpr.
integer(i4), public opti_method
integer(i4), public ntstepday
integer(i4), dimension(:), allocatable, public warmingdays
integer(i4), public opti_function
type(period), dimension(:), allocatable, public evalper
Provides structures needed by mHM, mRM and/or mpr.
real(dp), dimension(:, :), allocatable, target, public global_parameters
type(domain_meta), public domainmeta
Global variables for mRM only.
type(gaugingstation), public gauge
integer(i4), public nmeasperday
integer(i4), public ngaugestotal
Objective Functions for Optimization of mHM/mRM against runoff.
real(dp) function, dimension(2) multi_objective_lnnse_highflow_lnnse_lowflow(parameterset, eval)
Multi-objective function with NSE and lnNSE.
real(dp) function objective_weighted_nse(parameterset, eval)
Objective function of weighted NSE.
real(dp) function loglikelihood_evin2013_2(parameterset, eval, regularize)
Logarithmised likelihood with linear error model and lag(1)-autocorrelation of the relative errors.
real(dp) function, public single_objective_runoff(parameterset, eval, arg1, arg2, arg3)
Wrapper for objective functions optimizing agains runoff.
real(dp) function objective_multiple_gauges_kge_power6(parameterset, eval)
combined objective function based on KGE raised to the power 6
real(dp) function, dimension(2) multi_objective_nse_lnnse(parameterset, eval)
Multi-objective function with NSE and lnNSE.
real(dp) function objective_power6_nse_lnnse(parameterset, eval)
Objective function of combined NSE and lnNSE with power of 5 i.e.
subroutine, public multi_objective_runoff(parameterset, eval, multi_objectives)
Wrapper for multi-objective functions where at least one is regarding runoff.
real(dp) function objective_sse(parameterset, eval)
Objective function of SSE.
real(dp) function objective_nse(parameterset, eval)
Objective function of NSE.
real(dp) function, dimension(2) multi_objective_ae_fdc_lsv_nse_djf(parameterset, eval)
Multi-objective function with absolute error of Flow Duration Curves low-segment volume and nse of DJ...
subroutine, public single_objective_runoff_subprocess(eval, arg1, arg2, arg3)
Wrapper for objective functions optimizing agains runoff.
real(dp) function, dimension(2) multi_objective_lnnse_highflow_lnnse_lowflow_2(parameterset, eval)
Multi-objective function with NSE and lnNSE.
real(dp) function parameter_regularization(paraset, prior, bounds, mask)
TODO: add description.
real(dp) function objective_sse_boxcox(parameterset, eval)
Objective function of sum of squared errors of transformed streamflow.
real(dp) function loglikelihood_trend_no_autocorr(parameterset, eval, stddev_old, stddev_new, likeli_new)
Logarithmic likelihood function with linear trend removed.
real(dp) function objective_equal_nse_lnnse(parameterset, eval)
Objective function equally weighting NSE and lnNSE.
real(dp) function objective_lnnse(parameterset, eval)
Objective function of logarithmic NSE.
subroutine, public extract_runoff(gaugeid, runoff, runoff_agg, runoff_obs, runoff_obs_mask)
extracts runoff data from global variables
real(dp) function loglikelihood_stddev(parameterset, eval, stddev, stddev_new, likeli_new)
Logarithmic likelihood function with removed linear trend and Lag(1)-autocorrelation.
real(dp) function objective_kge(parameterset, eval)
Objective function of KGE.
real(dp) function, public single_objective_runoff_master(parameterset, eval, arg1, arg2, arg3)
Wrapper for objective functions optimizing agains runoff.
Module with calculations for several hydrological signatures.
real(dp) function, dimension(size(quantiles, 1)), public flowdurationcurve(data, quantiles, mask, concavity_index, mid_segment_slope, mhigh_segment_volume, high_segment_volume, low_segment_volume)
Flow duration curves.