      PROGRAM SLGCMN
Status: R

C
C*********************************************************************
C*********************** SLGCM   MODEL *******************************
C*********************  PROGRAM  SLGCMN  *****************************
C********************** 06 OCTOBER 1989 ******************************
C*********************************************************************
C
C
      PRINT *,' *****************************************************'
      PRINT *,' ************** SLGCM VERSION 1 :  10/06/89 ***********'
      PRINT *,' *****************************************************'
      PRINT *,'                                                      '
      PRINT *,'  - UNITS DEFINED BY THE MODEL  - - - - - - - -       '
      PRINT *,'                                                      '
      PRINT *,'                                                      '
      PRINT *,'                                                      '
      PRINT *,'- - SLGCM ARGUMENTS - - - - - - - - -- - - - -        '
      PRINT *,'                                                      '
      PRINT *,'       DT: INTEGER TIMESTEP IN SECONDS.               '
      PRINT *,'                                                      '
      PRINT *,'                                                      '
      PRINT *,'   OUTPUT: EXTERNAL NAME OF USER SUPPLIED OUTPUT      '
      PRINT *,'           ROUTINE.                                   '
      PRINT *,'                                                      '
      PRINT *,'      KRS: UNIT NUMBER OF RE-START                    '
      PRINT *,'                                                      '
      PRINT *,'                                                      '
      PRINT *,'      TAU: CURRENT TIME IN SECONDS                    '
      PRINT *,'                                                      '
      PRINT *,' CALL SLGCM(DT, KRS, OUTPUT, TAU)'
      PRINT *,'                                                      '
C
      CALL CONSL
      CALL INPUT
C
      STOP
      END
      SUBROUTINE SLGCM(DT, RDHOUR, SEASNL, DIURNL, KRS
     *,                            ADIBAT, OUTPUT, RSFLG, SHFTR)
C
#include "slgcm.slgprm"
#include "slgcm.slclok"
C
C*********************************************************************
C*********************** SLGCM   MODEL *******************************
C********************* SUBROUTINE SLGCM  *****************************
C********************** 05 AUGUST  1992 ******************************
C*********************************************************************
C
C
C
      INTEGER  DT, RDHOUR, CHECK
      EXTERNAL OUTPUT
      DOUBLE PRECISION TAU
      LOGICAL RSFLG, SEASNL, DIURNL, ADIBAT, SHFTR, FIRST

C
      RDT      = DT
      MYTIME   = 0.0
      SLAGTIME = 0.0
      OUTPTIME = 0.0
      MGSLTIME = 0.0
      JOBTIME  = 0.0
      KPRTIM   = 0.0
      CONVTIME = 0.0
      RDTNTIME = 0.0
C
C
      CALL CLKON
C
C
      PRINT *, '    TIME STEP WILL BE ',DT,' SECS.'
      IF (.NOT. ADIBAT) THEN
         CHECK = SETALARM(16,RDHOUR*3600)
         PRINT *, '  RADIATION WILL BE CALLED EVERY ',CHECK,' SECS.'
      ENDIF
C
      CALL RESTRD(KRS,SHFTR)
C
c     IF (SHFTR) THEN
c        TAU = CTIME() + DT
c        PRINT *,' setting time from tau=',tau,' to tau=',settime(tau)
c     ENDIF
      CALL CONDT(DT)

      CALL GETBCS(SEASNL)
      IF (.NOT. ADIBAT) THEN
         CALL RDTNML(DIURNL,SEASNL,RDHOUR)
         CALL CLRCLD
      ENDIF
C
      FIRST = .TRUE.
100   CONTINUE
C
      CALL CLKON
C
C CALL THE MAIN LOOP
C
      CALL SLGCST(RDT, RSFLG, .FALSE., FIRST, TAU, DIURNL, SEASNL)
      CALL CLKOFF(SLAGTIME)
C
      MYTIME  = MYTIME + DT
      CHECK = TOCK(RDT)
C
      IF (CUCKOO()) THEN
         CALL CLKON
         CALL OUTPUT(*101)
         CALL CLKOFF(OUTPTIME)
      ENDIF
C
      IF (.NOT. ADIBAT) THEN
         IF (ALARM(16)) THEN
            CALL GETBCS(SEASNL)
            CALL RDTNML(DIURNL,SEASNL,RDHOUR)
            CALL CLRCLD
         ENDIF
      ENDIF

C
      GO TO 100
C
101   CALL CLKOFF(OUTPTIME)
      CALL CLKOFF(JOBTIME)
C
C    TIMINGS
C
      DAYS     = FLOAT(MYTIME)/DAYLEN
      PRINT *, MYTIME,DAYS,JOBTIME,SLAGTIME,OUTPTIME,MGSLTIME
      JOBTIME  =  JOBTIME / DAYS
      SLAGTIME = SLAGTIME / DAYS
      OUTPTIME = OUTPTIME / DAYS
      MGSLTIME = MGSLTIME / DAYS
      KPRTIM   = KPRTIM   / DAYS
      RDTNTIME = RDTNTIME / DAYS
      CONVTIME = CONVTIME / DAYS
C
      OVERHEAD =  JOBTIME - OUTPTIME - SLAGTIME - RDTNTIME
      DYNAMICS = SLAGTIME - CONVTIME
      WRITE(6,1000) JOBTIME, OVERHEAD, OUTPTIME, SLAGTIME, MGSLTIME
     *,             KPRTIM,  RDTNTIME, CONVTIME, DYNAMICS
C
1000  FORMAT(//,' TOTAL JOB TIME =',      F12.5
     *,      //,'     OVERHEAD   =', 12X, F12.5
     *,       /,'       OUTPUT   =', 12X, F12.5
     *,       /,'     SLAGTIME   =', 12X, F12.5
     *,       /,'     MGSLTIME   =', 12X, F12.5
     *,       /,'     KPRTIM    =', 12X, F12.5
     *,       /,'    RDTNTIME    =', 12X, F12.5
     *,       /,'     CONVTIME    =', 12X, F12.5
     *,       /,'     DYNAMICS    =', 12X, F12.5)
C
      RETURN
      END
      SUBROUTINE SLGCMF(DT, RDHOUR, SEASNL, DIURNL, KRS
     *,                ADIBAT, OUTPUT, RSFLG, SHFTR, KRSF, ITAUF)
C
#include "slgcm.slgprm"
#include "slgcm.slclok"
C
C*********************************************************************
C*********************** SLGCM   MODEL *******************************
C********************* SUBROUTINE SLGCM  *****************************
C********************** 05 AUGUST  1992 ******************************
C*********************************************************************
C
C
C
      INTEGER  DT, RDHOUR, CHECK
      EXTERNAL OUTPUT
      DOUBLE PRECISION TAU
      LOGICAL RSFLG, SEASNL, DIURNL, ADIBAT, SHFTR, FIRST

C
      RDT      = DT
      MYTIME   = 0.0
      SLAGTIME = 0.0
      OUTPTIME = 0.0
      MGSLTIME = 0.0
      JOBTIME  = 0.0
      KPRTIM   = 0.0
      CONVTIME = 0.0
      RDTNTIME = 0.0
C
C
      CALL CLKON
C
C
      PRINT *, '    TIME STEP WILL BE ',DT,' SECS.'
      IF (.NOT. ADIBAT) THEN
         CHECK = SETALARM(16,RDHOUR*3600)
         PRINT *, '  RADIATION WILL BE CALLED EVERY ',CHECK,' SECS.'
      ENDIF
C
C
      CALL RESTRD(KRS,SHFTR)
C
c     IF (SHFTR) THEN
c        TAU = CTIME() + DT
c        PRINT *,' setting time from tau=',tau,' to tau=',settime(tau)
c     ENDIF
c     print *,' in slgcmf:',' dt=',dt,' rdhour=',rdhour,'seasnl='
c    *,       seasnl,'diurnl=',diurnl,' krs=',krs,' krsf=',krsf
c    *,      ' adibat=',adibat,' itauf=',itauf
      CALL CONDT(DT)

      CALL GETBCS(SEASNL)
      IF (.NOT. ADIBAT) THEN
         CALL RDTNML(DIURNL,SEASNL,RDHOUR)
         CALL CLRCLD
      ENDIF
C
      FIRST = .TRUE.
100   CONTINUE
C
      CALL CLKON
C
C CALL THE MAIN LOOP
C
      CALL SLGCST(RDT, RSFLG, .FALSE., FIRST, TAU, DIURNL, SEASNL)
      CALL CLKOFF(SLAGTIME)
C
      MYTIME  = MYTIME + DT
      CHECK = TOCK(RDT)
C
      IF (CUCKOO()) THEN
         CALL CLKON
         CALL OUTPUT(DT, ITAUF, KRSF, *101)
         CALL CLKOFF(OUTPTIME)
      ENDIF
C
      IF (.NOT. ADIBAT) THEN
         IF (ALARM(16)) THEN
            CALL GETBCS(SEASNL)
            CALL RDTNML(DIURNL,SEASNL,RDHOUR)
            CALL CLRCLD
         ENDIF
      ENDIF
C
      GO TO 100
C
101   CALL CLKOFF(OUTPTIME)
      CALL CLKOFF(JOBTIME)
C
C    TIMINGS
C
      DAYS     = FLOAT(MYTIME)/DAYLEN
      PRINT *, MYTIME,DAYS,JOBTIME,SLAGTIME,OUTPTIME,MGSLTIME
      JOBTIME  =  JOBTIME / DAYS
      SLAGTIME = SLAGTIME / DAYS
      OUTPTIME = OUTPTIME / DAYS
      MGSLTIME = MGSLTIME / DAYS
      KPRTIM   = KPRTIM   / DAYS
      RDTNTIME = RDTNTIME / DAYS
      CONVTIME = CONVTIME / DAYS
C
      OVERHEAD =  JOBTIME - OUTPTIME - SLAGTIME - RDTNTIME
      DYNAMICS = SLAGTIME - CONVTIME
      WRITE(6,1000) JOBTIME, OVERHEAD, OUTPTIME, SLAGTIME, MGSLTIME
     *,             KPRTIM,  RDTNTIME, CONVTIME, DYNAMICS
C
1000  FORMAT(//,' TOTAL JOB TIME =',      F12.5
     *,      //,'     OVERHEAD   =', 12X, F12.5
     *,       /,'       OUTPUT   =', 12X, F12.5
     *,       /,'     SLAGTIME   =', 12X, F12.5
     *,       /,'     MGSLTIME   =', 12X, F12.5
     *,       /,'     KPRTIM    =', 12X, F12.5
     *,       /,'    RDTNTIME    =', 12X, F12.5
     *,       /,'     CONVTIME    =', 12X, F12.5
     *,       /,'     DYNAMICS    =', 12X, F12.5)
C
      RETURN
      END

