HYPE
All Classes Namespaces Files Functions Variables Pages
Functions/Subroutines
compout Module Reference

Functions/Subroutines

subroutine compute_load_accumulation_period_status (date, loadvar, nper, pstart, pend)
 
subroutine compute_period_timesteplength_and_end_status (ct, pcode, nper, pend, pfull, idt, ndt)
 
subroutine acc_one_data (sumtype, y, yhelp, acc, acch)
 
subroutine stop_acc_data (miss, acc, accok)
 
subroutine check_and_acc_one_data (simple, sumtype, y, yhelp, miss, acc, acchelp, accok)
 
subroutine check_and_outmean_one_data (sumtype, pcode, nper, miss, acc, acch, x)
 
subroutine, public compute_basinoutput (io, iad, dim, pwrite, pend, nper, idt, iens, x)
 
subroutine, public compute_mapoutput (ct, io, idt, ndt, intformat, nmapperiod)
 
subroutine, public compute_print_output_flags (ct, io, idt, ndt, nper, pwrite, pend, wuskip)
 
subroutine, public compute_timeoutput (io, ivar, dim, pwrite, pend, nper, idt, iens, x)
 
subroutine, public compute_regionoutput (io, ir, iad, dim, pwrite, pend, nper, idt, iens, x)
 
subroutine, public compute_outloads (d, pend, idt)
 
subroutine, public initiate_outvar (idt)
 
subroutine, public revise_outvar ()
 
subroutine, public calculate_class_average (varindex, ncl, classindex, avvalue)
 
subroutine, public calculate_class_weighted_average (varindex, varindex0, ncl, classindex, avvalue)
 
subroutine, public calculate_region_average (ireg, ivar, average)
 
subroutine, public calculate_region_obsfunc (ireg)
 
subroutine, public calculate_upstream_average (varindex, areatype, avvalue)
 
subroutine, public prepare_to_compute_crit (ct, idt, ndt)
 
subroutine, public calculate_criteria (crit0, basincrit, simcrit, crit1, thres1)
 
subroutine add_max_criterion_to_objective (i, value, objcrit, condcrit, condthres)
 
subroutine add_min_criterion_to_objective (i, value, objcrit, condcrit, condthres)
 
integer function, public find_variable_index_type (str, outindex, timeagg, areaagg)
 
integer function, public find_variable_index (str, iout, flow)
 
character(len=20) function, public get_variable_string (outputvariable)
 
character(len=30) function, public get_unit_string (io, ivar)
 
real function compute_yearfact (vartype, per)
 
real function compute_sr2limit (yearlim, per)
 
subroutine, public find_acrit_corresponding_to_crit (i, iout)
 
subroutine find_crit_corresponding_to_acrit (j, iout)
 
subroutine save_variables_for_later_critcalc (n, icrit, cs, rs, ts)
 
subroutine extend_ktvariables (n, m, i)
 
subroutine accumulate_periodvalues (m, n, r, c, rs, cs, ts)
 
subroutine reform_accumulated_periodvalues (n, acctype, rs, cs, ts)
 
subroutine reset_periodvalues (rs, cs, ts, n, m)
 
subroutine kendallstau (n, data1, data2, tau)
 
subroutine calculate_fit (n, c, r, m, lim, x)
 
subroutine calculate_mab (n, c, r, m, lim, usew, w, x)
 
subroutine calculate_ra (n, c, r, m, p, lim, x)
 
subroutine, public calculate_median (n, x, miss, median)
 
subroutine calculate_mean_criterion (dim, usew, crit, w, ave)
 
subroutine calculate_meanabs_criterion (dim, usew, crit, w, ave)
 
subroutine calculate_subbasin_mean_var (iac, limityear, dim, vartype, rec, sim)
 
subroutine calculate_nash_sutcliffe (iac, dim, r2)
 
subroutine calculate_regional_nash_sutcliffe (iac, rr2)
 
subroutine calculate_regional_number_of_observations (iac, num)
 
subroutine calculate_meanmedian_number_of_observations (dim, crit, miss, num)
 
subroutine calculate_spatial_nash_sutcliffe (iac, limityear, limitbasin, vartype, sr2)
 
subroutine calculate_spatial_root_mean_square_error (iac, limityear, limitbasin, vartype, srmse)
 
subroutine calculate_spatial_mean_absolute_bias (iac, limityear, limitbasin, vartype, smab)
 
subroutine calculate_all_subbasins_tau (iac, dim, tau)
 
subroutine calculate_all_subbasins_ra (iac, dim, acoeff, ra)
 
subroutine calculate_regional_ra (iac, acoeff, rra)
 
subroutine calculate_relative_error (iac, dim, re)
 
subroutine calculate_regional_relative_error (iac, rve)
 
subroutine calculate_mean_and_errors (iac, dim, rec, sim, rmae, rmse, nrmse, n)
 
subroutine calculate_regional_errors (iac, rmae)
 
subroutine calculate_variance_based_criteria (iac, dim, recstd, simstd, stderr, stdrelerr, corr, nsew)
 
subroutine calculate_kling_gupta (iac, dim, kge, sckge, kge1, kge2, kge3)
 
subroutine calculate_minmax_subass (iac, mmvalues)
 

Detailed Description

The module compout contains procedures relating to calculating output and criteria.

Procedures for for accumulation output data and for preparing output for file writing. Output are accumulated to the time period wanted for print out and for criteria calculations. Several different criteria is calculated.

Function/Subroutine Documentation

◆ acc_one_data()

subroutine compout::acc_one_data ( integer, intent(in)  sumtype,
real, intent(in)  y,
real, intent(in)  yhelp,
real, intent(inout)  acc,
real, intent(inout)  acch 
)

Accumulate one data point Depending on type of output variable accumulate data.

Parameters
[in]sumtypeType of output variable
[in]yData
[in]yhelpHelp data (water for weighting)
[in,out]accVariable for accumulated data
[in,out]acchVariable for accumulated help data
+ Here is the caller graph for this function:

◆ accumulate_periodvalues()

subroutine compout::accumulate_periodvalues ( real, intent(in)  m,
integer, intent(in)  n,
real, dimension(n), intent(in)  r,
real, dimension(n), intent(in)  c,
real, dimension(n), intent(inout)  rs,
real, dimension(n), intent(inout)  cs,
integer, dimension(n), intent(inout)  ts 
)

Accumulate values to mean period used by criterion.

Parameters
[in]mMask value, missing value
[in]nSize of variables, number of subbasins
[in]rRecorded value of variable to be used for criteria
[in]cComputed value of variable to be used for criteria
[in,out]rsAccumulation of recorded value
[in,out]csAccumulation of computed value
[in,out]tsAccumulation of number of values
+ Here is the caller graph for this function:

◆ add_max_criterion_to_objective()

subroutine compout::add_max_criterion_to_objective ( integer, intent(in)  i,
real, intent(in)  value,
real, intent(inout)  objcrit,
real, intent(inout)  condcrit,
real, intent(inout)  condthres 
)

Add criterion value to multi-criteria objective function or to conditional criterion for a criterion to be maximised, e.g. NSE.

+ Here is the caller graph for this function:

◆ add_min_criterion_to_objective()

subroutine compout::add_min_criterion_to_objective ( integer, intent(in)  i,
real, intent(in)  value,
real, intent(inout)  objcrit,
real, intent(inout)  condcrit,
real, intent(inout)  condthres 
)

Add criterion value to multi-criteria objective function or to conditional criterion for a criterion to be minimised, e.g. RMSE.

+ Here is the caller graph for this function:

◆ calculate_all_subbasins_ra()

subroutine compout::calculate_all_subbasins_ra ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, intent(in)  acoeff,
real, dimension(dim), intent(out)  ra 
)

Calculate Nash-Sutcliffe effciency with parameter a instead of 2 for all time series, "RA".

Parameters
[in]iacIndex of accumulation criteria
[in]dimDimension of array, number of subbasins
[in]acoeffCoefficient a for RA criterion
[out]raCalculated criteria, RA

Algorithm

For each subbasin: Calculate criteria RA

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_all_subbasins_tau()

subroutine compout::calculate_all_subbasins_tau ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, dimension(dim), intent(out)  tau 
)

Calculate Kendalls tau for all subbasins.

Parameters
[in]iacIndex of accumulated criteria
[in]dimDimension of array, number of subbasins
[out]tauCalculated criteria, Kendalls tau

Algorithm

For each subbasin: Calculate kendalls tau

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_class_average()

subroutine, public compout::calculate_class_average ( integer, intent(in)  varindex,
integer, intent(in)  ncl,
integer, dimension(ncl), intent(in)  classindex,
real, dimension(nsub), intent(out)  avvalue 
)

Calculate a simple average of selected class values of a variable for all subbasins.

Parameters
[in]varindexindex of variable's class values
[in]nclnumber of selected classes
[in]classindexindex of selected classes
[out]avvalueclass average values

Algoritm

Calculate average value of selected classes

+ Here is the caller graph for this function:

◆ calculate_class_weighted_average()

subroutine, public compout::calculate_class_weighted_average ( integer, intent(in)  varindex,
integer, intent(in)  varindex0,
integer, intent(in)  ncl,
integer, dimension(ncl), intent(in)  classindex,
real, dimension(nsub), intent(out)  avvalue 
)

Calculate a water weighted average of selected class values of a variable for all subbasins.

Parameters
[in]varindexindex of variable's class values
[in]varindex0index of variable's corresponding water class values
[in]nclnumber of selected classes
[in]classindexindex of selected classes
[out]avvalueclass average values

Algoritm

Calculate weighted average value of selected classes

+ Here is the caller graph for this function:

◆ calculate_criteria()

subroutine, public compout::calculate_criteria ( real, intent(out)  crit0,
real, dimension(nsubcrit,maxsubass,nacrit), intent(out), optional  basincrit,
real, dimension(maxperf,nacrit), intent(out), optional  simcrit,
real, intent(out), optional  crit1,
real, intent(out), optional  thres1 
)

Calculates objective function (chosen multi-criteria) for the last time step. Calculates optional other criteria.

Consequences Worldvar module variables ktcomp,ktrec and ktnum etc. may be allocated and changed (sort of?).

Parameters
[out]crit0Value of chosen objective function
[out]basincritPerformance criteria per subbasin and variable
[out]simcritPerformance criteria per variable
[out]crit1Conditional criteria
[out]thres1Threshold of conditional criteria

Algorithm
Initializations

For every criteria with unique variables:

If assessment print out: Calculate diagnostic criteria (R2, RE etc) for each subbasin

If subbasin assessment: Set optional subbasin assessment criteria dummy argument

If simulation assessment: Calculate and set simulation assessment criteria. These could be average and median of subbasin criteria or regional or spatial criteria.

If simulation assessment: Calculate and set simulation assessment criteria, spatial and combined ("regional")

Calculate the multi-criteria optimization criterion, i.e. the objective function

For every criterion included in the objective function:

  • If TAU: Calculate Kendalls tau for each subbasin, calculate mean TAU, add to objective function or conditional criteria
  • If RRA: Calculate regional RA, add to objective function or conditional criteria
  • If SRA: Calculate variable's average for each subbasin, calculate RA on these (spatial RA), add to objective function or conditional criteria
  • If SR2: Calculate spatial NSE if not already done, add to objective function or conditional criteria
  • If SNR: Calculate spatial RMSE if not already done, add to objective function or conditional criteria
  • If SMB: Calculate spatial Mean Absolute Bias if not already done, add to objective function or conditional criteria
  • If RR2: Calculate regional NSE if not already done, add to objective function or conditional criteria
  • If MR2: Calculate NSE for every subbasin and their average if not already done, add to objective function or conditional criteria
  • If MD2: Calculate NSE for every subbasin and their median if not already done, add to objective function or conditional criteria
  • If MRA: Calculate RA for every subbasin, calculate their average, add to objective function or conditional criteria
  • If MDA: Calculate RA for every subbasin, calculate their median, add to objective function or conditional criteria
  • If RRE: Calculate regional relative error if not already done, add to objective function or conditional criteria
  • If MRE: Calculate relative error of mean for every subbasin and their average if not already done, add to objective function or conditional criteria
  • If MAR: Calculate relative for every subbasin and the average of their absolute value if not already done, add to objective function or conditional criteria
  • If MCC: Calculate correlation coefficient for every subbasin and their average if not already done, add to objective function or conditional criteria
  • If MKG: Calculate Kling-Gupta Efficiency for every subbasin and their median if not already done, add to objective function or conditional criteria
  • If AKG: Calculate Kling-Gupta Efficiency for every subbasin and their mean if not already done, add to objective function or conditional criteria
  • If ASK: Calculate rescaled Kling-Gupta Efficiency for every subbasin and their mean if not already done, add to objective function or conditional criteria
  • If MRS: Calculate error in standard deviations for every subbasin and their average if not already done, add to objective function or conditional criteria
  • If MNR: Calculate normalised RMSE by max for every subbasin and their median if not already done, add to objective function or conditional criteria
  • If NSW: Calculate NSE adjusted for bias for every subbasin and their average if not already done, add to objective function or conditional criteria

Set output variables

Deallocate help variables for calculating Kendalls Tau or RA

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_fit()

subroutine compout::calculate_fit ( integer, intent(in)  n,
real, dimension(n), intent(in)  c,
real, dimension(n), intent(in)  r,
real, intent(in)  m,
integer, intent(in)  lim,
real, dimension(4), intent(out)  x 
)
private

Calculate three fitness criteria between two arrays of length n.

Parameters
[in]nNumber of elements
[in]cArray with computed values
[in]rArray with recorded values
[in]mMissing value
[in]limMinimum number of elements
[out]xFitness criteria; 1=R2 (Nash-Sutcliff), 2=RMSE, 3=bias, and 4=number of data used

Algorithm
Initialize

Calculate sum of values and errors (for not missing values)

If enough values not missing; calculate fitness criteria

+ Here is the caller graph for this function:

◆ calculate_kling_gupta()

subroutine compout::calculate_kling_gupta ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, dimension(dim), intent(out)  kge,
real, dimension(dim), intent(out)  sckge,
real, dimension(dim), intent(out)  kge1,
real, dimension(dim), intent(out)  kge2,
real, dimension(dim), intent(out)  kge3 
)

Calculate Kling-Gupta effciency for all time series, "KGE".

Reference Gupta et al. 2009 KGE = 1 - sqrt{ (cc-1)^2 + (a-1)^2 + (b-1)^2 } cc = linear correlation coefficient a = std(SIM)/std(OBS) b = mean(SIM)/mean(OBS)

Parameters
[in]iacIndex of accumulation criteria
[in]dimDimension of array, number of subbasins
[out]kgeKling-Gupta efficiency
[out]sckgeKling-Gupta efficiency rescaled to (-1,1)
[out]kge1Kling-Gupta efficiency part 1, cc
[out]kge2Kling-Gupta efficiency part 2, std-quotient
[out]kge3Kling-Gupta efficiency part 3, mean-quotient

Algorithm

For every subbasin with enough data: calculate criteria

+ Here is the caller graph for this function:

◆ calculate_mab()

subroutine compout::calculate_mab ( integer, intent(in)  n,
real, dimension(n), intent(in)  c,
real, dimension(n), intent(in)  r,
real, intent(in)  m,
integer, intent(in)  lim,
logical, intent(in)  usew,
real, dimension(n), intent(in)  w,
real, intent(out)  x 
)
private

Calculates fitness criterion, mean absolute scaled bias.

Parameters
[in]nNumber of elements
[in]cArray with computed values
[in]rArray with recorded values
[in]mMissing value
[in]limMinimum number of elements
[in]usewStatus of using weights on subbasin
[in]wWeight for averaging criteria
[out]xFitness criteria; weighted average of absolute scaled bias

Algorithm
Initialize

Calculate sum of values (for not missing values)

If enough values not missing; calculate fitness criteria

+ Here is the caller graph for this function:

◆ calculate_mean_and_errors()

subroutine compout::calculate_mean_and_errors ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, dimension(dim), intent(out)  rec,
real, dimension(dim), intent(out)  sim,
real, dimension(dim), intent(out)  rmae,
real, dimension(dim), intent(out)  rmse,
real, dimension(dim), intent(out)  nrmse,
integer, dimension(dim), intent(out)  n 
)

Calculate mean absolute error and root mean square error for all time series, "MAE and RMSE". Calculate mean values for observations and simulation.

Parameters
[in]iacindex of accumulation criteria
[in]dimdimension of criteria
[out]recmean recorded value
[out]simmean simulated value
[out]rmaemean absolute error
[out]rmseroot mean square error
[out]nrmsenormalized root mean square error, rmse/maxRec (rmse/(maxRec-MinRec)?)
[out]nnumber of observations used
+ Here is the caller graph for this function:

◆ calculate_mean_criterion()

subroutine compout::calculate_mean_criterion ( integer, intent(in)  dim,
logical, intent(in)  usew,
real, dimension(dim), intent(in)  crit,
real, dimension(:), intent(in), allocatable  w,
real, intent(out)  ave 
)
private

Calculate (subbasin) mean value of criterion; arithmetic mean or weighted mean.

Parameters
[in]dimDimension of array, subbasins
[in]usewStatus of using weighted mean
[in]critArray with criteria
[in]wWeight for averaging criteria
[out]aveAverage of criteria
+ Here is the caller graph for this function:

◆ calculate_meanabs_criterion()

subroutine compout::calculate_meanabs_criterion ( integer, intent(in)  dim,
logical, intent(in)  usew,
real, dimension(dim), intent(in)  crit,
real, dimension(:), intent(in), allocatable  w,
real, intent(out)  ave 
)

Calculate subbasin mean absolute value of criterion.

Parameters
[in]dimDimension of array, subbasins
[in]usewStatus of using weighted mean
[in]critArray with criteria
[out]aveAverage of criteria
[in]wWeight for averaging criteria
+ Here is the caller graph for this function:

◆ calculate_meanmedian_number_of_observations()

subroutine compout::calculate_meanmedian_number_of_observations ( integer, intent(in)  dim,
real, dimension(dim), intent(in)  crit,
real, intent(in)  miss,
real, intent(out)  num 
)

Calculate number of data point used for calculation of "regional" criteria.

Parameters
[in]dimnumber of areas
[in]critcriteria value for areas
[in]missmissing value
[out]numNumber of areas with criteria
+ Here is the caller graph for this function:

◆ calculate_median()

subroutine, public compout::calculate_median ( integer, intent(in)  n,
real, dimension(n), intent(in)  x,
real, intent(in)  miss,
real, intent(out)  median 
)

Calculate median of non-missing values in array.

Parameters
[in]nNumber of elements
[in]xArray with values
[in]missMissing value
[out]medianMedian value

Algorithm
Calculate the median simle for small arrays, the return

Calculate the place of the median element

Calculate the median

+ Here is the caller graph for this function:

◆ calculate_minmax_subass()

subroutine compout::calculate_minmax_subass ( integer, intent(in)  iac,
real, dimension(:,:), intent(out)  mmvalues 
)

Calculate min and max value of simulated and observed time series.

Parameters
[in]iacIndex of accumulation criteria
[out]mmvaluesMin and max values (dim,4)

Algorithm

For every subbasin with enough data: calculate criteria

+ Here is the caller graph for this function:

◆ calculate_nash_sutcliffe()

subroutine compout::calculate_nash_sutcliffe ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, dimension(dim), intent(out)  r2 
)

Calculate Nash-Sutcliffe effciency ("R2") for all subbasins.

Parameters
[in]iacIndex of accumulation criteria
[in]dimDimension of array, number of subbasins
[out]r2Nash-Sutcliffe efficiency
+ Here is the caller graph for this function:

◆ calculate_ra()

subroutine compout::calculate_ra ( integer, intent(in)  n,
real, dimension(n), intent(in)  c,
real, dimension(n), intent(in)  r,
real, intent(in)  m,
real, intent(in)  p,
integer, intent(in)  lim,
real, intent(out)  x 
)
private

Calculates fitness criterion, "RA", for two columns of an array of length n. Criterion RA is similar to NSE but with exponent p instead of 2.

Parameters
[in]nNumber of elements
[in]cArray with computed values
[in]rArray with recorded values
[in]mMissing value
[in]pParameter value of criterion
[in]limMinimum number of elements
[out]xFitness criterion 1=RA

Algorithm
Initialize

Calculate sum of values and errors (for not missing values)

If enough values not missing; calculate fitness criteria

+ Here is the caller graph for this function:

◆ calculate_region_average()

subroutine, public compout::calculate_region_average ( integer, intent(in)  ireg,
integer, intent(in)  ivar,
real, intent(out)  average 
)

Calculate the region average of a subbasin variable for one region, unless another function than the average is asked for in which case missing value is returned.

Parameters
[in]iregcurrent region
[in]ivarindex of output variable (in outvar)
[out]averageregion average value

Algoritm
Calculate region average of the variable for the region, by adding the subbasin values multiplied by their weight in the average.

+ Here is the caller graph for this function:

◆ calculate_region_obsfunc()

subroutine, public compout::calculate_region_obsfunc ( integer, intent(in)  ireg)

Calculate the region observation functions for an outregion.

Parameters
[in]iregcurrent region

Algoritm
Select observation function

Obsfunc 1: Calculate reservoir inflow as local runoff + precipitation on reservoir minus evaporation of reservoir

  • 1. Find outvar columns with regionalized clrf, clrp, clre, and qcin
  • 2. Apply the regional observation function if rgqcin is to be output

Obsfunc 2: Not implemented yet.

  1. find out which snow variables are regionalized (which will be interpolated to the in-situ point)
+ Here is the caller graph for this function:

◆ calculate_regional_errors()

subroutine compout::calculate_regional_errors ( integer, intent(in)  iac,
real, intent(out)  rmae 
)

Calculate mean absolute error and mean square error for all time series as one time series, "regional MAE and MSE".

Parameters
[in]iacIndex of accumulation criteria
[out]rmaeRegional mean absolute error

Algorithm
Accumulate data over all subbasins

Calculate regional MAE of all observations

+ Here is the caller graph for this function:

◆ calculate_regional_nash_sutcliffe()

subroutine compout::calculate_regional_nash_sutcliffe ( integer, intent(in)  iac,
real, intent(out)  rr2 
)

Calculate Nash-Sutcliffe effciency for all time series as one time series, "regional R2".

Parameters
[in]iacIndex of accumulation criteria
[out]rr2Calculated criterion, regional R2
+ Here is the caller graph for this function:

◆ calculate_regional_number_of_observations()

subroutine compout::calculate_regional_number_of_observations ( integer, intent(in)  iac,
real, intent(out)  num 
)

Calculate number of data point used for calculation of "regional" criteria.

Parameters
[in]iacIndex of accumulation criteria
[out]numNumber of data points
+ Here is the caller graph for this function:

◆ calculate_regional_ra()

subroutine compout::calculate_regional_ra ( integer, intent(in)  iac,
real, intent(in)  acoeff,
real, intent(out)  rra 
)

Calculate Nash-Sutcliffe effciency with coeffcient a for all time series as one time series, "regional RA".

Parameters
[in]iacIndex of accumulation criteria
[in]acoeffCoefficient a for RA criterion
[out]rraCalculated criteria, regional RA

Algorithm
Prepare arrays to hold all data in the time series

Set the arrays with all data in the time series

Calculate RA for these large data arrays

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_regional_relative_error()

subroutine compout::calculate_regional_relative_error ( integer, intent(in)  iac,
real, intent(out)  rve 
)

Calculate relative volume error for all time series as one time series, "regional RE".

Parameters
[in]iacIndex of accumulation criteria
[out]rveRegional relative error

Algorithm
Accumulate data over all subbasins

Calculate regional relative volume error

+ Here is the caller graph for this function:

◆ calculate_relative_error()

subroutine compout::calculate_relative_error ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, dimension(dim), intent(out)  re 
)

Calculate error relative to observed (absolute) mean value for all subbasins, "RE".

Parameters
[in]iacIndex of accumulation criteria
[in]dimDimension of array, number of subbasins
[out]reRelative error
+ Here is the caller graph for this function:

◆ calculate_spatial_mean_absolute_bias()

subroutine compout::calculate_spatial_mean_absolute_bias ( integer, intent(in)  iac,
integer, intent(in)  limityear,
integer, intent(in)  limitbasin,
integer, intent(in)  vartype,
real, intent(out)  smab 
)

Calculate Mean absolute scaled bias with subbasins as time series, "SMB".

Parameters
[in]iacIndex of accumulation criteria
[in]limityearMinimum years with data (5)
[in]limitbasinMinimum basins with data (5)
[in]vartypeVariable type (state,flow or concentration)
[out]smabCriteria, spatial mean absolute bias

Algorithm

Calculate average of variables for each subbasin

Transformation, natural logarithm

Calculate fit from the subbasin averages

Set output

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_spatial_nash_sutcliffe()

subroutine compout::calculate_spatial_nash_sutcliffe ( integer, intent(in)  iac,
integer, intent(in)  limityear,
integer, intent(in)  limitbasin,
integer, intent(in)  vartype,
real, intent(out)  sr2 
)
private

Calculate Nash-Sutcliffe efficiency with subbasins as time series, "spatial R2".

Parameters
[in]iacIndex of accumulation criteria
[in]limityearMinimum years with data (5)
[in]limitbasinMinimum basins with data (5)
[in]vartypeVariable type (state,flow or concentration)
[out]sr2Criteria, spatial R2

Algorithm
Calculate average of variables for each subbasin

Calculate Nash-Sutcliffe efficiency from the subbasin averages

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_spatial_root_mean_square_error()

subroutine compout::calculate_spatial_root_mean_square_error ( integer, intent(in)  iac,
integer, intent(in)  limityear,
integer, intent(in)  limitbasin,
integer, intent(in)  vartype,
real, intent(out)  srmse 
)

Calculate RMSE with subbasins as time series, "spatial RMSE".

Parameters
[in]iacIndex of accumulation criteria
[in]limityearMinimum years with data (5)
[in]limitbasinMinimum basins with data (5)
[in]vartypeVariable type (state,flow or concentration)
[out]srmseCriteria, spatial RMSE

Algorithm

Calculate average of variables for each subbasin

Calculate RMSE from the subbasin averages

Scale with average of observations

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_subbasin_mean_var()

subroutine compout::calculate_subbasin_mean_var ( integer, intent(in)  iac,
integer, intent(in)  limityear,
integer, intent(in)  dim,
integer, intent(in)  vartype,
real, dimension(dim), intent(out)  rec,
real, dimension(dim), intent(out)  sim 
)

Calculate average value for each subbasin of simulated and recorded variable.

Parameters
[in]iacIndex of accumularion criteria
[in]limityearMinimum years with data (5)
[in]dimDimension of data arrays, subbasins
[in]vartypeVariable type (state,flow or concentration)
[out]recRecorded variable subbasin yearmean or yearsum
[out]simComputed variable subbasin yearmeanor yearsum
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_upstream_average()

subroutine, public compout::calculate_upstream_average ( integer, intent(in)  varindex,
integer, intent(in)  areatype,
real, dimension(nsub), intent(out)  avvalue 
)

Calculate the upstream average of a variable for all subbasins.

Parameters
[in]varindexoutvar index of variable to be averaged
[in]areatypebasinarea or landarea variable
[out]avvalueupstream average

Algoritm
Return if the upstream variable not have an associated base area

Accumulate values downstream

+ Here is the caller graph for this function:

◆ calculate_variance_based_criteria()

subroutine compout::calculate_variance_based_criteria ( integer, intent(in)  iac,
integer, intent(in)  dim,
real, dimension(dim), intent(out)  recstd,
real, dimension(dim), intent(out)  simstd,
real, dimension(dim), intent(out)  stderr,
real, dimension(dim), intent(out)  stdrelerr,
real, dimension(dim), intent(out)  corr,
real, dimension(dim), intent(out)  nsew 
)

Calculate standard deviation of observations and simulated values for all time series. Also calculate error, relative error and correlation of the standard deviation.

Parameters
[in]iacindex of accumulation criteria
[in]dimdimension of criteria, number of subbasins
[out]recstdrecorded standard deviation
[out]simstdsimulated standard deviation
[out]stderrerror of standard deviation
[out]stdrelerrrelative error of standard deviation
[out]corrcorrelation coefficient
[out]nsewNash-Sutcliffe efficiency adjusted for bias (NSE+bias^2/Var)

Algorithm

For every subbasin with enough data: calculate criteria

Calculate standard deviation, error and correlation

+ Here is the caller graph for this function:

◆ check_and_acc_one_data()

subroutine compout::check_and_acc_one_data ( logical, intent(in)  simple,
integer, intent(in)  sumtype,
real, intent(in)  y,
real, intent(in)  yhelp,
real, intent(in)  miss,
real, intent(inout)  acc,
real, intent(inout)  acchelp,
integer, intent(inout)  accok 
)
private

Check if data ok and then accumulate data.

Parameters
[in]simpleFlag for timesteply output
[in]sumtypeAccumulation type of data
[in]yData
[in]yhelpHelp data (water for weighting)
[in]missMissing value
[in,out]accVariable for accumulated data
[in,out]acchelpVariable for accumulated help data
[in,out]accokVariable for status of accumulation (0/1)

Algorithm

If timsteply output use the data as is (weight equal to 1)

Else: Depending on data accumulation type: accumulate or end accumulation

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_and_outmean_one_data()

subroutine compout::check_and_outmean_one_data ( integer, intent(in)  sumtype,
integer, intent(in)  pcode,
integer, intent(in)  nper,
real, intent(in)  miss,
real, intent(in)  acc,
real, intent(in)  acch,
real, intent(out)  x 
)

Compute the correct output average at the end of mean period for accumulated data based on average type, period length and missing data.

Parameters
[in]sumtypeCode for variable average type
[in]pcodeCode for period
[in]nperPeriod length
[in]missMissing value
[in]accVariable for accumulated data
[in]acchVariable for accumulated help data
[out]xAverage or sum of accumulated data

Algorithm

Calculate denominator for average depending on accumulation type

Calculate average

+ Here is the caller graph for this function:

◆ compute_basinoutput()

subroutine, public compout::compute_basinoutput ( integer, intent(in)  io,
integer, intent(in)  iad,
integer, intent(in)  dim,
logical, intent(in)  pwrite,
logical, intent(in)  pend,
integer, intent(in)  nper,
integer, intent(in)  idt,
integer, intent(in)  iens,
real, dimension(dim), intent(out)  x 
)

Accumulate and calculate the mean of period for timeserie output for specific subbasin.

Consequences Module worldvar variables output change.

Parameters
[in]ioCurrent output
[in]iadCurrent (index of selected) subbasin
[in]dimData dimension, number of variables for print out
[in]pwriteFlag for end of period to be written
[in]pendFlag for end of summation period
[in]nperNumber of timesteps in current period
[in]idtCurrent time step number
[in]iensCurrent simulation
[out]xData to file

Algorithm

Default output

Skip warmup period

For every variable for print out:

  • Add value to period accumulation
  • If end of period: calculate output average
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_load_accumulation_period_status()

subroutine compout::compute_load_accumulation_period_status ( type(datetype), intent(in)  date,
type(sourceapptype), intent(in)  loadvar,
integer, intent(out)  nper,
logical, intent(out)  pstart,
logical, intent(out)  pend 
)
private

Compute number of timesteps in period, and check if period is ending.

Parameters
[in]dateCurrent date
[in]loadvarAccload structure
[out]nperNumber of timesteps in current period (calculated only if pend is true)
[out]pstartFlag for started period
[out]pendFlag for end of period

Algorithm

Set flag for current date in period

Check if end of period

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_mapoutput()

subroutine, public compout::compute_mapoutput ( type(timeinformationtype), intent(in)  ct,
integer, intent(in)  io,
integer, intent(in)  idt,
integer, intent(in)  ndt,
logical, intent(in)  intformat,
integer, intent(out)  nmapperiod 
)

Accumulate and calculate the mean of period for map output.

Consequences Module variables output,maptime,tmap may change.

Parameters
[in]ctCurrent time
[in]ioCurrent output
[in]idtCurrent time step number
[in]ndtNumber of time steps in run
[in]intformatWrite matlab format
[out]nmapperiodNumber of periods for map print out

Algorithm
Skip warmup period

For every variable and subbasin for print out:

  • Accumulate timestep data
  • If end of period: calculate output average

If end of period: Set the map time and prepare for next accumulation period

Calculate number of periods for map print out (so far)

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_outloads()

subroutine, public compout::compute_outloads ( type(datetype), intent(in)  d,
logical, intent(out)  pend,
integer, intent(in)  idt 
)

Accumulate yearly totals of nutrient loads from daily values. Can also accumulate for a shorter period if asked for.

Consequences Module variables accload may change.

Parameters
[in]dCurrent date
[out]pendFlag for writing load files, end of summation period
[in]idtCurrent time step number

Algorithm
Skip warmup period

Check for period start and end

Check for negative accumulated loads (between lakebasins), zero them if found.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_period_timesteplength_and_end_status()

subroutine compout::compute_period_timesteplength_and_end_status ( type(timeinformationtype), intent(in)  ct,
integer, intent(in)  pcode,
integer, intent(out)  nper,
logical, intent(out)  pend,
logical, intent(out)  pfull,
integer, intent(in)  idt,
integer, intent(in)  ndt 
)

Compute number of timesteps in accumulation period, and check if period is ending.

Parameters
[in]ctCurrent time
[in]pcodeCode for period
[out]nperNumber of timesteps in current period (calculated only if pend is true)
[out]pendFlag for end of summation period
[out]pfullFlag for full summation period at end
[in]idtCurrent time step
[in]ndtNumber of time steps in run

Algorithm
Calculate day of year, day of month, last day of year etc. Calculate end of year, month, week and day.

Depending on current period: Calculate number of time steps in period and check if end of period

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_print_output_flags()

subroutine, public compout::compute_print_output_flags ( type(timeinformationtype), intent(in)  ct,
integer, intent(in)  io,
integer, intent(in)  idt,
integer, intent(in)  ndt,
integer, intent(out)  nper,
logical, intent(out)  pwrite,
logical, intent(out)  pend,
logical, intent(out)  wuskip 
)

Check if time for output of meanperiod timeserie output, and if output is timesteply.

Consequences Worldvar module variables output may change.

Parameters
[in]ctCurrent time
[in]ioCurrent output
[in]idtCurrent time step number
[in]ndtNumber of time steps in run
[out]nperNumber of timesteps in current period
[out]pwriteFlag for end of period to be written
[out]pendFlag for end of summation period
[out]wuskipFlag for skipping warmup period

Algorithm
Default values

Skip warmup period

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_regionoutput()

subroutine, public compout::compute_regionoutput ( integer, intent(in)  io,
integer, intent(in)  ir,
integer, intent(in)  iad,
integer, intent(in)  dim,
logical, intent(in)  pwrite,
logical, intent(in)  pend,
integer, intent(in)  nper,
integer, intent(in)  idt,
integer, intent(in)  iens,
real, dimension(dim), intent(out)  x 
)

Accumulate and calculate the mean of output period for region output for one region.

Consequences Module worldvar variable output may change.

Parameters
[in]ioCurrent output
[in]irCurrent region (region order)
[in]iadIndex of accdata (of current region)
[in]dimData dimension, number of variables for print out
[in]pwriteFlag for end of period to be written
[in]pendFlag for end of summation period
[in]nperNumber of timesteps in current period
[in]idtCurrent time step number
[in]iensCurrent simulation
[out]xData, calculated period mean

Algorithm
Default output

Skip warmup period

For every variable for print out:

  • Add value to period accumulation
  • If end of period: calculate output average
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_sr2limit()

real function compout::compute_sr2limit ( integer, intent(in)  yearlim,
integer, intent(in)  per 
)

Calculate minimum number of data points necessary to have minimum number of years with data for SR2-criterium calculation.

Parameters
[in]yearlimMimimum number of years needed
[in]perAccumulation period code
Return values
compute:sr2limitnumber of data points needed
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_timeoutput()

subroutine, public compout::compute_timeoutput ( integer, intent(in)  io,
integer, intent(in)  ivar,
integer, intent(in)  dim,
logical, intent(in)  pwrite,
logical, intent(in)  pend,
integer, intent(in)  nper,
integer, intent(in)  idt,
integer, intent(in)  iens,
real, dimension(dim), intent(out)  x 
)

Accumulate and calculate the mean of period for timeserie output for one variable.

Consequences Worldvar module variables output may change.

Parameters
[in]ioCurrent output
[in]ivarCurrent output variable
[in]dimNumber of subbasins/outregions
[in]pwriteFlag for end of period to be written
[in]pendFlag for end of summation period
[in]nperNumber of timesteps in current period
[in]idtCurrent time step number
[in]iensCurrent simulation
[out]xData to file

Algorithm

Default output

Skip warmup period

For every subbasin:

  • Accumulate timestep data
  • If end of period: calculate output average and reset accumulation variables
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_yearfact()

real function compout::compute_yearfact ( integer, intent(in)  vartype,
integer, intent(in)  per 
)

Calculate the scaling factor to get the yearly mean value based on a value of the current accumulation period.

Parameters
[in]vartypetype of accumulation for variable
[in]peraccumulation period code
Return values
compute_yearfactscaling factor

Algorithm
If accumulation type is sum over period: Calculate scaling factor as number of time steps in period

If accumulation type is average over period: Calculate scaling factor as reciprocal of number of time steps in period

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extend_ktvariables()

subroutine compout::extend_ktvariables ( integer, intent(in)  n,
integer, intent(in)  m,
integer, intent(in)  i 
)

Subroutine that extends two allocatable arrays by 100.

Consequences Module worldvar variables are increased in size

Parameters
[in]nNumber of values (subbasins)
[in]mSecond dimension, to be increased
[in]iCurrent accumulated variable index
+ Here is the caller graph for this function:

◆ find_acrit_corresponding_to_crit()

subroutine, public compout::find_acrit_corresponding_to_crit ( integer, intent(in)  i,
integer, intent(out)  iout 
)

Find what accumulated variables corresponds to current criteria variable.

Parameters
[in]iCurrent criterion index
[out]ioutAccumulated variable index
+ Here is the caller graph for this function:

◆ find_crit_corresponding_to_acrit()

subroutine compout::find_crit_corresponding_to_acrit ( integer, intent(in)  j,
integer, intent(out)  iout 
)

Find what criteria variable corresponds to current accumulated variable.

Parameters
[in]jAccumulated variable index
[out]ioutCurrent criterion index
+ Here is the caller graph for this function:

◆ find_variable_index()

integer function, public compout::find_variable_index ( character(len=4), intent(in)  str,
integer, intent(out)  iout,
integer, intent(out)  flow 
)

Finds the index for an output variable short name string.

Parameters
[in]strvariable short name
[out]ioutindex of variable
[out]flowtype of variable (0=state,1=flow,2=conc)
Return values
find_variable_indexerror status of function

Algorithm
Transform all variable name to lower case.

Find index of current output variable

If found: Set output dummy argument, else: return missing.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_variable_index_type()

integer function, public compout::find_variable_index_type ( character(len=*), intent(in)  str,
integer, intent(out)  outindex,
integer, intent(out)  timeagg,
integer, intent(out)  areaagg 
)

Finds idindex and type for an output variable short name string.

Parameters
[in]strvariable short name
[out]outindexindex of variable
[out]timeaggtype of time period aggreagation (0=state,1=flow,2=conc)
[out]areaaggtype of area aggreagation (0=basin,1=upstream,2=region)
Return values
find_variable_index_typeerror status of function

Algorithm
Transform all variable name to lower case.

Depending on area aggregation find variable index

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_unit_string()

character(len=30) function, public compout::get_unit_string ( integer, intent(in)  io,
integer, intent(in)  ivar 
)

Get the proper unit for output variables summed over a period.

Parameters
[in]iocurrent output
[in]ivarcurrent output variable
Returns
Return values
theunit spelled out for current period
Returns
Get unit of current variable

If summed variable; add the current period

+ Here is the caller graph for this function:

◆ get_variable_string()

character(len=20) function, public compout::get_variable_string ( type(outputvariabletype outputvariable)

Get the name of a variable from output.

Parameters
outputvariablevariable from output; output(io)variable(ivar)
Returns
Return values
thevariable name
+ Here is the caller graph for this function:

◆ initiate_outvar()

subroutine, public compout::initiate_outvar ( integer, intent(in)  idt)

Initiate output variables to missing value.

Consequences Module modvar variables firstoutstep and outvar is set.

Parameters
[in]idtcurrent timestep
+ Here is the caller graph for this function:

◆ kendallstau()

subroutine compout::kendallstau ( integer, intent(in)  n,
real, dimension(n), intent(in)  data1,
real, dimension(n), intent(in)  data2,
real, intent(inout)  tau 
)
private

Calculates Kendalls Tau, rank correlation, between two data sets with adjustment for ties.

Parameters
[in]nDimension of data set
[in]data1Data set 1
[in]data2Data set 2
[in,out]tauCalculated Kendalls tau
+ Here is the caller graph for this function:

◆ prepare_to_compute_crit()

subroutine, public compout::prepare_to_compute_crit ( type(timeinformationtype), intent(in)  ct,
integer, intent(in)  idt,
integer, intent(in)  ndt 
)

Accumulate data for criteria calculation.

Consequences Module worldvar variables critvec, rs,cs and ts may be allocated and/or changed

Parameters
[in]ctCurrent time
[in]idtCurrent time step number
[in]ndtNumber of time steps in run

Algorithm
Skip warmup period

Allocate criteria accumulation variables if not already done

If first time step of accumulation period: initialise accumulation variables

For every criteria with unique variables:

Accumulate data for period

If end of period:

  • Upscale data for periods with not all observations
  • If needed: save data for later (for Kendalls Tau and RA the variables need to be saved)
  • For every subbasin/outregion: accumulate data period data for later criteria calculations
  • (Re-)initialize accumulation variables
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reform_accumulated_periodvalues()

subroutine compout::reform_accumulated_periodvalues ( integer, intent(in)  n,
integer, intent(in)  acctype,
real, dimension(n), intent(inout)  rs,
real, dimension(n), intent(inout)  cs,
integer, dimension(n), intent(inout)  ts 
)
private

Reform period accumulate variables to average value for some variables.

Parameters
[in]nDimension of variables, number of subbasins
[in]acctypeType of accumulation for variable; sum, mean, weighted mean*2
[in,out]rsAccumulation of recorded value
[in,out]csAccumulation of computed value
[in,out]tsAccumulation of number of values
+ Here is the caller graph for this function:

◆ reset_periodvalues()

subroutine compout::reset_periodvalues ( real, dimension(n,m), intent(inout)  rs,
real, dimension(n,m), intent(inout)  cs,
integer, dimension(n,m), intent(inout)  ts,
integer, intent(in)  n,
integer, intent(in)  m 
)

Reset the period accumulation variables.

Parameters
[in]nDimension of variables
[in]mDimension of variables
[in,out]rsAccumulation of recorded value
[in,out]csAccumulation of computed value
[in,out]tsAccumulation of number of values
+ Here is the caller graph for this function:

◆ revise_outvar()

subroutine, public compout::revise_outvar

Set concentrations of waters with zero volume to missing_value and calculate regional and upstream average for output.

Consequences Module modvar variable outvar may be set.

Calculate outvar as class average for non-aggregated class outvars

Calculate new outvar for regional variables

Calculate new outvar for upstream variables

Set computed concentrations of waters with zero volume to missing_value

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save_variables_for_later_critcalc()

subroutine compout::save_variables_for_later_critcalc ( integer, intent(in)  n,
integer, intent(in)  icrit,
real, dimension(n), intent(in)  cs,
real, dimension(n), intent(in)  rs,
integer, dimension(n), intent(in)  ts 
)

Save the variables needed to calculate Kendalls tau or RA after the simulation.

Consequences Worldvar module variables ktcomp,ktrec and ktnum etc may be allocated and set.

Parameters
[in]nNumber of values (subbasins)
[in]icritCurrent accumulated variable index
[in]csComputed value
[in]rsRecorded value
[in]tsNumber of values used for cs,rs

Algorithm
Depending on index of accumulated variable:

  • Allocate variables for holding values until end of simulation if necessary
  • For every subbasin: If values exist set variable. If variable full increase its size.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop_acc_data()

subroutine compout::stop_acc_data ( real, intent(in)  miss,
real, intent(out)  acc,
integer, intent(out)  accok 
)

Missing data, stop further accumulation for this period.

Parameters
[in]missMissing value
[out]accVariable for accumulation of data
[out]accokVariable for status of accumulation (0/1)
+ Here is the caller graph for this function: