@BeginModule
@NewPage
@Name      = Ymonpctl
@Title     = Multi-year monthly percentile values
@Section   = Statistical values
@Class     = Statistic
@Arguments = ifile1 ifile2 ifile3 ofile
@Operators = ymonpctl

@BeginDescription
This operator writes a certain percentile of each month of year in @file{ifile1} to @file{ofile}.
The algorithm uses histograms with minimum and maximum bounds given in
@file{ifile2} and @file{ifile3}, respectively. The default number of
histogram bins is 101. The default can be overridden by setting the
environment variable @env{CDO_PCTL_NBINS} to a different value. The files
@file{ifile2} and @file{ifile3} should be the result of corresponding
@mod{ymonmin} and @mod{ymonmax} operations, respectively.
The date information in an output field is the date of the last
contributing input field.
@EndModule


@BeginOperator_ymonpctl
@Title     = Multi-year monthly percentiles
@Parameter = p

@BeginDescription
@IfMan

o(01,x) = pth percentile {i(t,x), month(i(t)) = 01}
                 ...
o(12,x) = pth percentile {i(t,x), month(i(t)) = 12}
@EndifMan
@IfDoc
\vspace*{3mm}

@BeginMath
\begin{array}{c}
o(\mbox{01},x) = \mbox{\bf pth percentile}\{i(t,x), \mbox{month}(i(t)) = \mbox{01}\} \\
\vdots \\
o(\mbox{12},x) = \mbox{\bf pth percentile}\{i(t,x), \mbox{month}(i(t)) = \mbox{12}\} \\
\end{array}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginParameter
@Item = p
INTEGER  Percentile number in {1, ..., 99}
@EndParameter


@BeginEnvironment
@Item = CDO_PCTL_NBINS
Sets the number of histogram bins. The default number is 101.
@EndEnvironment


@BeginExample
To compute the monthly 90th percentile over all input years use:
@BeginVerbatim
   cdo ymonmin ifile minfile
   cdo ymonmax ifile maxfile
   cdo ymonpctl,90 ifile minfile maxfile ofile
@EndVerbatim
Or shorter using operator piping:
@BeginVerbatim
   cdo ymonpctl,90 ifile -ymonmin ifile -ymonmax ifile ofile
@EndVerbatim
@EndExample
