```
POLATEV3

The POLATEV3 routine performs budget interpolation
from any grid to any grid for vector fields.
It requires a grid for the output fields (kgdso(1)>=0).
The algorithm simply computes (weighted) averages
of Bilinearly interpolated points arranged in a square box
centered around each output grid point and stretching
nearly halfway to each of the neighboring grid points.
Options allow choices of number of points in each radius
from the center point (ipopt(1)) which defaults to 2
(if ipopt(1)=-1) meaning that 25 points will be averaged;
Further options are the respective weights for the radius
points starting at the center point (ipopt(2:2+ipopt(1))
which defaults to all 1 (if ipopt(1)=-1 or ipopt(2)=-1).
A special interpolation is done if ipopt(2)=-2.
In this case, the boxes stretch nearly all the way to
each of the neighboring grid points and the weights
are the adjoint of the Bilinear interpolation weights.
This case gives Quasi-Second-Order Budget interpolation.
Another option is the minimum percentage for mask,
i.e. percent valid input data required to make output data,
(ipopt(3+ipopt(1)) which defaults to 50 (if -1).
Only horizontal interpolation is performed.
The grids are defined by their grid description sections
(passed in integer form as decoded by subprogram w3fi63).

The current code recognizes the following projections:
(KGDS(1)=000) EQUIDISTANT CYLINDRICAL
(KGDS(1)=001) MERCATOR CYLINDRICAL
(KGDS(1)=003) LAMBERT CONFORMAL CONICAL
(KGDS(1)=004) GAUSSIAN CYLINDRICAL (SPECTRAL NATIVE)
(KGDS(1)=005) POLAR STEREOGRAPHIC AZIMUTHAL
(KGDS(1)=202) ROTATED EQUIDISTANT CYLINDRICAL (ETA NATIVE)

Where KGDS could be either input KGDSI or output KGDSO.
The input and output vectors are rotated so that they are
either resolved relative to the defined grid
in the direction of increasing x and y coordinates
or resolved relative to easterly and northerly directions,
as designated by their respective grid description sections.
As an added bonus the number of output grid points
and their latitudes and longitudes are also returned
Along with their vector rotation parameters.
Input bitmaps will be interpolated to output bitmaps.
Output bitmaps will also be created when the output grid
Extends outside of the domain of the input grid.
The output field is set to 0 where the output bitmap is off.

USAGE:    CALL POLATEV3(IPOPT,KGDSI,KGDSO,MI,MO,KM,IBI,LI,UI,VI,
NO,RLAT,RLON,CROT,SROT,IBO,LO,UO,VO,IRET)

Input argument list:
IPOPT    - INTEGER (20) INTERPOLATION OPTIONS
IPOPT(1) IS NUMBER OF RADIUS POINTS
(DEFAULTS TO 2 IF IPOPT(1)=-1);
IPOPT(2:2+IPOPT(1)) ARE RESPECTIVE WEIGHTS
(DEFAULTS TO ALL 1 IF IPOPT(1)=-1 OR IPOPT(2)=-1).
IPOPT(3+IPOPT(1)) IS MINIMUM PERCENTAGE FOR MASK
(DEFAULTS TO 50 IF IPOPT(3+IPOPT(1)=-1)
KGDSI    - INTEGER (200) INPUT GDS PARAMETERS AS DECODED BY W3FI63
KGDSO    - INTEGER (200) OUTPUT GDS PARAMETERS
MI       - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS IF KM>1
OR DIMENSION OF INPUT GRID FIELDS IF KM=1
MO       - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS IF KM>1
OR DIMENSION OF OUTPUT GRID FIELDS IF KM=1
KM       - INTEGER NUMBER OF FIELDS TO INTERPOLATE
IBI      - INTEGER (KM) INPUT BITMAP FLAGS
LI       - LOGICAL*1 (MI,KM) INPUT BITMAPS (IF SOME IBI(K)=1)
UI       - REAL (MI,KM) INPUT U-COMPONENT FIELDS TO INTERPOLATE
VI       - REAL (MI,KM) INPUT V-COMPONENT FIELDS TO INTERPOLATE

Output argument list:
NO       - INTEGER NUMBER OF OUTPUT POINTS
RLAT     - REAL (MO) OUTPUT LATITUDES IN DEGREES
RLON     - REAL (MO) OUTPUT LONGITUDES IN DEGREES
CROT     - REAL (NO) VECTOR ROTATION COSINES
SROT     - REAL (NO) VECTOR ROTATION SINES
(UGRID=CROT*UEARTH-SROT*VEARTH;
VGRID=SROT*UEARTH+CROT*VEARTH)
IBO      - INTEGER (KM) OUTPUT BITMAP FLAGS
LO       - LOGICAL*1 (MO,KM) OUTPUT BITMAPS (ALWAYS OUTPUT)
UO       - REAL (MO,KM) OUTPUT U-COMPONENT FIELDS INTERPOLATED
VO       - REAL (MO,KM) OUTPUT V-COMPONENT FIELDS INTERPOLATED
IRET     - INTEGER RETURN CODE
0    SUCCESSFUL INTERPOLATION
2    UNRECOGNIZED INPUT GRID OR NO GRID OVERLAP
3    UNRECOGNIZED OUTPUT GRID
31   INVALID UNDEFINED OUTPUT GRID
32   INVALID BUDGET METHOD PARAMETERS

iplib.tar
Library contains subroutines to be used for
interpolating almost any grids used at NCEP. (Fortran90)
Date posted: 2/22/2007

```