@BeginModule
@NewPage
@Name      = Remapbil
@Title     = Bilinear interpolation
@Section   = Interpolation
@Class     = Interpolation
@Arguments = ifile ofile
@Operators = remapbil genbil

@BeginDescription
This module contains operators for a bilinear remapping of fields between grids in spherical coordinates.
The interpolation is based on an adapted SCRIP library version. 
For a detailed description of the interpolation method see @cite{SCRIP}.
This interpolation method only works on quadrilateral curvilinear source grids.
@IfDoc
Below is a schematic illustration of the bilinear remapping:

\vspace{1mm}

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

\vspace{1mm}

The figure on the left side shows the input data on a regular lon/lat source grid and on the right side
the remapped result on an unstructured triangular target grid. The figure in the middle shows the input data with
the target grid. Grid cells with missing value are grey colored.
@EndifDoc
@EndDescription
@EndModule


@BeginOperator_remapbil
@Name      = remapbil
@Title     = Bilinear interpolation
@Parameter = grid

@BeginDescription
Performs a bilinear interpolation on all input fields.
@EndDescription
@EndOperator


@BeginOperator_genbil
@Name      = genbil
@Title     = Generate bilinear interpolation weights
@Parameter = grid

@BeginDescription
Generates bilinear interpolation weights for the first input field and writes the
result to a file. The format of this file is NetCDF following the SCRIP convention.
Use the operator @mod{remap} to apply this remapping weights to a data file with the same source grid.
@EndDescription
@EndOperator


@BeginParameter
@Item = grid
STRING  Target grid description file or name
@EndParameter


@BeginEnvironment
@Item = REMAP_EXTRAPOLATE
This variable is used to switch the extrapolation feature 'on' or 'off'.
By default the extrapolation is enabled for circular grids.
@EndEnvironment


@BeginExample
Say @file{ifile} contains fields on a quadrilateral curvilinear grid.
To remap all fields bilinear to a Gaussian N32 grid, type:
@BeginVerbatim
   cdo remapbil,n32 ifile ofile
@EndVerbatim
@EndExample
