PUBLIC INTERFACE / ROUTINES / ERRORS / NOTES


module bgrid_change_grid_mod

     Contact:   Bruce Wyman
     Reviewers:
     Change history: WebCVS Log for bgrid_change_grid.f90


OVERVIEW


    Provides interfaces to interpolate data between the 
    four basic sub-grid locations on B-grid.

    The B-grid model has four basic sub-grids that correspond to
    temperature (TEMP), velocity (WIND), zonal mass flux (UFLX),
    and meridional mass flux (VFLX) grid points. The orientation of
    these points to each other for the same i,j can be depicted as:

                   VFLX(i,j)    WIND(i,j)

                   TEMP(i,j)    UFLX(i,j)

    The interpolation between the sub-grids is done using either
    a 4-pt or 2-pt averaging.  The averaging can use area-weighting
    or equal-weighting (a simple average). Overloaded interfaces
    can accommodate either one or two input fields.

    Not all grid changes are currently available, 
    see the notes section for details.


OTHER MODULES USED


    bgrid_horiz_mod
    fms_mod


PUBLIC INTERFACE


   use bgrid_change_grid_mod [,only:  change_grid,
                               TEMP_GRID, WIND_GRID,
                               UFLX_GRID, VFLX_GRID]

   change_grid
        Interpolates from sub-grid to another sub-grid.

  Public parameters that identify the four basic sub-grids:
 
      TEMP_GRID = temperature (mass) grid
      WIND_GRID = velocity (momentum) grid
      UFLX_GRID = zonal mass flux grid; grid points are located
                   between temperature points along the x-axis
      VFLX_GRID = meridional mass flux grid; grid points are located
                   between temperature points along the y-axis



PUBLIC ROUTINES



call change_grid ( Hgrid, grid_inp, grid_out, data_inp, data_out
                      [, weight, mask_inp] )
         OR

call change_grid ( Hgrid, grid_inp, grid_out, data_inp1, data_inp2,
                       data_out1, data_out2 [, weight, mask_inp] )

  INPUT
      Hgrid        horizontal grid constants [horiz_grid_type]
      grid_inp     grid identifier for the input grid
                     [integer]
      grid_out     grid identifier for the output grid
                     [integer]
      data_inp,
      data_inp1,
      data_inp2 = input data
                     [real, dimension(Hgrid%ilb:,Hgrid%jlb:)]
                     [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

   OUTPUT
      data_out,
      data_out1,
      data_out2 = output data
                     [real, dimension(Hgrid%ilb:,Hgrid%jlb:)]
                     [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

   OPTIONAL INPUT
      weight = integer flag that type of interpolation
                 weight=AREA for area weighting (the default) or
                 weight=EQUAL for simple 4-pt (or 2pt) averaging
      mask_inp = grid box mask (typically for step-coordinate model)
                     [real, dimension(Hgrid%ilb:,Hgrid%jlb:)]
                     [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

  NOTES

     1) Possible grid identifiers are: 
          TEMP_GRID = temperature (mass) grid
          WIND_GRID = velocity (momentum) grid
          UFLX_GRID = zonal mass flux grid; grid points are located
                      between temperature points along the x-axis
          VFLX_GRID = meridional mass flux grid; grid points are located
                      between temperature points along the y-axis
     2) Halo are not updated, see the notes section below.
     3) The input and output arrays may be the same since 
        temporary memory is used to compute the result.


ERROR MESSAGES


FATAL errors in change_grid

    invalid grid change specified
        The input and output grid identifiers must be set using the
        public module parameters: TEMP_GRID, WIND_GRID, UFLX_GRID, VFLX_GRID.
        Several grid conversions are not possible, refer to the notes section.

    invalid value of area_weight
        The optional input argument weight must be set to
        one of the public module parameters: AREA or EQUAL.

WARNING message in bgrid_change_grid

    optional mask argument not used for this type of grid interpolation
        The optional mask argument is not used with two-point interpolations.


KNOWN BUGS


     None.


NOTES


    The following are valid 4-pt interpolations:

         "grid_inp"  -->  "grid_out"

          WIND_GRID  -->  TEMP_GRID     (south & west halos not computed)
          TEMP_GRID  -->  WIND_GRID     (north & east halos not computed)
          VFLX_GRID  -->  UFLX_GRID     (south & east halos not computed)
          UFLX_GRID  -->  VFLX_GRID     (north & west halos not computed)

    The following are valid 2-pt interpolations:

          TEMP_GRID  -->  UFLX_GRID     (east  halo not computed)
          TEMP_GRID  -->  VFLX_GRID     (north halo not computed)

    The following have not been implemented.
    They are INVALID and will produce a FATAL error.

          WIND_GRID  -->  UFLX_GRID
          WIND_GRID  -->  VFLX_GRID
          VFLX_GRID  -->  TEMP_GRID
          VFLX_GRID  -->  WIND_GRID
          UFLX_GRID  -->  TEMP_GRID
          UFLX_GRID  -->  WIND_GRID


FUTURE PLANS


     Implement 2-pt interpolations that are currently not allowed.