SUBROUTINE GRID2XY

Fortran version:

"Generic" Fortran-90 routine to convert grid cell-centers to a different map projection, with optional SPHER1, SPHER2 spheroid arguments:
    SUBROUTINE GRID2XY( GDTYP_O, P_ALP_O, P_BET_O, P_GAM_O, XCENT_O, YCENT_O, SPHER_O,  &
                        GDTYP_I, P_ALP_I, P_BET_I, P_GAM_I, XCENT_I, YCENT_I, SPHER_I,  &
                        NCOLS_I, NROWS_I, XORIG_I, YORIG_I, XCELL_I, YCELL_I,           &
                        XLOC_O, YLOC_O )

    SUBROUTINE GRID2XY( GDTYP_O, P_ALP_O, P_BET_O, P_GAM_O, XCENT_O, YCENT_O,           &
                        GDTYP_I, P_ALP_I, P_BET_I, P_GAM_I, XCENT_I, YCENT_I,           &
                        NCOLS_I, NROWS_I, XORIG_I, YORIG_I, XCELL_I, YCELL_I,           &
                        XLOC_O, YLOC_O )
    SUBROUTINE BNDY2XY( GDTYP_O, P_ALP_O, P_BET_O, P_GAM_O, XCENT_O, YCENT_O, SPHER_O,  &
                        GDTYP_I, P_ALP_I, P_BET_I, P_GAM_I, XCENT_I, YCENT_I, SPHER_I,  &
                        NCOLS_I, NROWS_I, NTHIK_I, XORIG_I, YORIG_I, XCELL_I, YCELL_I,  &
                        XLOC_B, YLOC_B )

    SUBROUTINE BNDY2XY( GDTYP_O, P_ALP_O, P_BET_O, P_GAM_O, XCENT_O, YCENT_O,           &
                        GDTYP_I, P_ALP_I, P_BET_I, P_GAM_I, XCENT_I, YCENT_I,           &
                        NCOLS_I, NROWS_I, NTHIK_I, XORIG_I, YORIG_I, XCELL_I, YCELL_I,  &
                        XLOC_B, YLOC_B )

        INTEGER, INTENT(IN   ) :: GDTYP_O, GDTYP_I
        INTEGER, INTENT(IN   ) :: NCOLS_I, NROWS_I        !!  dimensions for GRID_I
        REAL*8 , INTENT(IN   ) :: SPHER_O, SPHER_I        !!  input, output spheres
        REAL*8 , INTENT(IN   ) :: P_ALP_O, P_BET_O, P_GAM_O, XCENT_O, YCENT_O
        REAL*8 , INTENT(IN   ) :: P_ALP_I, P_BET_I, P_GAM_I, XCENT_I, YCENT_I
        REAL*8 , INTENT(IN   ) :: XORIG_I, YORIG_I, XCELL_I, YCELL_I
        REAL*8 , INTENT(  OUT) :: XLOC_O( NCOLS_I,NROWS_I )     !!  GRID_O coords for
        REAL*8 , INTENT(  OUT) :: YLOC_O( NCOLS_I,NROWS_I )     !!  GRID_I grid-cell centers
        REAL*8 , INTENT(  OUT) :: XLOC_B( 2*NTHIK_I*(NCOLS_I+NROWS_I+2*NTHIK_I) )     !!  ... boundary-cell centers
        REAL*8 , INTENT(  OUT) :: YLOC_B( 2*NTHIK_I*(NCOLS_I+NROWS_I+2*NTHIK_I) )     !!  

Summary:

Compute locations <XLOC_O_O,YLOC_O> for all (input) GRID_I grid-cell or boundary-cell centers relative to the coordinate system for (output) GRID_O using USGS GCTP-package routine GTPZ0(). The usual I/O API coordinate-description conventions are used for the GDTYP,P_ALP,P_BET,P_GAM,XCENT,YCENT input and output coordinate description arguments.

Versions without the spheroid arguments use routine INITSPHERES() (controlled by environment variable IOAPI_ISPH) to determine the spheroid used by the map projections; the two-spheroid-argument versions should be used for transformations for which the input map projection uses a different spheroid from the output map projection (in which case, the tramsform must be implemented "behind the scenes" as a two-stage process: first, using the input spheroid, from input-projection coordinates to Lat-Lon; then, using the output spheroid, from Lat-Lon to the output-projection coordinates).

NOTE: The GRID_I-vs-GRID_O issue for many uses is "backward" to the naive intuition: to interpolate data-grids from GRID_O to GRID_I, one needs to compute the locations of GRID_I-nodes relative to the GRID_O coordinate-and-grid system in order to compute the bilinear coefficients for those points—a coordinate transformation in the reverse of the direction of the data-interpolation.

For I/O API Version 3.2 or later, only: generic module-routine CONTAINed in MODULE MODGCTP.

See also Coordinate-coordinate conversion routines:

GCTP coordinate-transform package from USGS

GRID2INDX()/PNTS2INDX()/INDXMULT() "New" bilinear interpolation package from MODULE MODGCTP

XY2XY(): array-of-points coordinate transformation routine from MODULE MODGCTP

Preconditions

USE MODGCTGP

CALL INITSPHERES() or CALL SETSPHERE() before using.

Fortran Usage:

In addition to the example below, see also the example under BMATVEC() and BILIN() and the m3tools program mtxcalc for a full-program example.
    ...
    INTEGER     GDTYP_O      !!  parameters for output coordinate system
    REAL*8      P_ALP_O
    REAL*8      P_BET_O
    REAL*8      P_GAM_O
    REAL*8      XCENT_O
    REAL*8      YCENT_O
    INTEGER     GDTYP_I      !!  parameters for input grid and coord system
    INTEGER     NCOLS_I
    INTEGER     NROWS_I
    INTEGER     NTHIK_I
    REAL*8      P_ALP_I
    REAL*8      P_BET_I
    REAL*8      P_GAM_I
    REAL*8      XCENT_I
    REAL*8      YCENT_I
    REAL*8      XORIG_I
    REAL*8      YORIG_I
    REAL*8      XCELL_I
    REAL*8      YCELL_I
    ...
    REAL*8      XGRID_O( NCOLS_I,NROWS_I )
    REAL*8      YGRID_O( NCOLS_I,NROWS_I )
    ...
    CALL GRID2XY( GDTYP_O, P_ALP_O, P_BET_O, P_GAM_O, XCENT_O, YCENT_O,     &
                  GDTYP_I, P_ALP_I, P_BET_I, P_GAM_I, XCENT_I, YCENT_I,     &
                  NCOLS_I, NROWS_I, XORIG_I, YORIG_I, XCELL_I, YCELL_I,     &
                  XGRID_O, YGRID_O )
    ...
    

See also:

GCTP coordinate transformation routine from USGS

MODULE MODGCTP

GRID2INDX()/PNTS2INDX()/INDXMULT(): Bilinear-interpolation package in MODULE MODGCTP

XY2XY(): array-of-points coordinate transformation routinee in MODULE MODGCTP

UNGRIDB() and BILIN()/BMATVEC() "old" bilinear interpolation packages


Up: MODULE MODGCTP

Up: Coordinate and Grid Related Routines

To: Models-3/EDSS I/O API: The Help Pages