      SUBROUTINE LGRNGV (MO, NA, QU, AU, AN, FF, DF, SF)
C     ******************************************************************
C     FORTRAN SUBROUTINE FOR LAGRANGIAN FUNCTION EVALUATION
C     ******************************************************************
C     MO = MODE OF OPERATION
C     NA = NUMBER OF STATIONS
C     QU = ARGUMENT OF FUNCTIONS
C     AU = STATION COORDINATES                    (N-ARRAY)
C     AN = NORMALIZATION FACTORS                  (N-ARRAY)
C     FF = LAGRANGIAN FUNCTIONS                   (N-ARRAY)
C     DF = FIRST DERIVATIVES                      (N-ARRAY)
C     SF = SECOND DERIVATIVES                     (N-ARRAY)
C
C     CALL LGRNGV (0, NA, QU, AU, AN, FF)         FOR FUNCTIONS
C     CALL LGRNGV (1, NA, QU, AU, AN, FF, DF)     FOR FIRST DERIVATIVES
C     CALL LGRNGV (2, NA, QU, AU, AN, FF, DF, SF) FOR SECOND DERIVATIVES
C
      DIMENSION AU(1), AN(1), FF(1), DF(1), SF(1)
      LOGICAL LN
  001 LN=.TRUE.
      TM=1.0
      DO 003 K=1,NA
      IF(QU.NE.AU(K))GO TO 002
      LN=.FALSE.
      GO TO 003
  002 DM=QU-AU(K)
      TM=DM*TM
  003 CONTINUE
      DO 007 K=1,NA
      IF(LN)GO TO 005
      IF(QU.NE.AU(K))GO TO 005
      FF(K)=TM
      GO TO 006
  005 DM=QU-AU(K)
      FF(K)=TM/DM
  006 FF(K)=FF(K)/AN(K)
  007 CONTINUE
      IF(MO.LE.0)GO TO 050
      SM=0.0
      DO 013 K=1,NA
      DF(K)=SM
      IF(LN)GO TO 012
      IF(QU.EQ.AU(K))GO TO 013
  012 DM=QU-AU(K)
      SM=SM+1.0/DM
  013 CONTINUE
      RM=SM
      IF(MO.EQ.1)GO TO 040
      SM=0.0
      DO 023 K=1,NA
      SF(K)=SM
      IF(LN)GO TO 022
      IF(QU.EQ.AU(K))GO TO 023
  022 DM=QU-AU(K)
      SM=SM+2.0*DF(K)/DM
  023 CONTINUE
      SM=0.0
      TM=0.0
      L=NA
      IF(LN)GO TO 034
      DO 033 K=1,NA
      SF(L)=TM+SF(L)+2.0*SM*DF(L)
      IF(QU.EQ.AU(L))GO TO 032
      SF(L)=2.0*(SM+DF(L))
      DM=QU-AU(L)
      TM=TM+2.0*SM/DM
      SM=SM+1.0/DM
  032 L=L-1
  033 CONTINUE
      GO TO 036
  034 DO 035 K=1,NA
      SF(L)=TM+SF(L)+2.0*SM*DF(L)
      DM=QU-AU(L)
      TM=TM+2.0*SM/DM
      SM=SM+1.0/DM
      L=L-1
  035 CONTINUE
  036 DO 037 K=1,NA
      SF(K)=FF(K)*SF(K)
  037 CONTINUE
  040 IF (LN) GO TO 043
      DO 042 K=1,NA
      IF (QU.NE.AU(K)) GO TO 041
      DF(K)=RM
      FF(K)=1.0
      GO TO 042
  041 DF(K)=FF(K)
      FF(K)=0.0
  042 CONTINUE
      RETURN
  043 SM=0.0
      L=NA
      DO 044 K=1,NA
      DF(L)=FF(L)*(SM+DF(L))
      SM=SM+1.0/(QU-AU(L))
      L=L-1
  044 CONTINUE
      RETURN
  050 IF(LN)GO TO 053
      DO 052 K=1,NA
      FF(K)=0.0
      IF(QU.NE.AU(K))GO TO 052
      FF(K)=1.0
  052 CONTINUE
  053 RETURN
      END
