# PDAF_diag_histogram

This page documents the routine `PDAF_diag_histogram`

of PDAF, which was introduced with PDAF V1.12.

This routine increments information on an ensemble rank histogram. The histogram gives a binned representation of the ensemble distribution relative to the state vector.

Inputs are the ensemble array and a state vector about which the histogram is computed. In addition, the index of the element has to be specified for which the histogram is computed. If this is 0, the histogram information is collected over all elements. Also, the value 'ncall' has to be set. It gives the number of calls used to increment the histogram and is needed to compute the delta-measure that describes the deviation from the ideal histogram.

The input/output array 'hist' has to be allocated externally. In addition, it has to be initialized with zeros before the first call.

The routine can be called in the pre/poststep routine of PDAF both before and after the analysis step to collect the histogram information.

The interface is the following:

SUBROUTINE PDAF_diag_histogram(ncall, dim, dim_ens, element, & state, ens, hist, delta, status)

with the following arguments:

`ncall`

:`integer, intent(in)`

Number of calls to routine (>=1)`dim`

:`integer, intent(in)`

Size of state vector`dim_ens`

:`integer, intent(in)`

Ensemble size`element`

:`integer, intent(in)`

Element of state vector for which the histogram is computed. If`element=0`

, the histogram is computed over the whole state vector`state`

:`real, intent(in), dimension(dim)`

State vector`ens`

:`real, intent(in), dimension(dim, dim_ens)`

State ensemble`hist`

:`integer, intent(inout), dimension(dim, dim_ens+1)`

Histogram about the state`delta`

:`real, intent(out)`

Measure of deviation from flat histogram`status`

:`integer, intent(out)`

Status flag

Notes:

- The array
`hist`

has to be allocated and initialized with zeros before the first call to`PDAF_diag_histogram`

- The value of
`delta`

is >0 if the histogram is not flat. However, delta is not bounded and is hence difficult to interpret. - An example of using
`PDAF_diag_histogram`

can be found in the Lorenz-96 model example (see models/lorenz96/compute_truermse.F90).