@BeginModule
@NewPage
@Name      = Distgrid
@Title     = Distribute horizontal grid
@Section   = File operations
@Class     = File operation
@Arguments = ifile obase
@Operators = distgrid
@EndModule


@BeginOperator_distgrid
@Title     = Distribute horizontal grid
@Parameter = nx [ny]

@BeginDescription
This operator distributes a dataset into smaller pieces. Each output file contains a different region of the horizontal 
source grid. A target grid region contains a structured longitude/latitude box of the source grid. Only rectilinear and
curvilinear source grids are supported by this operator.
The number of different regions can be specified with the parameter @var{nx} and @var{ny}. The output files will be named 
<obase><xxx><suffix> where suffix is the filename extension derived from the file format. xxx will have five digits with 
the number of the target region.
@EndDescription
@EndOperator

@BeginParameter nx
@Item = nx
INTEGER  Number of regions in x direction
@Item = ny
INTEGER  Number of regions in y direction [default: 1]
@EndParameter


@BeginNote
This operator needs to open all output files simultaneously.
The maximum number of open files depends on the operating system!
@EndNote


@BeginExample
Distribute a file into 6 smaller files, each output file receives one half of x and a third of y of the source grid:
@BeginVerbatim
   cdo distgrid,2,3 ifile.nc obase
@EndVerbatim
@IfDoc
Below is a schematic illustration of this example:

\includegraphics[width=\textwidth]{distgrid.pdf}

On the left side is the data of the input file and on the right side is the data of the six output files.
@EndifDoc
@EndExample
