clever folks, grid subsetting / extracting

Clever folks,

Is there an algorithm, or known method to extract a subset of one grid
to match another. I have two grids, one nested, the other global. In
general they are regular lat/lon grids. Also, in general they are 0.5
degree lat/lon. However, I would like to make this as general as
possible.

What I am trying to accomplish is the following:
A) to have a function where I pass the two grids and meta data about
the grids (lon0, lat0, dx, numx, dy, numy, etc). Then, a subsection of
the global grid is returned that matches the nested grid.

B) in a more general case, I may have to define a regrid function so
that the subset of the global grid could match the nested grid.

Suggestions?