      SUBROUTINE SPINTR(BOX,NEWBOX,LM,NLM,INCR,WORK,OLDX,NEWX,Y,NEWY) 

C     * MAR 11/2004 - M.BERKLEY (MODIFIED for NCAR V3.2)
C     * F. ZWIERS, 14 DEC 1990 (SOFT CODE CONREC "SPECIAL VALUE") 
C     * HAROLD REYNOLDS, JULY 5, 1989.
  
C     * THIS SUBROUTINE PROVIDES A TWO-WAY LINEAR INTERPOLATION OF
C     * THE 2-D FIELD "BOX", PUTTING THE RESULT IN THE ARRAY "NEWBOX".
C     * THIS ROUTINE WAS DESIGNED SPECIFICALLY FOR PROGRAM SPPLOT,
C     * BUT THE PART WHICH DOES THE INTERPOLATION CAN BE ADAPTED TO 
C     * OTHER USES. 
C 
C     * FIRST, THE UPPER TRIANGLE ARRAY IS CONVERTED INTO A SYMMETRIC 
C     * ARRAY. THEN THE ARRAY IS INTERPOLATED BY ROWS AND THE NEW 
C     * ARRAY IS INTERPOLATED BY COLUMNS. THEN THE "SPECIAL VALUE"
C     * OF CONREC, WHICH MAKES IT NOT DRAW LINES IN  THE CELL IN
C     * QUESTION, IS RE-INSTATED IN THE LOWER TRIANGLE. FINALLY, THE
C     * "STEPS" IN THE SPPLOT ARE PUT IN PLACE. 
  
      INTEGER LM,NLM,MAX,INCR 
      REAL BOX(LM*LM),NEWBOX(NLM*NLM),WORK(NLM*NLM),OLDX(LM),NEWX(NLM)
      REAL Y(LM),NEWY(NLM)
  
C     * NCAR COMMON BLOCK USED TO CARRY "SPECIAL VALUE" 
  
C      COMMON /CONRE1/IOFFP,SPVAL,IHILO
      COMMON /CONRE1/IOFFP,SPVAL
  
C     *INITIALIZE WORK ARRAY
  
      DO 4 I=1,LM*LM
        WORK(I)=BOX(I)
    4 CONTINUE
  
C     * CREATE SYMMETRIC MATRIX 
  
      DO 5 IROW=1,LM-1
        DO 10 ICOL=IROW+1,LM
         IUP=(ICOL-1)*LM+IROW 
         ILO=(IROW-1)*LM+ICOL 
         WORK(ILO)=WORK(IUP)
   10   CONTINUE
    5 CONTINUE
  
C     * CREATE ARRAYS OF X COORDINATES
  
      DO 15 I=1,LM
        OLDX(I)=FLOAT(I)
   15 CONTINUE
  
C     * VALUE OF NLM=(LM-1)*INCR+LM  OR  (INCR+1)*LM-INCR WHERE 
C     * INCR IS THE NUMBER OF NEW POINTS BEING ADDED BETWEEN
C     * EACH PAIR OF OLD ARRAY
  
      DO 20 I=INCR+1,NLM+INCR 
        NEWX(I-INCR)=FLOAT(I)/FLOAT(INCR+1) 
   20 CONTINUE
  
C     * INTERPOLATE EACH ROW
      DO 35 IROW=1,LM 
        DO 25 ICOL=1,LM 
          IND=(ICOL-1)*LM+IROW
          Y(ICOL)=WORK(IND) 
   25   CONTINUE
        CALL LINIL(NEWY,NEWX,NLM,Y,OLDX,LM,0.0,0.0) 
        DO 30 ICOL=1,NLM
          IND=(ICOL-1)*LM+IROW
          NEWBOX(IND)=NEWY(ICOL)
   30   CONTINUE
   35 CONTINUE
  
C     * TAKE NEW ARRAY AND INTERPOLATE EACH COLUMN
  
      DO 50 ICOL=1,NLM
        DO 40 IROW=1,LM 
          IND=(ICOL-1)*LM+IROW
          Y(IROW)=NEWBOX(IND) 
   40   CONTINUE
        CALL LINIL(NEWY,NEWX,NLM,Y,OLDX,LM,0.0,0.0) 
        DO 45 IROW=1,NLM
          IND=(ICOL-1)*NLM+IROW 
          WORK(IND)=NEWY(IROW)
   45   CONTINUE
   50 CONTINUE
  
C     * PUT THE SPECIAL VALUE BACK INTO LOWER LEFT CORNER 
  
      DO 60 IROW=1,NLM
        DO 55 ICOL=1,NLM
          IND=(ICOL-1)*NLM+IROW 
          IF(ICOL .LT. IROW) THEN 
            NEWBOX(IND)=SPVAL 
          ELSE
            NEWBOX(IND)=WORK(IND) 
          END IF
   55   CONTINUE
   60 CONTINUE
  
C     * NOW MUST "CARVE OUT" STEP SO IT FITS IN ORIGINAL STEP OF GRAPH
C     * INCR IS THE NUMBER OF NEW POINTS PUT BETWEEN EACH PAIR OF OLD ONES
  
      DO 75 IROW=1,NLM
        MD=MOD(IROW-1,INCR+1) 
        IF(MD.NE.0) THEN
          IND=(IROW-1)*NLM+IROW 
C         * MCARVE IS NUMBER OF COLUMNS OVER FROM DIAGONAL WE MUST GO 
          MCARVE=(INCR+1)-MD
          DO 70 ICOL=1,MCARVE 
            IND2=IND+(ICOL-1)*NLM 
            NEWBOX(IND2)=SPVAL
   70     CONTINUE
        END IF
   75 CONTINUE
  
      RETURN
      END 
