*DECK BIO04
      SUBROUTINE INITAL
C...
C...  GLUCOSE TOLERANCE TEST
C...
C...  THE GLUCOSE TOLERANCE TEST IS USED CLINCICALLY TO EVALUATE THE
C...  ABILITY OF THE PANCREAS TO RELEASE INSULIN IN RESPONSE TO A LARGE
C...  DOSE OF GLUCOSE GIVEN EITHER ORALLY OR INTRAVENEOUSLY.  THE NORMAL
C...  PANCREAS  RELEASES ENOUGH INSULIN TO LOWER THE PLASMA GLUCOSE
C...  WITHIN A FEW HOURS, SOMETIMES TO THE POINT OF HYPOGLYCEMIA.  THE
C...  DEFICIENCY OF INSULIN RELEASE, CHARACTERISTIC OF JUVENILE-ONSET
C...  DIABETES, PROLONGS THE FALL OF GLUCOSE FOR MANY HOURS (1).
C...
C...  (1)  RANDALL, JAMES E., MICROCOMPUTERS AND PHYSIOLOGICAL SIMULA-
C...  TION, ADDISON-WESLEY PUBLISHING COMPANY, INC., READING, MA, 1980,
C...  P69.
C...
C...  THE FOLLOWING DIFFERENTIAL EQUATIONS CAN BE USED TO COMPUTE THE
C...  GLUCOSE AND INSULIN LEVELS AS A FUNCTION OF TIME:
C...
C...     CG*DG/DT = Q + IN - (GG*I*G) - DD*G, G LT GK                (1)
C...
C...     CG*DG/DT = Q + IN - (GG*I*G) - DD*G - MU*(G - GK), G GE GK  (2)
C...
C...     CI*DI/DT = -AA*I, G LT G0                                   (3)
C...
C...     CI*DI/DT = -AA*I + BB*(G - G0), G GE G0                     (4)
C...
C...  WHERE
C...
C...     SYMBOL        PARAMETERS/VARIABLES             NORMAL VALUES
C...
C...       EX     EXTRACELLULAR SPACE                     15000 ML
C...
C...       CG     GLUCOSE CAPACITANCE = EX/100             150 ML
C...
C...       CI     INSULIN CAPACITANCE = EX/100             150 ML
C...
C...       Q      LIVER RELEASE OF GLUCOSE               8400 MG/HR
C...
C...       QT     GLUCOSE INFUSION RATE                 80000 MG/HR
C...
C...       IN     INFUSION, QT OR 0
C...
C...       DD     FIRST-ORDER GLUCOSE LOSS            24.7 MG/HR/MGML
C...
C...       GG     CONTROLLED GLUCOSE LOSS           13.9 MG/HR/MGML/MIML
C...
C...       GK     RENAL THRESHOLD                         250 MGML
C...
C...       MU     RENAL LOSS RATE                      72 MG/HR/MGML
C...
C...       G0     PANCREAS THRESHOLD                      51 MGML
C...
C...       BB     INSULIN RELEASE RATE                14.3 MI/HR/MGML
C...
C...       AA     FIRST-ORDER INSULIN RATE             76 MI/HR/MGML
C...
C...       G      EXTRACELLULAR GLUCOSE               81 MGML (T = 0)
C...
C...       I      EXTRACELLULAR INSULIN              5.7 MIML (T = 0)
C...
C...       T      TIME                                      HR
C...
C...  THE MASS AND CONCENTRATION UNITS ARE:
C...
C...       MG     MILLIGRAMS OF GLUCOSE
C...
C...       MI     MILLIGRAMS OF INSULIN
C...
C...       MGML   MILLIGRAMS OF GLUCOSE/100 ML EXTRACELLULAR FLUID
C...
C...       MIML   MILLIGRAMS OF INSULIN/100 ML EXTRACELLULAR FLUID
C...
C...  THE GLUCOSE INFUSION FUNCTION, IN, IS GIVEN BY:
C...
C...              IN = QT, 0 LE T LE 0.5
C...
C...              IN = 0, 0.5 LT T LE 12
C...
C...  EQUATIONS (1) TO (4) ARE TO BE INTEGRATED FOR THE FOUR CASES:
C...
C...     (1)  (NORUN = 1)
C...
C...          NORMAL PANCREATIC SENSITIVITY (BB = 14.3)
C...          (WITHOUT GLUCOSE INFUSION, QT = 0)
C...
C...     (2)  (NORUN = 2)
C...
C...          NORMAL PANCREATIC SENSITIVITY (BB = 14.3)
C...          (WITH GLUCOSE INFUSION)
C...
C...     (3)  (NORUN = 3)
C...
C...          REDUCED PANCREATIC SENSITIVITY (BB = 0.2(14.3))
C...          (WITH GLUCOSE INFUSION)
C...
C...     (4)  (NORUN = 4)
C...
C...          ELEVATED PANCREATIC SENSITIVITY (BB = 2.0(14.3))
C...          (WITH GLUCOSE INFUSION)
C...
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     G,     I
     2      /F/  DGDT,  DIDT
     3      /C/    EX,    CG,    CI,     Q,    QT,    IN,    DD,    GG,
     4             GK,    MU,    G0,    BB,    AA
      REAL          I,    IN,    MU
C...
C...  SET THE MODEL PARAMETERS
      EX=15000.
      CG=150.
      CI=150.
       Q=8400.
      DD=24.7
      GG=13.9
      GK=250.
      MU=72.
      G0=51.
      AA=76.
C...
C...  SELECT THE CASE
      IF(NORUN.EQ.1)THEN
C...
C...  CASE 1
      BB=14.3
      QT=0.
C...
C...  CASE 2
      ELSE IF(NORUN.EQ.2)THEN
      BB=14.3
      QT=80000.
C...
C...  CASE 3
      ELSE IF(NORUN.EQ.3)THEN
      BB=0.2*14.3
      QT=80000.
C...
C...  CASE 4
      ELSE IF(NORUN.EQ.4)THEN
      BB=2.0*14.3
      QT=80000.
      END IF
C...
C...  SET THE MODEL INITIAL CONDITIONS
      G=81.14
      I=5.671
C...
C...  INITIALIZE THE MODEL DERIVATIVES
      CALL DERV
      RETURN
      END
      SUBROUTINE DERV
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     G,     I
     2      /F/  DGDT,  DIDT
     3      /C/    EX,    CG,    CI,     Q,    QT,    IN,    DD,    GG,
     4             GK,    MU,    G0,    BB,    AA
      REAL          I,    IN,    MU
C...
C...  GLUCOSE INFUSION FUNCTION
      IF((T.GE.0. ).AND.(T.LE.0.5))IN=QT
      IF((T.GT.0.5).AND.(T.LE.12.))IN=0.
C...
C...  GLUCOSE EQUATIONS (EQUATIONS (1), (2))
      IF(G.LT.GK)
     1 DGDT=(1./CG)*(Q+IN-(GG*I*G)-DD*G)
      IF(G.GE.GK)
     2 DGDT=(1./CG)*(Q+IN-(GG*I*G)-DD*G-MU*(G-GK))
C...
C...  INSULIN EQUATIONS (EQUATIONS (3), (4))
      IF(G.LT.G0)
     1 DIDT=(1./CI)*(-AA*I)
      IF(G.GE.G0)
     1 DIDT=(1./CI)*(-AA*I+BB*(G-G0))
      RETURN
      END
      SUBROUTINE PRINT(NI,NO)
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     G,     I
     2      /F/  DGDT,  DIDT
     3      /C/    EX,    CG,    CI,     Q,    QT,    IN,    DD,    GG,
     4             GK,    MU,    G0,    BB,    AA
      REAL          I,    IN,    MU
C...
C...  DIMENSION THE ARRAYS FOR THE PLOTTED SOLUTION
      DIMENSION TP(49), GP(4,49), PI(4,49)
C...
C...  INITIALIZE A COUNTER FOR THE PLOTTED SOLUTION
      DATA IP/0/
C...
C...  PRINT A HEADING FOR THE NUMERICAL SOLUTION
      IF(IP.EQ.0)WRITE(NO,2)
2     FORMAT(9X,1HT,8X,2HIN,9X,1HG,6X,4HDGDT,9X,1HI,6X,4HDIDT)
C...
C...  PRINT THE SOLUTION EVERY FOURTH CALL TO SUBROUTINE PRINT
      IP=IP+1
      IF(((IP-1)/4*4).EQ.(IP-1))
     1   WRITE(NO,1)T,IN,G,DGDT,I,DIDT
1     FORMAT(F10.2,F10.0,4F10.4)
C...
C...  STORE THE NUMERICAL SOLUTION FOR PLOTTING
      GP(NORUN,IP)=G
      PI(NORUN,IP)=I
      TP(IP)=T
C...
C...  PLOT THE NUMERICAL SOLUTION
      IF(IP.LT.49)RETURN
      IF(NORUN.EQ.4)GO TO 3
      IP=0
      RETURN
3     CALL SPLOTS(NORUN,IP,TP,GP)
      WRITE(NO,4)
4     FORMAT(1H ,/,38H GLUCOSE CONC (MG/100 ML) VS TIME (HR))
      CALL SPLOTS(NORUN,IP,TP,PI)
      WRITE(NO,5)
5     FORMAT(1H ,/,38H INSULIN CONC (MG/100 ML) VS TIME (HR))
C...
C...  *****************************************************************
C...
C...  THE CODING FOR THE CONTINUOUS PLOTS WAS REMOVED SINCE IT IS
C...  MACHINE DEPENDENT.  EQUIVALENT PLOTTING CAN BE ADDED HERE USING
C...  THE SAME ARRAYS AS IN THE PRECEDING CALLS TO SUBROUTINE SPLOTS.
C...
C...  *****************************************************************
C...
      RETURN
      END
