      SUBROUTINE TKLAYR(LYRTHK, GEOHGT)
C
C***********************************************************************
C
C   NAME- TKLAYR
C
C   LANGUAGE- VS FORTRAN      TYPE- SUBROUTINE      COMPUTER- NAS9000
C
C   VERSION- 1.0      DATE- 3/19/92      PROGRAMMER-  DAVE MOREL (SMSRC)
C   VERSION- 2.0      DATE- 3/20/95      PROGRAMMER-  LI LU (SMSRC)
C     ATOVS79 :  DIMENSION OF GEOHGT CHANGES FROM 40 TO 42. FOR EACH
C                COMPUTATION OF A LEVEL OF LYRTHK, ADD A CHECK FOR ANY
C                VALUE OF GEOHGT EQUAL TO SPVAL:R4SPV. IF ANY LEVEL
C                IS MISSING, SET THE CORRESPONDING LEVEL OF LYRTHK
C                TO SPVAL:R4SPV.
C   VERSION- 3.0    DATE- 05/14/96   PROGRAMMER- ALEX POZDNYAK, FDC
C      FOR REHOSTING TO THE CRAY, CHANGED ALL R*4 DECLARATIONS TO REAL.
C   VERSION- 4.0    DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C        Replace R4SPV equivalence test with ISR4SPV function
C
C   FUNCTION- THIS SUBROUTINE COMPUTES THE LAYER THICKNESS FROM
C             THE 42 TOVS LEVELS AT THE 20 STANDARD LEVELS.
C
C   CALLING SEQUENCE PARAMETERS-
C
C   NAME    TYPE  I/O    DESCRIPTION
C   ----    ----  ---    -----------
C   LYRTHK  REAL   O     VECTOR OF 20 THICKNESS LAYERS (M)
C   GEOHGT  REAL   I     VECTOR OF 42 HEIGHTS BETWEEN TOVS LEVELS
C
C
C   EXIT STATES- NONE
C
C***********************************************************************
C
      INCLUDE 'SPVAL'
C
      REAL  LYRTHK(20), GEOHGT(42)
      LOGICAL   ISR4SPV
C
C  IF ANY VALUE OF GEOHGT IS MISSING, SET CORRESPONDING LEVEL OF
C  LYRTHK TO SPVAL:R4SPV.
C
      IF ((ISR4SPV(GEOHGT(1))) .OR. (ISR4SPV(GEOHGT(2))) .OR.
     1    (ISR4SPV(GEOHGT(3)))) THEN
         LYRTHK(1)  = R4SPV
      ELSE
         LYRTHK(1)  = GEOHGT(1) + GEOHGT(2) + GEOHGT(3)
      END IF
C
      IF ((ISR4SPV(GEOHGT(4))) .OR. (ISR4SPV(GEOHGT(5)))) THEN
         LYRTHK(2)  = R4SPV
      ELSE
         LYRTHK(2)  = GEOHGT(4) + GEOHGT(5)
      END IF
C
      LYRTHK(3)  = GEOHGT(6)
C
      IF ((ISR4SPV(GEOHGT(7))) .OR. (ISR4SPV(GEOHGT(8)))) THEN
         LYRTHK(4)  = R4SPV
      ELSE
         LYRTHK(4)  = GEOHGT(7) + GEOHGT(8)
      END IF
C
      LYRTHK(5)  = GEOHGT(9)
      LYRTHK(6)  = GEOHGT(10)
C
      IF ((ISR4SPV(GEOHGT(11))) .OR. (ISR4SPV(GEOHGT(12)))) THEN
         LYRTHK(7)  = R4SPV
      ELSE
         LYRTHK(7)  = GEOHGT(11) + GEOHGT(12)
      END IF
C
      IF ((ISR4SPV(GEOHGT(13))) .OR. (ISR4SPV(GEOHGT(14)))) THEN
         LYRTHK(8)  = R4SPV
      ELSE
         LYRTHK(8)  = GEOHGT(13) + GEOHGT(14)
      END IF
C
      LYRTHK(9)  = GEOHGT(15)
C
      IF ((ISR4SPV(GEOHGT(16))) .OR. (ISR4SPV(GEOHGT(17)))) THEN
         LYRTHK(10)  = R4SPV
      ELSE
         LYRTHK(10) = GEOHGT(16) + GEOHGT(17)
      END IF
C
      IF ((ISR4SPV(GEOHGT(18))) .OR. (ISR4SPV(GEOHGT(19)))) THEN
         LYRTHK(11)  = R4SPV
      ELSE
         LYRTHK(11) = GEOHGT(18) + GEOHGT(19)
      END IF
C
      IF ((ISR4SPV(GEOHGT(20))) .OR. (ISR4SPV(GEOHGT(21))) .OR.
     1    (GEOHGT(22).EQ.R4SPV)) THEN
         LYRTHK(12)  = R4SPV
      ELSE
         LYRTHK(12) = GEOHGT(20) + GEOHGT(21) + GEOHGT(22)
      END IF
C
      LYRTHK(13) = GEOHGT(23)
      LYRTHK(14) = GEOHGT(24)
      LYRTHK(15) = GEOHGT(25)
C
      IF ((ISR4SPV(GEOHGT(26))) .OR. (ISR4SPV(GEOHGT(27)))) THEN
         LYRTHK(16)  = R4SPV
      ELSE
         LYRTHK(16) = GEOHGT(26) + GEOHGT(27)
      END IF
C
      IF ((ISR4SPV(GEOHGT(28))) .OR. (ISR4SPV(GEOHGT(29))) .OR.
     1    (ISR4SPV(GEOHGT(30)))) THEN
         LYRTHK(17)  = R4SPV
      ELSE
         LYRTHK(17) = GEOHGT(28) + GEOHGT(29) + GEOHGT(30)
      END IF
C
      IF ((ISR4SPV(GEOHGT(31))) .OR. (ISR4SPV(GEOHGT(32))) .OR.
     1    (ISR4SPV(GEOHGT(33))) .OR. (ISR4SPV(GEOHGT(34)))) THEN
         LYRTHK(18)  = R4SPV
      ELSE
         LYRTHK(18) = GEOHGT(31) + GEOHGT(32) + GEOHGT(33) + GEOHGT(34)
      END IF
C
      IF ((ISR4SPV(GEOHGT(35))) .OR. (ISR4SPV(GEOHGT(36)))) THEN
         LYRTHK(19)  = R4SPV
      ELSE
         LYRTHK(19) = GEOHGT(35) + GEOHGT(36)
      END IF
C
      IF ((ISR4SPV(GEOHGT(37))) .OR. (ISR4SPV(GEOHGT(38))) .OR.
     1    (ISR4SPV(GEOHGT(39)))) THEN
         LYRTHK(20)  = R4SPV
      ELSE
         LYRTHK(20) = GEOHGT(37) + GEOHGT(38) + GEOHGT(39)
      END IF
C
C
      RETURN
      END
