      PROGRAM MTERP
C -------------------------------------------------------------------
C     **** SHORT PROGRAM TO TAKE Ames-MGCM ZONALLY OUTPUT FIELDS
C     **** AND RECAST THEM IN 36-LATITUDE SLICES FOR THE NCAR-MTGCM
C     **** LAST REVISED : S. W. BOUGHER (10/17/97)  MGSPH1
C     **** LAST REVISED : S. W. BOUGHER (11/20/97) 
C     **** LAST REVISED : S. W. BOUGHER (12/02/97) 
C     **** LAST REVISED : S. W. BOUGHER (12/04/97) 
C     **** LAST REVISED : S. W. BOUGHER (12/30/97) 
C     **** LAST REVISED : S. W. BOUGHER (06/05/98) 
C     **** LAST REVISED : S. W. BOUGHER (06/29/98) 
C     **** LAST REVISED : S. W. BOUGHER (09/04/98)  MGSPH2 
C     **** LAST REVISED : S. W. BOUGHER (09/11/98) 
C     **** LAST REVISED : S. W. BOUGHER (09/22/98) 
C     **** LAST REVISED : S. W. BOUGHER (09/29/98) 
C     **** LAST REVISED : S. W. BOUGHER (11/30/98) 
C     **** LAST REVISED : S. W. BOUGHER (04/09/99)  MCOLIB ENTRIES 
C     **** LAST REVISED : S. W. BOUGHER (05/04/99)  MCOLIB ENTRIES #2 
C     **** LAST REVISED : S. W. BOUGHER (05/11/99)  MCOLIB ENTRIES #3 
C     **** LAST REVISED : S. W. BOUGHER (05/25/99)  MCOLIB ENTRIES 
C     **** LAST REVISED : S. W. BOUGHER (05/03/00)  MCOLIB ENTRIES #4 
C     **** USES CUBSPL ROUTINES OF NCAR LIBRARIES 
C -------------------------------------------------------------------
C
      PARAMETER (ILATN=36,ILATO=25,ILATO3=28)
C -   INPERPOLATION DATA SOURCE
      DIMENSION ZKMO(ILATO),TO(ILATO)
C     DIMENSION ZKMO(ILATO3),TO(ILATO3)
C -   INPERPOLATION DATA SINK
      DIMENSION ZKMN(ILATN),TN(ILATN)
C  -  INDEPENDENT VARIABLE ARRAY AT WHICH DATA EXISTS
      DIMENSION XLATO(ILATO)
C  -  INDEPENDENT VARIABLE ARRAY AT WHICH INTERP. IS DESIRED
      DIMENSION XLATN(ILATN)
C -   INPUT ARRAYS FOR INTERP. ROUTINES : X,F,WW BIGGER THAN NEEDED
      DIMENSION X(25),F(25),WW(25),IOP(2),WK(76),ITAB(3),TAB(3)
C  -  INDEPENDENT VARIABLE DATASET ARRAY (NEW)
      DATA XLATN/-87.5,-82.5,-77.5,-72.5,-67.5,-62.5,-57.5,-52.5,
     & -47.5,-42.5,-37.5,-32.5,-27.5,-22.5,-17.5,-12.5,-7.5,-2.5,
     & 2.5,7.5,12.5,17.5,22.5,27.5,32.5,37.5,42.5,47.5,52.5,57.5,
     & 62.5,67.5,72.5,77.5,82.5,87.5/
C  -  INDEPENDENT VARIABLE DATASET ARRAY (OLD)
      DATA XLATO/-90.0,-82.5,-75.0,-67.5,-60.0,-52.5,
     & -45.0,-37.5,-30.0,-22.5,-15.0,-7.5,0.0,
     &  7.5,15.0,22.5,30.0,37.5,45.0,52.5,60.0,
     &  67.5,75.0,82.5,90.0/
C  -  INPUT FLAGS FOR INTERPOALTION ROUTINES
      DATA IOP/1,1/,INTT/1/,ITAB/1,0,0/,NVEC/2/
C ----(LOOP OVER NUMBER OF SEASONS TO BE PROCESSED)
      DO 100 IKK=1,2
C ----(NEW SET1)------------------------------------------------------
      READ(20,2000) XLS
      READ(20,2002) (ZKMO(J),J=1,ILATO)
      READ(20,2003) (TO(J),J=1,ILATO)
 2000 FORMAT(4X,F12.4)
 2002 FORMAT(15X,5F12.4)
 2003 FORMAT(14X,5F12.4)
C --------------------------------------------------------------------
C
C -   OLD INDEPENDENT VARIABLE VALUES
      DO 1 J=1,ILATO
   1  X(J)=XLATO(J)
C -   LOOP OVER OLD DEPENDENT VARIABLE VALUES IN ASCENDING ORDER
            DO 30 K=1,NVEC
C -   LOOP OVER RANGE OF AVAILABLE ILATO
               DO 35 J=1,ILATO
                IF(K.EQ.1)F(J)=ZKMO(J)
  35            IF(K.EQ.2)F(J)=TO(J)
C -   LOOP OVER INDEPENDENT VAR VALUES AT WHICH INTERP IS REQUIRED
               DO 40 JJ=1,ILATN
                YI=XLATN(JJ)
C -   NATURAL SPLINE BOUNDARY CONDITIONS
               WW(1)=0.
               WW(ILATO)=0.
            CALL COEFF1(ILATO,X,F,WW,IOP,INTT,WK)
            CALL TERP1(ILATO,X,F,WW,YI,INTT,TAB,ITAB)
C ------------------------------------------------------------------
C
C SUMMARY OF CURRENT UNDERSTANDING OF HEIGHT OFFSETS OF MGCM to MTGCM
C -- (Update based on Phase II ACC data P574-P583 : 9/28/98)
C -- (Update based on Phase II ACC data P750-P787 : 11/30/98)
C
C       (1)  Tri-axial ellipsoid used by NAV; ACC heights error is less than +-1.0 km.
C            Conversation with Keating (summer 1998). Equatorial lats. errors minimal?
C       (2)  MOLA indicates that 6.1-mbar surface in error by ~1.0 km in DTM heights  on
C            average. Error NOT systematic. Worse case add +1.0 km to MGCM heights, 
C            since it it uses DTM topography to fix height scale.
C       (3)  MGCM calculates geopotential heights which differ from MTGCM
C            geometric heights by ~1-2 km at p=1.32-ubar surface. Add another
C            +1.0 km (lower limit) or +2.0 km (upper limit) to MGCM height scale.
C       (4)  MGCM deposition of aerosol heating with height (below 40 km) may be
C            incorrect.  Alternatively, dynamical heating above 60 km may not be
C            addressed correctly. Effect is more pronounced as perihelion approaches.
C            This ``variable'' portion of the offset will be largest at
C            perihelion (near S. Summer Solstice) and smallest at aphelion
C            (N. Summer Solstice).
C   (TOTAL)  Total height offset required to achieve proper calibration of ACC 1.26-nbar
C            heights and MGCM-MTGCM height scale.
C
C                   LS         TOTAL   (1)   (2+3)       (4)    tau(vis)
C                 -------      -----  ----   -----      ----    --------
C                 180-220       5.5    1.0    2.0        2.5    0.3-1.0
C                 220-250      10.0    1.0    2.0        7.0    NOACHIS
C                 250-300       7.5    1.0    2.0        4.5    0.3-1.0
C    ACTUAL          30         4.5    1.0    2.0        1.5    0.2-0.3
C    ACTUAL          60         3.0    1.0    2.0        0.0    0.2-0.15
C    ESTIMATE        80         2.0    0.0    2.0        0.0    0.2-0.15
C
C
C ------------------------------------------------------------------
C -   OUTPUT GRID OF INTERPOLATED RESULTS  (NO OFFSET)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)
C ---------------MGS PHASE I-----------------------------------------
C     ALT OFFSET ACCORDING TO MGS/ACC HT OF P=1.26 nbar (9/20-10/20/97)
C         (Use for Fall 1997 MGS Calibration of MTGCM heights)
C         (tau = 0.3=1.0 Used)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+5.5
C     ALT OFFSET ACCORDING TO MGS/ACC HT OF P=1.26 nbar (11/20-12/20/97)
C         (Use for Fall 1997 MGS Calibration of MTGCM heights)
C         (tau = 0.3=1.0 Used)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+7.5
C     ALT OFFSET ACCORDING TO MGS/ACC HT OF P=1.26 nbar (11/20-12/10/97)
C         (Use for Fall 1997 MGS Calibration of MTGCM heights)
C         (Initial tau = 0.3 static preceeding Noachis storm Event)
C         (``Deep dust mixing cases'' for storm event)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+10.0
C ---------------SOLAR CYCLE CASES ----------------------------------
C     ALT OFFSET ACCORDING TO STEWART(87) P=1.26 nbar
C         (Solar Cycle EQUMED DY:10 Height Offset : Ls=180 D=1.467)
C         (tau = 0.0 used)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+7.0
C     ALT OFFSET ACCORDING TO STEWART(87) P=1.26 nbar
C         (Solar Cycle SSLMED DY:5 Height Offset : Ls=270 D=1.388)
C         (tau = 0.0 compared to tau = 0.3 and tau = 1.0)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+10.0
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+ 7.5
C     ALT OFFSET ACCORDING TO STEWART(87) P=1.26 nbar
C         (Solar Cycle NSLMED DY:5 Height Offset : Ls=090 D=1.656)
C         (tau = 0.0 used)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+1.0
C ---------------MGS PHASE II----------------------------------------
C     ALT OFFSET ACCORDING TO RESIDUAL FOR NO/LOW DUST (Table above)
C         (tau = 0.2 used for static background seasonal dust opacity)
C         (MGS Phase II Aphelion Height Offset : Ls=030-060 D=1.625-1.660)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+4.5
C         (MGS Phase II Aphelion Height Offset : Ls=080 D=1.664)
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+2.0
C ---------------MCO FALL 1999 -------------------------------------
C ---------------MCO FALL 1999 AB (NO OFFSET)-----------------------
                IF(K.EQ.1)ZKMN(JJ)=TAB(1)
                IF(K.EQ.2)TN(JJ)=TAB(1)
C ---------------MCO FALL 1999 AB (MGS1 OFFSET)---------------------
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+5.5
C               IF(K.EQ.2)TN(JJ)=TAB(1)
C ---------------MGS FALL 1998 AB (MGS2 OFFSET)---------------------
C               IF(K.EQ.1)ZKMN(JJ)=TAB(1)+2.5
C               IF(K.EQ.2)TN(JJ)=TAB(1)
C ------------------------------------------------------------------
  40           CONTINUE
  30        CONTINUE
C
C --------------------------------------------------------------------
      WRITE (21,2011) XLS
      WRITE(21,2010) (ZKMN(J),TN(J),J=1,ILATN)
      PRINT 2011, (XLS)
      PRINT 2010, (ZKMN(J),TN(J),J=1,ILATN)
  100 CONTINUE
C --------------------------------------------------------------------
 2010 FORMAT(1X,2F10.2)
 2011 FORMAT(1X,F10.2)
C --------------------------------------------------------------------
      STOP
      END

