      SUBROUTINE GCMTYM2(IDAY,KOUNT,NDAYS,NSECS,   KFINAL,KTOTAL, 
     1                  DELT,INCD,LDAY,SEC2)
C
C     * JUN 16/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     * NOV 22/94 - F.MAJAESS. - PREVIOUS VERSION GCMTYMC.

C     * IDAY = DAY OF THE YEAR
C     * KOUNT = CURRENT TIMESTEP NUMBER 
C     * NDAYS = NUMBER OF DAYS ELAPSED SINCE THE START (KOUNT=0). 
C     * NSECS = NUMBER OF SECONDS ELAPSED IN THE CURRENT DAY. 
C     * KFINAL,KTOTAL = LAST STEP NUMBER OF THIS JOB,RUN. 
C     * DELT = MODEL TIMESTEP LENGTH (SECONDS). 
C     * INCD = IDAY PROGRESS SWITCH.
C     * LDAY = DATE OF NEXT AVAILABLE PHYSICS GRIDS.
C     * SEC2 = CURRENT C.P. CLOCK TIME
C
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)

      REAL*4 TARRAY(4)
      CHARACTER*3 MONTH
      COMMON /KEEPTIM/ IYEAR,IYMDH,MYRSSTI,ISAVDTS
C-------------------------------------------------------------------- 
C     * CALCULATE "OLD" VALUE OF HOUR.
C     * INCREMEMT KOUNT BY 1 AND NSECS BY DELT. 
C
      IHHOLD=NSECS/3600 
      JUMPD=0
      KOUNT=KOUNT+1 
      NSECS=NSECS+INT(DELT) 
C 
C     * IF THE DAY CHANGES, INCREMENT NDAYS AND RESET NSECS.
C     * IDAY AND IYMDH ARE THEN INCREMENTED IF INCD IS NOT ZERO.
C     * THERE ARE 86400 SECONDS IN ONE DAY. 
C
      IMOPREV=(IYMDH-1000000*IYEAR)/10000  
      IF(NSECS.LT.86400) GO TO 210
      NUSECS=MOD(NSECS,86400) 
      JUMPD=(NSECS-NUSECS)/86400
      NSECS=NUSECS
      NDAYS=NDAYS+JUMPD 
      IF(INCD.NE.0)                                        THEN
          IDAY  = IDAY+JUMPD 
      ENDIF
C
C     * HANDLE END-OF-YEAR CASE, BASED ON "MYRSSTI".
C
      IF(IDAY.GT.365)                                      THEN      
          IDAY=MOD(IDAY,365)
          IMO=1
          IYEAR=IYEAR+1
          IHH=NSECS/3600
          IYMDH=1000000*IYEAR + 10000*IMO + 100*IDAY + IHH
          IHHOLD=IHH
          JUMPD=0
          WRITE(6,6030) IYEAR,IYMDH
      ENDIF
C
C     * INCREMENT IYMDH FOR POSSIBLE CHANGE IN HOUR.
C     * PRINT THE CURRENT TIME INFORMATION. 
C 
  210 HOUR=FLOAT(NSECS)/3600. 
      IHH=NSECS/3600
      IYMDH=IYMDH + 100*JUMPD + (IHH-IHHOLD)
C     SEC1=SEC2 
C     CALL CLOCK(SEC2) 
C     CPSEC=SEC2-SEC1 
      SEC2=DTIME(TARRAY)
      CPSEC=TARRAY(1)
      SYSEC=TARRAY(2)
      SEC2=CPSEC+SYSEC
      CALL IDATEC(MONTH,MDAY,IDAY) 
      WRITE(6,6010) KOUNT,NDAYS,CPSEC,IDAY,MONTH,MDAY,HOUR
C 
C     * IF IDAY INCREMENTS TO LDAY THE MODEL MUST GET 
C     * NEW PHYSICS FIELDS BEFORE IT CAN PROCEED. 
C 
      IF(INCD.EQ.0) RETURN
      IF(IDAY.NE.LDAY) RETURN 
      WRITE(6,6020) IDAY
      IF(IDAY.NE.1)                  THEN
C
C        * NEW MONTH BOUNDARY SO IYMDH MUST BE INCREMENTED BY 1.
C        * DON'T DO IF JAN 1, SINCE ALREADY DONE IN RE-SETTING ABOVE.
C
         IMO=IMOPREV+1
         IDD=1
         IHH=NSECS/3600   
         IYMDH=1000000*IYEAR + 10000*IMO + 100*IDD + IHH
         WRITE(6,6040) IYMDH
      ENDIF
      RETURN
C-------------------------------------------------------------------- 
 6010 FORMAT(' ---KOUNT =',I7,'  NDAYS =',I6,'  CP SEC= ',F7.2,
     1       3X,'IDAY =',I6,49X,A3,I3,F8.2,' HRS')
 6020 FORMAT('0*** NEW PHYSICS FIELDS REQUIRED FOR DAY',I6)
 6030 FORMAT('0NEW IYEAR,IYMDH = ',I5,5X,I10)
 6040 FORMAT('0NEW IYMDH = ',I10)
      END 
