      SUBROUTINE GETGT6 (NF,GTPAK,GTPAL, NPPS,NLON,NLAT,
     1                  GCPAK,GCROW,GTROW,GTROL,NPGG, 
     2                  INCD,IDAY,MDAY,KOUNT,GG)
C 
C     * JUN 15/95 - M.LAZARE. INCLUDE OPTION "MYRSSTI" VIA COMMON
C     *                       BLOCK "KEEPTYM", TO DO AMIP-LIKE RUNS. 
C     *                       SIMILARILY OPTION "ISAVDTS" TO SAVE
C     *                       GCM OUTPUT IN "yyyymmddhh" FORMAT.
C     * OCT 11/87 - M.LAZARE. PREVIOUS VERSION GETGT5.
C
C     * READ IN GROUND TEMPERATURE FIELD(S).
C     * TIME LABEL IS THE JULIAN DATE OF THE FIRST OF THE MONTH 
C     * (NFDM) FOR WHICH THE SST ARE THE MONTHLY AVERAGE. 
C     * WHEN THE MODEL IS MOVING THROUGH THE YEAR (INCD.NE.0),
C     * THEN NEW SST ARE READ ON EVERY MID MONTH DAY (MMD), 
C     * AND INTERPOLATION WILL BE DONE BETWEEN THE TWO ADJACENT 
C     * MID MONTH DAYS. GTPAK IS THE PRECEDENT, GTPAL THE FOLLOWING.
C     * WHEN GCM IS RUN IN TANDEM WITH OCEAN MODEL, SET IOCEAN TO 
C     * GIVE THE DISTANCE (IN DAYS) OF THE TARGET DATE FOR ACCESSING
C     * NEW OCEAN TEMPERATURE (MDAY). 
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)

      REAL GTPAK(1),GTROW(1),GTPAL(1),GTROL(1),GCPAK(1),GCROW(1)
      REAL GG(1)
      INTEGER NFDM(12),MMD(12)
      COMMON /KEEPTIM/ IYEAR,IYMDH,MYRSSTI,ISAVDTS
C 
      DATA NFDM/  1, 32, 60, 91,121,152,182,213,244,274,305,335/
      DATA  MMD/ 16, 46, 75,106,136,167,197,228,259,289,320,350/
C----------------------------------------------------------------------
C     * VALUE TO SEARCH FOR IN IBUF(2) IS DEPENDANT ON WHETHER RUN
C     * IS USING STANDARD BOUNDARY FORCING OR MULTI-YEAR CONDITIONS.
C 
      IMO=(IYMDH-(1000000*IYEAR))/10000
      IF(IMO.NE.12)                          THEN
        IMOT=IMO+1
        IYRMOT=1000000*IYEAR + 10000*IMOT + 100
      ELSE
        IMOT=1
        IYRMOT=(IYEAR+1)*1000000 + 10000*IMOT + 100
      ENDIF
C
      IF(INCD.EQ.0) THEN
C       * 
C       * MODEL IS STATIONARY.
C       * ABORT IF RUNNING AMIP-LIKE EXPERIMENT.
C
        IF(MYRSSTI.NE.0)           CALL XIT('GETGT6',-1)
        IF(KOUNT.EQ.0) THEN 
C         * 
C         * START-UP TIME. READ-IN GT FOR AVERAGE OF MONTH. 
C         * 
          MDAY=IDAY 
          CALL GETAGB(GTPAK,NPPS,NC4TO8("  GT"),NF,NLON,NLAT,IDAY,GG)
          RETURN
        ELSE
C         * 
C         * NOT A NEW INTEGRATION. NO NEW FIELD REQUIRED. 
C         * 
          RETURN
        ENDIF 
      ELSE
C       * 
C       * THE MODEL IS MOVING.
C       * 
        IF(KOUNT.EQ.0) THEN 
C         * 
C         * START-UP TIME. GET GT FOR PREVIOUS AND FOLLOWING MID MONTH DAYS.
C         * NOTE THAT FOR MULTI-YEAR SST/ICE RUNS, NO "PREVIOUS" CONDITIONS
C         * EXIST SO THAT START CONDITIONS HELD CONSTANT THROUGH FIRST
C         * HALF-MONTH.
C         * 
          L=0 
          DO 150 N=1,12 
          IF(IDAY.GE.MMD(N)) L=N+1
  150     CONTINUE
          IF(L.EQ.0.OR.L.EQ.13) L=1 
          MDAY=MMD(L) 
          WRITE(6,6020) MDAY
          IF(MYRSSTI.EQ.0)     THEN
            JOUR=NFDM(L)
            L1=L-1
            IF(L1.EQ.0) L1=12 
            JOUR1=NFDM(L1)
            MDAY1=MMD(L1) 
            CALL GETAGB(GTPAK,NPPS,NC4TO8("  GT"),NF,NLON,NLAT,JOUR1,GG)
            CALL GETAGB(GTPAL,NPPS,NC4TO8("  GT"),NF,NLON,NLAT,JOUR ,GG)
            CALL INTGT (GTPAK,GTPAK,GTPAL,GCPAK,GTROW,GTROL,GCROW,
     1                  NPPS,NPGG,NLON-1,NLAT,MDAY1,IDAY,MDAY,GG) 
          ELSE  
            CALL GETAGB(GTPAK,NPPS,NC4TO8("  GT"),NF,NLON,NLAT,IYMDH,GG)
            CALL GETAGB(GTPAL,NPPS,NC4TO8("  GT"),NF,NLON,NLAT,IYMDH,GG)
          ENDIF
          RETURN
        ELSE
C         * 
C         * THIS IS IN THE MIDDLE OF A RUN. 
C         * 
          IF(IDAY.EQ.MDAY) THEN 
            WRITE(6,6010) 
C           * 
C           * TIME TO GET NEW SST FOR NEXT MID-MONTH DAY. 
C           * 
            M=0 
            DO 250 N=1,12 
            IF(IDAY.EQ.MMD(N)) M=N+1
  250       CONTINUE
            IF(M.EQ.13) M=1 
            IF(M.EQ.0)  CALL XIT('GETGT6',-2) 
            MDAY=MMD(M) 
            JOUR=NFDM(M)
            WRITE(6,6020) MDAY
            IF(MYRSSTI.EQ.0)     THEN
              MBUF2=JOUR
            ELSE
              MBUF2=IYRMOT
            ENDIF
            CALL GETAGB(GTPAL,NPPS,NC4TO8("  GT"),NF,NLON,NLAT,MBUF2,GG)
            RETURN
          ELSE
C           * 
C           * NOT YET TIME TO READ NEW SST. 
C           * 
            RETURN
          ENDIF 
        ENDIF 
      ENDIF 
C---------------------------------------------------------------------
 6010 FORMAT('0    NEW SST REQUIRED') 
 6020 FORMAT('0    MDAY RESET TO',I6)
      END 
