@BeginModule
@NewPage
@Name      = Remapcon2
@Title     = Second order conservative remapping
@Section   = Interpolation
@Class     = Interpolation
@Arguments = ifile ofile
@Operators = remapcon2 gencon2

@BeginDescription
This module contains operators for a second order conservative 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}.
The interpolation method is completely general and can be used for any grid on a sphere.
The search algorithm for the conservative remapping requires that no grid cell occurs more than once. 
@IfDoc
Below is a schematic illustration of the 2nd order conservative remapping:

\vspace{1mm}

\includegraphics[width=\textwidth]{remapcon2.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_remapcon2
@Name      = remapcon2
@Title     = Second order conservative remapping
@Parameter = grid

@BeginDescription
Performs a second order conservative remapping on all input fields.
@EndDescription
@EndOperator


@BeginOperator_gencon2
@Name      = gencon2
@Title     = Generate 2nd order conservative remap weights
@Parameter = grid

@BeginDescription
Generates second order conservative remapping 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 = CDO_REMAP_NORM
This variable is used to choose the normalization of the conservative interpolation. 
By default @env{CDO_REMAP_NORM} is set to 'fracarea'. 'fracarea' uses the sum of the
non-masked source cell intersected areas to normalize each target cell field value.
This results in a reasonable flux value but the flux is not locally conserved.
The option 'destarea' uses the total target cell area to normalize each target cell
field value. Local flux conservation is ensured, but unreasonable flux values may result.
@Item = REMAP_AREA_MIN
This variable is used to set the minimum destination area fraction. The default
of this variable is 0.0.
@EndEnvironment


@BeginNote
The SCRIP conservative remapping method doesn't work correctly for some grid combinations.
@EndNote


@BeginExample
Say @file{ifile} contains fields on a quadrilateral curvilinear grid.
To remap all fields conservative (2nd order) to a Gaussian N32 grid, type:
@BeginVerbatim
   cdo remapcon2,n32 ifile ofile
@EndVerbatim
@EndExample
