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) |
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.
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.
[in] | sumtype | Type of output variable |
[in] | y | Data |
[in] | yhelp | Help data (water for weighting) |
[in,out] | acc | Variable for accumulated data |
[in,out] | acch | Variable for accumulated help data |
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.
[in] | m | Mask value, missing value |
[in] | n | Size of variables, number of subbasins |
[in] | r | Recorded value of variable to be used for criteria |
[in] | c | Computed value of variable to be used for criteria |
[in,out] | rs | Accumulation of recorded value |
[in,out] | cs | Accumulation of computed value |
[in,out] | ts | Accumulation of number of values |
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.
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.
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".
[in] | iac | Index of accumulation criteria |
[in] | dim | Dimension of array, number of subbasins |
[in] | acoeff | Coefficient a for RA criterion |
[out] | ra | Calculated criteria, RA |
Algorithm
For each subbasin: Calculate criteria RA
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.
[in] | iac | Index of accumulated criteria |
[in] | dim | Dimension of array, number of subbasins |
[out] | tau | Calculated criteria, Kendalls tau |
Algorithm
For each subbasin: Calculate kendalls tau
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.
[in] | varindex | index of variable's class values |
[in] | ncl | number of selected classes |
[in] | classindex | index of selected classes |
[out] | avvalue | class average values |
Algoritm
Calculate average value of selected classes
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.
[in] | varindex | index of variable's class values |
[in] | varindex0 | index of variable's corresponding water class values |
[in] | ncl | number of selected classes |
[in] | classindex | index of selected classes |
[out] | avvalue | class average values |
Algoritm
Calculate weighted average value of selected classes
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?).
[out] | crit0 | Value of chosen objective function |
[out] | basincrit | Performance criteria per subbasin and variable |
[out] | simcrit | Performance criteria per variable |
[out] | crit1 | Conditional criteria |
[out] | thres1 | Threshold 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:
Set output variables
Deallocate help variables for calculating Kendalls Tau or RA
|
private |
Calculate three fitness criteria between two arrays of length n.
[in] | n | Number of elements |
[in] | c | Array with computed values |
[in] | r | Array with recorded values |
[in] | m | Missing value |
[in] | lim | Minimum number of elements |
[out] | x | Fitness 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
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)
[in] | iac | Index of accumulation criteria |
[in] | dim | Dimension of array, number of subbasins |
[out] | kge | Kling-Gupta efficiency |
[out] | sckge | Kling-Gupta efficiency rescaled to (-1,1) |
[out] | kge1 | Kling-Gupta efficiency part 1, cc |
[out] | kge2 | Kling-Gupta efficiency part 2, std-quotient |
[out] | kge3 | Kling-Gupta efficiency part 3, mean-quotient |
Algorithm
For every subbasin with enough data: calculate criteria
|
private |
Calculates fitness criterion, mean absolute scaled bias.
[in] | n | Number of elements |
[in] | c | Array with computed values |
[in] | r | Array with recorded values |
[in] | m | Missing value |
[in] | lim | Minimum number of elements |
[in] | usew | Status of using weights on subbasin |
[in] | w | Weight for averaging criteria |
[out] | x | Fitness 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
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.
[in] | iac | index of accumulation criteria |
[in] | dim | dimension of criteria |
[out] | rec | mean recorded value |
[out] | sim | mean simulated value |
[out] | rmae | mean absolute error |
[out] | rmse | root mean square error |
[out] | nrmse | normalized root mean square error, rmse/maxRec (rmse/(maxRec-MinRec)?) |
[out] | n | number of observations used |
|
private |
Calculate (subbasin) mean value of criterion; arithmetic mean or weighted mean.
[in] | dim | Dimension of array, subbasins |
[in] | usew | Status of using weighted mean |
[in] | crit | Array with criteria |
[in] | w | Weight for averaging criteria |
[out] | ave | Average of criteria |
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.
[in] | dim | Dimension of array, subbasins |
[in] | usew | Status of using weighted mean |
[in] | crit | Array with criteria |
[out] | ave | Average of criteria |
[in] | w | Weight for averaging criteria |
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.
[in] | dim | number of areas |
[in] | crit | criteria value for areas |
[in] | miss | missing value |
[out] | num | Number of areas with criteria |
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.
[in] | n | Number of elements |
[in] | x | Array with values |
[in] | miss | Missing value |
[out] | median | Median value |
Algorithm
Calculate the median simle for small arrays, the return
Calculate the place of the median element
Calculate the median
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.
[in] | iac | Index of accumulation criteria |
[out] | mmvalues | Min and max values (dim,4) |
Algorithm
For every subbasin with enough data: calculate criteria
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.
[in] | iac | Index of accumulation criteria |
[in] | dim | Dimension of array, number of subbasins |
[out] | r2 | Nash-Sutcliffe efficiency |
|
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.
[in] | n | Number of elements |
[in] | c | Array with computed values |
[in] | r | Array with recorded values |
[in] | m | Missing value |
[in] | p | Parameter value of criterion |
[in] | lim | Minimum number of elements |
[out] | x | Fitness criterion 1=RA |
Algorithm
Initialize
Calculate sum of values and errors (for not missing values)
If enough values not missing; calculate fitness criteria
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.
[in] | ireg | current region |
[in] | ivar | index of output variable (in outvar) |
[out] | average | region average value |
Algoritm
Calculate region average of the variable for the region, by adding the subbasin values multiplied by their weight in the average.
subroutine, public compout::calculate_region_obsfunc | ( | integer, intent(in) | ireg | ) |
Calculate the region observation functions for an outregion.
[in] | ireg | current region |
Algoritm
Select observation function
Obsfunc 1: Calculate reservoir inflow as local runoff + precipitation on reservoir minus evaporation of reservoir
Obsfunc 2: Not implemented yet.
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".
[in] | iac | Index of accumulation criteria |
[out] | rmae | Regional mean absolute error |
Algorithm
Accumulate data over all subbasins
Calculate regional MAE of all observations
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".
[in] | iac | Index of accumulation criteria |
[out] | rr2 | Calculated criterion, regional R2 |
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.
[in] | iac | Index of accumulation criteria |
[out] | num | Number of data points |
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".
[in] | iac | Index of accumulation criteria |
[in] | acoeff | Coefficient a for RA criterion |
[out] | rra | Calculated 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
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".
[in] | iac | Index of accumulation criteria |
[out] | rve | Regional relative error |
Algorithm
Accumulate data over all subbasins
Calculate regional relative volume 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".
[in] | iac | Index of accumulation criteria |
[in] | dim | Dimension of array, number of subbasins |
[out] | re | Relative error |
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".
[in] | iac | Index of accumulation criteria |
[in] | limityear | Minimum years with data (5) |
[in] | limitbasin | Minimum basins with data (5) |
[in] | vartype | Variable type (state,flow or concentration) |
[out] | smab | Criteria, spatial mean absolute bias |
Algorithm
Calculate average of variables for each subbasin
Transformation, natural logarithm
Calculate fit from the subbasin averages
Set output
|
private |
Calculate Nash-Sutcliffe efficiency with subbasins as time series, "spatial R2".
[in] | iac | Index of accumulation criteria |
[in] | limityear | Minimum years with data (5) |
[in] | limitbasin | Minimum basins with data (5) |
[in] | vartype | Variable type (state,flow or concentration) |
[out] | sr2 | Criteria, spatial R2 |
Algorithm
Calculate average of variables for each subbasin
Calculate Nash-Sutcliffe efficiency from the subbasin averages
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".
[in] | iac | Index of accumulation criteria |
[in] | limityear | Minimum years with data (5) |
[in] | limitbasin | Minimum basins with data (5) |
[in] | vartype | Variable type (state,flow or concentration) |
[out] | srmse | Criteria, spatial RMSE |
Algorithm
Calculate average of variables for each subbasin
Calculate RMSE from the subbasin averages
Scale with average of observations
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.
[in] | iac | Index of accumularion criteria |
[in] | limityear | Minimum years with data (5) |
[in] | dim | Dimension of data arrays, subbasins |
[in] | vartype | Variable type (state,flow or concentration) |
[out] | rec | Recorded variable subbasin yearmean or yearsum |
[out] | sim | Computed variable subbasin yearmeanor yearsum |
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.
[in] | varindex | outvar index of variable to be averaged |
[in] | areatype | basinarea or landarea variable |
[out] | avvalue | upstream average |
Algoritm
Return if the upstream variable not have an associated base area
Accumulate values downstream
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.
[in] | iac | index of accumulation criteria |
[in] | dim | dimension of criteria, number of subbasins |
[out] | recstd | recorded standard deviation |
[out] | simstd | simulated standard deviation |
[out] | stderr | error of standard deviation |
[out] | stdrelerr | relative error of standard deviation |
[out] | corr | correlation coefficient |
[out] | nsew | Nash-Sutcliffe efficiency adjusted for bias (NSE+bias^2/Var) |
Algorithm
For every subbasin with enough data: calculate criteria
Calculate standard deviation, error and correlation
|
private |
Check if data ok and then accumulate data.
[in] | simple | Flag for timesteply output |
[in] | sumtype | Accumulation type of data |
[in] | y | Data |
[in] | yhelp | Help data (water for weighting) |
[in] | miss | Missing value |
[in,out] | acc | Variable for accumulated data |
[in,out] | acchelp | Variable for accumulated help data |
[in,out] | accok | Variable 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
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.
[in] | sumtype | Code for variable average type |
[in] | pcode | Code for period |
[in] | nper | Period length |
[in] | miss | Missing value |
[in] | acc | Variable for accumulated data |
[in] | acch | Variable for accumulated help data |
[out] | x | Average or sum of accumulated data |
Algorithm
Calculate denominator for average depending on accumulation type
Calculate average
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.
[in] | io | Current output |
[in] | iad | Current (index of selected) subbasin |
[in] | dim | Data dimension, number of variables for print out |
[in] | pwrite | Flag for end of period to be written |
[in] | pend | Flag for end of summation period |
[in] | nper | Number of timesteps in current period |
[in] | idt | Current time step number |
[in] | iens | Current simulation |
[out] | x | Data to file |
Algorithm
Default output
Skip warmup period
For every variable for print out:
|
private |
Compute number of timesteps in period, and check if period is ending.
[in] | date | Current date |
[in] | loadvar | Accload structure |
[out] | nper | Number of timesteps in current period (calculated only if pend is true) |
[out] | pstart | Flag for started period |
[out] | pend | Flag for end of period |
Algorithm
Set flag for current date in period
Check if end of period
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.
[in] | ct | Current time |
[in] | io | Current output |
[in] | idt | Current time step number |
[in] | ndt | Number of time steps in run |
[in] | intformat | Write matlab format |
[out] | nmapperiod | Number of periods for map print out |
Algorithm
Skip warmup period
For every variable and subbasin for print out:
If end of period: Set the map time and prepare for next accumulation period
Calculate number of periods for map print out (so far)
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.
[in] | d | Current date |
[out] | pend | Flag for writing load files, end of summation period |
[in] | idt | Current time step number |
Algorithm
Skip warmup period
Check for period start and end
Check for negative accumulated loads (between lakebasins), zero them if found.
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.
[in] | ct | Current time |
[in] | pcode | Code for period |
[out] | nper | Number of timesteps in current period (calculated only if pend is true) |
[out] | pend | Flag for end of summation period |
[out] | pfull | Flag for full summation period at end |
[in] | idt | Current time step |
[in] | ndt | Number 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
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.
[in] | ct | Current time |
[in] | io | Current output |
[in] | idt | Current time step number |
[in] | ndt | Number of time steps in run |
[out] | nper | Number of timesteps in current period |
[out] | pwrite | Flag for end of period to be written |
[out] | pend | Flag for end of summation period |
[out] | wuskip | Flag for skipping warmup period |
Algorithm
Default values
Skip warmup period
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.
[in] | io | Current output |
[in] | ir | Current region (region order) |
[in] | iad | Index of accdata (of current region) |
[in] | dim | Data dimension, number of variables for print out |
[in] | pwrite | Flag for end of period to be written |
[in] | pend | Flag for end of summation period |
[in] | nper | Number of timesteps in current period |
[in] | idt | Current time step number |
[in] | iens | Current simulation |
[out] | x | Data, calculated period mean |
Algorithm
Default output
Skip warmup period
For every variable for print out:
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.
[in] | yearlim | Mimimum number of years needed |
[in] | per | Accumulation period code |
compute:sr2limit | number of data points needed |
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.
[in] | io | Current output |
[in] | ivar | Current output variable |
[in] | dim | Number of subbasins/outregions |
[in] | pwrite | Flag for end of period to be written |
[in] | pend | Flag for end of summation period |
[in] | nper | Number of timesteps in current period |
[in] | idt | Current time step number |
[in] | iens | Current simulation |
[out] | x | Data to file |
Algorithm
Default output
Skip warmup period
For every subbasin:
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.
[in] | vartype | type of accumulation for variable |
[in] | per | accumulation period code |
compute_yearfact | scaling 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
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
[in] | n | Number of values (subbasins) |
[in] | m | Second dimension, to be increased |
[in] | i | Current accumulated variable index |
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.
[in] | i | Current criterion index |
[out] | iout | Accumulated variable index |
subroutine compout::find_crit_corresponding_to_acrit | ( | integer, intent(in) | j, |
integer, intent(out) | iout | ||
) |
Find what criteria variable corresponds to current accumulated variable.
[in] | j | Accumulated variable index |
[out] | iout | Current criterion 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.
[in] | str | variable short name |
[out] | iout | index of variable |
[out] | flow | type of variable (0=state,1=flow,2=conc) |
find_variable_index | error 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.
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.
[in] | str | variable short name |
[out] | outindex | index of variable |
[out] | timeagg | type of time period aggreagation (0=state,1=flow,2=conc) |
[out] | areaagg | type of area aggreagation (0=basin,1=upstream,2=region) |
find_variable_index_type | error status of function |
Algorithm
Transform all variable name to lower case.
Depending on area aggregation find variable index
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.
[in] | io | current output |
[in] | ivar | current output variable |
the | unit spelled out for current period |
If summed variable; add the current period
character(len=20) function, public compout::get_variable_string | ( | type(outputvariabletype) | outputvariable | ) |
Get the name of a variable from output.
outputvariable | variable from output; output(io)variable(ivar) |
the | variable name |
subroutine, public compout::initiate_outvar | ( | integer, intent(in) | idt | ) |
Initiate output variables to missing value.
Consequences Module modvar variables firstoutstep and outvar is set.
[in] | idt | current timestep |
|
private |
Calculates Kendalls Tau, rank correlation, between two data sets with adjustment for ties.
[in] | n | Dimension of data set |
[in] | data1 | Data set 1 |
[in] | data2 | Data set 2 |
[in,out] | tau | Calculated Kendalls tau |
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
[in] | ct | Current time |
[in] | idt | Current time step number |
[in] | ndt | Number 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:
|
private |
Reform period accumulate variables to average value for some variables.
[in] | n | Dimension of variables, number of subbasins |
[in] | acctype | Type of accumulation for variable; sum, mean, weighted mean*2 |
[in,out] | rs | Accumulation of recorded value |
[in,out] | cs | Accumulation of computed value |
[in,out] | ts | Accumulation of number of values |
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.
[in] | n | Dimension of variables |
[in] | m | Dimension of variables |
[in,out] | rs | Accumulation of recorded value |
[in,out] | cs | Accumulation of computed value |
[in,out] | ts | Accumulation of number of values |
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
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.
[in] | n | Number of values (subbasins) |
[in] | icrit | Current accumulated variable index |
[in] | cs | Computed value |
[in] | rs | Recorded value |
[in] | ts | Number of values used for cs,rs |
Algorithm
Depending on index of accumulated variable:
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.
[in] | miss | Missing value |
[out] | acc | Variable for accumulation of data |
[out] | accok | Variable for status of accumulation (0/1) |