      SUBROUTINE GCMTYM2X(IDAY,KOUNT,NDAYS,NSECS,KFINAL,KTOTAL, 
     1                    DELT,INCD,LDAY,SEC2)
C
C     * MAY 24/17 - M.LAZARE.  FOR CONVERSION TO XC40:
C     *                        - REPLACE "DTIME" BY "CPU_TIME".
C     * JUN 28/04 - L.SOLHEIM. EXPAND NUMBER OF DIGITS FOR PRINTOUT OF
C     *                        KOUNT.
C     * SEP 23/03 - M.LAZARE. ADD "MPINFO" COMMON BLOCK TO CONTROL ONLY
C     *                       WRITING TO STANDARD OUTPUT ON NODE 0. 
C     * JUN 16/95 - M.LAZARE.  - PREVIOUS VERSION GCMTYMC2.
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)
      INTEGER*4 MYNODE 
      CHARACTER*3 MONTH

      COMMON /MPINFO/ MYNODE
      COMMON /KEEPTIM/ IYEAR,IMDH,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 IMDH ARE THEN INCREMENTED IF INCD IS NOT ZERO.
C     * THERE ARE 86400 SECONDS IN ONE DAY. 
C
      IMOPREV=IMDH/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
          IMDH=10000*IMO + 100*IDAY + IHH
          IHHOLD=IHH
          JUMPD=0
          IF(MYNODE.EQ.0) WRITE(6,6030) IYEAR,IMDH
      ENDIF
C
C     * INCREMENT IMDH FOR POSSIBLE CHANGE IN HOUR.
C     * PRINT THE CURRENT TIME INFORMATION. 
C 
  210 HOUR=FLOAT(NSECS)/3600. 
      IHH=NSECS/3600
      IMDH=IMDH + 100*JUMPD + (IHH-IHHOLD)
C     SEC1=SEC2 
C     CALL CLOCK(SEC2) 
C     CPSEC=SEC2-SEC1 
C     SEC2=DTIME(TARRAY)
C     CPSEC=TARRAY(1)
C     SYSEC=TARRAY(2)
C     SEC2=CPSEC+SYSEC
      call flush(6)
      SEC1=SEC2
      call cpu_time(sec2)
      CPSEC=SEC2-SEC1
C     write(6,*) 'gcmtym2x-aftr- MYNODE,SEC1,SEC2,CPSEC=',
C    +    MYNODE,SEC1,SEC2,CPSEC
      call flush(6)
      CALL IDATEC(MONTH,MDAY,IDAY) 
      IF(MYNODE.EQ.0)                                      THEN  
          WRITE(6,6010) KOUNT,NDAYS,CPSEC,IDAY,MONTH,MDAY,HOUR
      ENDIF
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 
      IF(MYNODE.EQ.0) WRITE(6,6020) IDAY
      IF(IDAY.NE.1)                  THEN
C
C        * NEW MONTH BOUNDARY SO IMDH 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   
         IMDH=10000*IMO + 100*IDD + IHH
         IF(MYNODE.EQ.0) WRITE(6,6030) IYEAR,IMDH
      ENDIF
      RETURN
C-------------------------------------------------------------------- 
 6010 FORMAT(' ---KOUNT =',I9,'  NDAYS =',I9,'  CP SEC= ',F7.2,
     1       3X,'IDAY =',I4,49X,A3,I3,F8.2,' HRS')
 6020 FORMAT('0*** NEW PHYSICS FIELDS REQUIRED FOR DAY',I6)
 6030 FORMAT('0NEW IYEAR,IMDH = ',I5,5X,I6)
      END 
