-------------------------------------------------------
Set Filtering Limits on the Horizontal Domain (MSETDOM)
-------------------------------------------------------

The horizontal domain can be limited to match one of two map projections (polar 
stereographic, Lambert conformal conic) or it can be limited to a 
latitude/longitude rectangle.  Only stations within the domain will be returned.  
If one of the map projections is selected, any winds (of any form) returned by 
subsequent MGET* calls will be rotated to match the projection.  

If MSETDOM is not called, all available stations will be returned, regardless of 
their location.

MSETDOM can be called anytime after the first MINIT call has been made, and the 
settings will remain in effect for all datasets until a subsequent call to 
MSETDOM.


USAGE:    CALL MSETDOM (IDMTYPE,RPAR1,RPAR2,RPAR3,RPAR4,RPAR5,RPAR6,RPAR7,
                        IPAR1,IPAR2,STATUS)

  INPUT ARGUMENT LIST:

    IDMTYPE  - Integer   Domain Type:

                         0 - clear domain settings (don't filter stations)
                         1 - lat/lon corners (not a grid projection)
                         2 - polar stereographic grid
                         3 - Lambert conformal conic (secant or tangent)

                         * See note 1 for argument units


    If IDMTYPE = 1 (lat/lon corners):
    ---------------------------------

    RPAR1    - Real      Lower left latitude (Southwest)

    RPAR2    - Real      Lower left longitude

    RPAR3    - Real      Upper right latitude (Northeast)

    RPAR4    - Real      Upper right longitude

    RPAR5    - Real      Unused

    RPAR6    - Real      Unused

    RPAR7    - Real      Unused

    IPAR1    - Integer   Unused

    IPAR2    - Integer   Unused
 

    If IDMTYPE = 2 (polar stereographic):
    -------------------------------------
 
                         * See note 2 for an example
 
    RPAR1    - Real      Mesh length of grid box at true latitude

    RPAR2    - Real      Latitude of 1st grid pt (lower left)

    RPAR3    - Real      Longitude of 1st grid pt (lower left)

    RPAR4    - Real      Orientation of the grid, i.e., the longitude
                         value of the meridian which is parallel to the
                         Y-axis (or columns of the grid) along which
                         latitude increases as the Y-coordinate
                         increases (note the orientation longitude may,
                         or may not, appear within the particular grid)

    RPAR5    - Real      I-coordinate of pole (real, not integer index)

    RPAR6    - Real      J-coordinate of pole (real, not integer index)

    RPAR7    - Real      Latitude at which mesh length is true

    IPAR1    - Integer   Number of points along X-axis (i dimension)

    IPAR2    - Integer   Number of points along Y-axis (j dimension)
 

    If IDMTYPE = 3 (Lambert conformal):
    -----------------------------------
 
                         * See note 3 for an example
 
    RPAR1    - Real      Mesh length of grid box at "true" latitude 
                         (* see note 4)

    RPAR2    - Real      Latitude of 1st grid pt (lower left)

    RPAR3    - Real      Longitude of 1st grid pt (lower left)

    RPAR4    - Real      Orientation of the grid, i.e., the longitude
                         value of the meridian which is parallel to the
                         Y-axis (or columns of the grid) along which
                         latitude increases as the Y-coordinate
                         increases (note the orientation longitude may,
                         or may not, appear within the particular grid).
                         this is also the meridian (on the back side of
                         cone) along which the cut is made to lay the
                         cone flat.

    RPAR5    - Real      The first latitude from the pole at which the
                         cone cuts the spherical earth (* see note 4)

    RPAR6    - Real      The second latitude from the pole at which the 
                         cone cuts the spherical earth (* see note 4)

    RPAR7    - Real      Unused

    IPAR1    - Integer   Number of points along X-axis (I dimension)
                         (* see note 5)

    IPAR2    - Integer   number of points along Y-axis (J dimension)
                         (* see note 5)
 
  OUTPUT ARGUMENT LIST:

    STATUS   - Integer   0 - success, or error code


ERRORS:

  Error code       Error message
  -----------      -------------

    3005           No MADIS subsystem initialized
       7           Invalid domain type           (* see note 6)
       8           Invalid domain arguments      (* see note 7)


NOTES:

1.  Latitudes are in degrees North, longitudes are in degrees East, and the 
    grid mesh length is in meters.
 
2.  Example of polar stereographic arguments using AWIPS grid 202 
    (NATIONAL-CONUS):
 
       RPAR1   190500.0
       RPAR2   7.838
       RPAR3   -141.028
       RPAR4   -95
       RPAR5   33.0
       RPAR6   45.0
       RPAR7   60.0
       IPAR1   65
       IPAR2   43
 
3.  Example of Lambert conformal arguments using AWIPS grid 212
    (REGIONAL-CONUS-DOUBLE RESOLUTION):
 
       RPAR1   40635.25
       RPAR2   12.19
       RPAR3   -133.459
       RPAR4   -95.0
       RPAR5   25.0
       RPAR6   25.0
       IPAR1   185
       IPAR2   129
 
4.  If RPAR5 = RPAR6, a tangent cone is used, and the grid mesh length is true 
    at that latitude.  If RPAR5 .ne. RPAR6, a secant cone is used.  Note that 
    this is done by calculating the tangent equivalent of the secant, using the 
    M_EQVLAT function (see that routine for a reference).  This means that the 
    grid mesh is true at the latitude returned from M_EQVLAT and *not* true at 
    either RPAR5 or RPAR6.  Therefore, any official GRIB grid using a secant cone 
    (RPAR5 .ne. RPAR6) will be slightly distorted when using the MADIS library.  
    Also note, however, that all the Lambert conformal grids produced by NCEP 
    use a tangent cone (RPAR5 = RPAR6).  Finally, note that this code hasn't 
    been tested with RPAR5 and RPAR6 on opposite sides of the equator.
 
5.  The (I,J) of the grid goes from (1-IPAR1,1-IPAR2), where I is the 
    X-dimension, with longitude going from West to East, and J is the 
    Y-dimension, with latitude going from South to North; e.g., (1,1) is the 
    lower-left or Southwest corner, and (IPAR1,IPAR2) is the upper-right or 
    Northeast corner.  This is true anywhere on the globe.
 
6.  Invalid domain type:

       IDMTYPE < 0 or > 3
 
7.  Invalid domain arguments:

       IDMTYPE 1  - Lower left latitude is East of upper right latitude
                  - Lower left longitude is North of upper right latitude
                  - Invalid lat/lon value (e.g., -999.0)
 
       IDMTYPE 2  - Invalid lat/lon value
                  - Negative grid mesh length of I,J dimension
 
       IDMTYPE 3  - RPAR5 = -RPAR6
                  - RPAR6 is closer to pole than RPAR5
                  - Invalid lat/lon value
                  - Negative grid mesh length of I,J dimension
 









