      SUBROUTINE GGIGG(UG,VG,ILG1,ILG,ILAT,SLON,SLAT,
     1                 UL,VL,NLG1,NLG,NLAT,DLON,DLAT,
     2                 INTERP,IFLD)
C
C     * MAR 25/13 - S.KHARIN
C
C     * BI-LINEAR OR CUBIC INTERPOLATION OF SCALAR OR VECTOR FIELDS
C     * FROM ONE GRID TO ANOTHER.
C
C     * UG,VG         = INPUT FIELDS.
C     * ILG1,ILG,ILAT = DIMENSIONS OF INPUT GRIDS.
C     *                 ILG1=ILG+1 IF THERE IS CYCLIC LONG.
C                       OTHERWISE ILG1=ILG.
C     * SLON          = LON (DEG) OF INPUT GRID COLUMNS.
C     * SLAT          = LAT (DEG) OF INPUT GRID ROWS.
C     * UO,VO         = OUTPUT FIELDS.
C     * NLG1,NLG,NLAT = DIMENSIONS OF OUTPUT GRID.
C     * DLON          = LON (DEG) OF OUTPUT GRID COLUMNS.
C     * DLAT          = LAT (DEG) OF OUTPUT GRID ROWS.
C     * WO            = AREA FRACTION WITH NON-MISSING VALUES.
C     * INTERP        = 1: BI-LINEAR INTERPOLATION.
C                     = 3: BI-CUBIC INTERPOLATION.
C                       (THESE ARE THE ONLY VALID OPTIONS)
C     * IFLD          = 0 UG IS SCALAR FIELD.
C                     = 1 UG IS VECTOR COMPONENT.
C                     = 2 UG,VG ARE VECTOR-FIELD COMPONENTS.
C
C     * RETURN SPVAL=1.E+38 IF ANY OF NEIGHBOURS EQUALS 1.E+38.
C
      IMPLICIT NONE
      REAL USP,VSP,UNP,VNP,U,V
      INTEGER ILG,ILG1,ILAT,NLG,NLG1,NLAT,INTERP,IFLD,I,J,
     1     LUSP,LVSP,LUNP,LVNP
      REAL UG(ILG1,ILAT),VG(ILG1,ILAT),UL(NLG1,NLAT),VL(NLG1,NLAT)
      REAL SLAT(ILAT),SLON(ILG1),DLAT(NLAT),DLON(NLG1)
      REAL SPVAL,SPVALT
      DATA SPVAL/1.E+38/,SPVALT/1.E+32/
C-----------------------------------------------------------------------
      IF(INTERP.NE.1.AND.INTERP.NE.3) CALL         XIT('GGIGG',-1)
      IF(IFLD.LT.0.OR.IFLD.GT.2) CALL              XIT('GGIGG',-2)
C
C     * CHECK FOR SPVAL AT THE LATITUDES CLOSEST TO THE POLES

      LUSP=0
      LUNP=0
      LVSP=0
      LVNP=0
      DO I=1,ILG
        IF(UG(I,   1).EQ.SPVAL)LUSP=LUSP+1
        IF(UG(I,ILAT).EQ.SPVAL)LUNP=LUNP+1
      ENDDO
      IF(IFLD.EQ.2)THEN
        DO I=1,ILG
          IF(VG(I,   1).EQ.SPVAL)LVSP=LVSP+1
          IF(VG(I,ILAT).EQ.SPVAL)LVNP=LVNP+1
        ENDDO
      ENDIF
C
C     * ESTIMATE VALUES AT THE POLES FROM THE CLOSEST LATITUDES
C
      IF(LUSP.EQ.0.AND.LVSP.EQ.0)THEN
        CALL UVWAVE(UG(1,1),VG(1,1),SLON,ILG,-1,USP,VSP,IFLD)
      ELSE
        USP=SPVAL
        VSP=SPVAL
      ENDIF
      IF(LUNP.EQ.0.AND.LVNP.EQ.0)THEN
        CALL UVWAVE(UG(1,ILAT),VG(1,ILAT),SLON,ILG,1,UNP,VNP,IFLD)
      ELSE
        UNP=SPVAL
        VNP=SPVAL
      ENDIF
C
C     * APPLY THE REQUESTED INTERPOLATION FOR EACH OUTPUT GRID POINT...
C
      DO J=1,NLAT
        DO I=1,NLG
          IF(INTERP.EQ.1.OR.
     1       DLAT(J).LE.SLAT(1).OR.DLAT(J).GE.SLAT(ILAT))THEN
C
C           * BI-LINEAR INTERPOLATION (ALWAYS NEAR THE POLES)
C
            CALL GGPNL3(U,V,UG,VG,ILG,ILG1,ILAT,DLON(I),DLAT(J),
     1                  SLON,SLAT,USP,VSP,UNP,VNP,IFLD)
          ELSE
C
C           * CUBIC INTERPOLATION
C
            CALL GGPNT3(U,V,UG,VG,ILG,ILG1,ILAT,DLON(I),DLAT(J),
     1                  SLON,SLAT,USP,VSP,UNP,VNP,IFLD)
          ENDIF
          UL(I,J)=U
          VL(I,J)=V
        ENDDO
        IF (NLG1.NE.NLG) THEN
          UL(NLG1,J)=UL(1,J)
          VL(NLG1,J)=VL(1,J)
        ENDIF
      ENDDO
      RETURN
      END
