      SUBROUTINE AMASFC(LIMBADJ,OBSAMA,MAXLMT,X2COEF,
     >                  XCOEF,CH4THRES,CLWADJ,CLWZERO,Q4,Q5,Q4P,
     >                  CLWADJ4,CH5THRES,CLWADJ5)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- AMASFC
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE      COMPUTER- CRAY J916
C
C   VERSION- 1.0    DATE- 05/25/99   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.1    DATE- 06/02/99   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.2    DATE- 06/21/99   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.3    DATE- 07/13/99   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.4    DATE- 09/07/99   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.5    DATE- 03/28/00   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.6    DATE- 05/12/00   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.7    DATE- 08/07/00   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.8    DATE- 09/18/00   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.9    DATE- 02/07/01   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.10   DATE- 02/27/02   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 1.11   DATE- 05/14/02   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C   VERSION- 2.0    DATE- 06/21/02   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 2.1    DATE- 11/06/02   PROGRAMMER- A. ALLEGRINO (RAYTHEON)
C   VERSION- 2.2    DATE- 02/27/03   PROGRAMMER- Rickey Rollins (CSC)
C   VERSION- 2.3    DATE- 04/22/05   PROGRAMMER- FRANK TILLEY (RAYTHEON)
C   VERSION- 2.4    DATE- 06/06/06   PROGRAMMER- FRANK TILLEY (IMSG)
C
C   FUNCTION-** THIS SUBROUTINE COMPUTES A FRAME OF AMSU-A SURFACE
C               PRODUCTS.
C   VERSION- 1.1 - ADDED THE CALCULATION OF THE LAND PRECIPITATION INDEX
C                  AND ADDED A CLOUD CLEARED AMSUA CH6 AND, CHANGED THE
C                  COEFFICIENTS USED TO CALCULATE THE CLOUD CLEARED AMSU-A
C                  CHANNELS TO ARRAY VARIABLES. THESE ARRAYS ARE INITIALIZED
C                  VIA THE SOFTFLAGS DATA SET.
C   VERSION- 1.2 - PLACED AMSU-A CHANNELS 4 AND 5 IN POSITIONS 25 AND 26
C                  ON THE AMADAT BUFFER SO THAT THEY CAN BE PRECIPITATION
C                  SCREENED. STORE LAND PRECIPITATION INDEX IN AMSU-A 
C                  ANCILLARY BUFFER.
C   VERSION- 1.3 - PLACED AMSU-A CHANNEL 6 IN POSITION 27 IN THE AMADAT
C                  BUFFER SO THAT IT COULD BE PRECIPITATION SCREENED.
C   VERSION- 1.4 - ADDED NORM GRODY'S CORRECTIONS TO THE CLOUD LIQUID  
C                  WATER COMPUTATION.
C   VERSION- 1.5 - MODIFIED THE PRECIPITATION/CLOUD CLEARED AMSUA CH 4
C                  AND CHANNEL 5 TO BASE THE PROCESS ON A CHANNEL 4
C                  THRESHOLD. REMOVED THE TREATMENT OF LAND AND AMSUA 
C                  CHANNEL 6. 
C   VERSION- 1.6 - REWROTE THE PRECIPITATION/CLOUD CLEARED AMSUA CH 4
C                  AND CHANNEL 5 PROCESS TO RCONSTRAIN THE CORRECTIONS
C                  TO THE PROPER RANGE AND THAT CLW MUST BE GREATER THAN
C                  0.1 FOR SUB POLAR REGIONS AND GREATER THAN 0 FOR THE
C                  TROPICS & SUBTROPICS.
C   VERSION- 1.7 - MODIFIED THE PRECIPITATION/CLOUD CLEARED AMSUA CH 4
C                  AND CHANNEL 5 PROCESS TO USE AMSU-A CHANNEL 6 TO ASSIST
C                  IN REMOVING WATER VAPOR IN THE TROPICS
C   VERSION- 1.8 - MODIFIED CODE TO MAKE FUDGEU4 AND FUDGEU5 SOFT CODED
C                  VARIABLES, CHANGED LATITUDE BOUNDARIES FOR DEFINING
C                  THE TROPIC REGIONS, AND ADDED CODE TO NOT THE TEMPERATURES
C                  IF THE CLOUD LIQUID WATER IS GREATER THAN 0.5 POLEWARD
C                  OF INLAT OR ISLAT IN THE TROPICAL/SUBTROPICAL SECTION.
C                  (WR #102 AND 110)
C   VERSION- 1.9 - MODIFIED CODE TO MAKE THE TEST WHICH DETERMINES THE CLW
C                  CORRECTIONS FOR AMSUA CH4 AND5 TO BE ZERO TO READ THE
C                  CLW LIMIT FROM THE SOFTFLAGS DATA SET (WR#120)
C  VERSION- 1.10 - MODIFIED CODE TO REVAMP THE TESTS WHICH DETERMINES THE CLW
C                  CORRECTIONS FOR AMSUA CH4 AND CH5. THIS INCLUDES ADDITIONAL
C                  THRESHOLDS WHICH ARE SOFTCODED AND MORE TESTS (WR#158 AND
C                  191) REMOVED BIMODAL CORRECTION USING CHANNEL 6.
C  VERSION- 1.11 - RESTRICTED AMSU-A CHANNEL 5 CLW CORRECTION TO THE
C                  TROPICS. ADDED CALLING ARGUMENTS CLWADJ4,CH5THRES, AND
C                  CLWADJ5. REMOVED ARGUMENTS MAXCH6, MINCH6, FUDGEU4,
C                  AND FUDGEU5. REMOVED HARDCODED ADJUSTMENT OF 0.03 FROM
C                  THE CLW CALCULATION (WR #196)
C  VERSION- 2.0  - INSTALLED NEW ALGORITHMS FOR THE SURFACE PRODUCTS, TPW,CLW
C                  AND SEA ICE CONCENTRATION. (WR#197)
C  VERSION- 2.1  - INSTALLED ALGORITHMS FOR CHANNEL 1 AND 2 EMISSIVITIES AND 
C                  SNOW COVER. (WR#197)
C  VERSION- 2.2  - REPLACED R4SPV CHECKS WITH FUNCTION ISR4SPV.
C  VERSION- 2.3  - COMMENTED OUT A TEST FOR DELTACH4 GREATER THAN 6.0.
C                  (WR #281)
C  VERSION- 2.4  - SET COPIES OF AMSU-A CHANNEL 4, 5, AND 6 BRIGHTNESS
C                  TEMPERATURES TO ZERO OVER OCEAN IN THE TROPICS WHERE
C                  CLW EXCEEDS 0.25. ADDED PRECIPITATION CORRECTION TO
C                  AMSU-A CHANNEL 5 AND 6 OVER NON-SEA BELOW 1500 METERS
C                  ELEVATION BASED ON A LAND PRECIPITATION INDEX VALUE.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE          TYPE I/O  FUNCTION
C     --------          ---- ---  --------
C     AMADAT            REAL I/O  ARRAY OF DIMENSION (ANSPOT X ATOTLN
C                                 X ADATEL) WHICH HOLDS ONE DATA FRAME
C                                 OF 256 SECONDS OF AMSU-A SPOTS.
C     AMAANC            REAL I/O  ARRAY OF DIMENSION (ANSPOT X ATOTLN
C                                 X ANANC) WHICH HOLD THE ANCILLARY
C                                 AMSU-A INFORMATION.
C     CH4THRES          REAL   I  TEMPERATURE THRESHOLD USED TO DETERMINE
C                                 THE CLOUD/PRECIP CLEARED PROCESS ( USES
C                                 AMSUA CHANNEL 4.
C     CLWADJ            REAL   I  VALUE USED TO ADJUST THE CLOUD LIQUID WATER
C                                 IF AMSUA CH. 4 TEMPERATURE IS BELOW OR EQUAL
C                                 TO CH4THRES
C     CLWZERO           REAL   I  CLW LIMIT USED TO DETERMINE WHETHER OR NOT 
C                                 THE CLW CORRECTION IS ZERO 
C     LIMBADJ           INT    I  FLAG TO DETERMINE WHETHER OR NOT TO USE 
C                                 LIMB CORRECTED OR UNLIMB CORRECTED DATA.
C     MAXLMT            REAL   I  ARRAY WHICH CONTAINS THE MAXIMUM VALUES
C                                 FOR THE AMSUA SURFACE PRODUCTS
C                                 MAXLMT(1) = MAXIMUM TPW LIMIT
C                                 MAXLMT(2) = MAXIMUM CLW LIMIT
C     OBSAMA            REAL   I  UNLIMB CORRECTED AMSU-A DATA ARRAY.
C     Q4,Q5 & Q4P       REAL   I  EXPONENTAL TERMS USED TO REPLACE THE
C                                 X**2 TERM. Q4 IS USED FOR CHANNEL 4,
C                                 Q5 IS USED FOR CHANNEL 5 AND Q4P IS USED
C                                 FOR CHANNEL 4 IN THE ICE FREE POLAR REGIONS.
C     X2COEF            REAL   I  ARRAY OF DIMENSION 3 WHICH CONTAINS THE
C                                 X**2 TERM COEFFICIENTS FOR AMSU-A CHANNELS
C                                 4,5, & 6 (CLOUD CLEARED)
C     XCOEF             REAL   I  ARRAY OF DIMENSION 3 WHICH CONTAINS THE
C                                 X TERM COEFFICIENTS FOR AMSU-A CHANNELS
C                                 4,5, & 6 (CLOUD CLEARED)
C     CLWADJ4           REAL   I  CLOUD LIQUID WATER ADJUSTMENT FOR AMSU-A
C                                 CHANNEL 4.
C     CH5THRES          REAL   I  CHANNEL 5 BRIGHTNESS TEMPERATURE THRESHOLD
C                                 BELOW WHICH NO CLW ADJUSTMENT IS MADE.
C     CLWADJ5           REAL   I  CLOUD LIQUID WATER ADJUSTMENT FOR AMSU-A
C                                 CHANNEL 5.
C                                 
C
C   COMMON AREA PARAMETERS- FRMINF,INSPARM,INPARM,SPVAL,SPGUNT,MONSTA,ERPARM,
C                           INSCOM
C
      INCLUDE 'INSPARM'
      INCLUDE 'FRMINF'
      INCLUDE 'INPARM'
      INCLUDE 'SPVAL'
      INCLUDE 'SPGUNT'
      INCLUDE 'ERPARM'
      INCLUDE 'ERINFO'
      INCLUDE 'MONSTA'
      INCLUDE 'INSCOM'
      INCLUDE 'RMPHSCON'
C
C   LOCAL PARAMETERS-
C     VARIABLE          TYPE  DESCRIPTION
C     --------          ----  -------------------------------------
C     I,J,K             INT   LOOP CONTROL INDICES.
C     LPINDX            REAL  LAND PRECIPITATION INDEX.
C     MISSNG         LOGICAL  SET TRUE WHEN ALL BRIGHTNESS TEMPERATURES
C                             IN RDATCY ARE MISSING.
C     M                 INT   SCAN LINE NUMBER USED IN COMPUTING
C                             SPOTNR.
C     N                 INT   AMOUNT OF OVERFLOW SCAN LINES IN AMADAT.
C     RDATCY            REAL  VECTOR OF DIMENSION INPARM:ANCHAN WITH
C                             BRIGHTNESS TEMPERATURES OF AMSU-A DATA.
C     TERTYP            INT   INTEGER TO HOLD THE TERRAIN TYPE
C                             VALUE OF THE REAL AMAANC BUFFER
C                             EQUIVALENCED TO CERTYP.
C     KMSG            CH*100  KIDS MESSAGE BUFFER.
C     SI31 & SI89      REAL   SCATTERRING INDICES USED TO DETECT THE
C     & SCAT                  PRESENCE OF SNOW ON THE GROUND AND
C                             FALLING RAIN.
C     DF1              REAL   DISCRIMINANT FUNCTION USED TO SEPARATE
C                             SEA ICE FROM OPEN OCEAN.
C     DF2              REAL   DISCRIMINANT FUNCTION USED TO SEPARATE
C                             WARM DESERTS AND NON - DESERTS
C     DF3              REAL   DISCRIMINANT FUNCTION USED TO SEPARATE
C                             COLD DESERTS AND NON - DESERTS
C     AE & BE          REAL   COEFFICIENTS USED TO COMPUTE THE 
C                             EMISSIVITY
C     EMISS            REAL   CALCULATED SURFACE EMISSIVITY
C     P23 & P31        REAL   NON-LINEAR CONVERSIONS OF THE BRIGHTNESS
C                             TEMPERATURES FOR AMSUA CH1 (P23) AND
C                             AMSUA CH2 (P31)
C     MAXTPW           REAL   MAX TOTAL PRECIPITABLE WATER LIMIT
C     MAXCLW           REAL   MAX CLOUD LIQUID WATER            
C
C
C********************************************************************
C
      REAL OBSAMA(ANSPOT,ATOTLN,ADATEL)
      REAL MAXLMT(2),X2COEF(6),XCOEF(6)
      REAL CLWADJ,CH4THRES,CLWZERO,CLWADJ5
      INTEGER LIMBADJ
C
      CHARACTER*100 KMSG
      INTEGER I,J,K,M,N,TERTYP
      REAL RDATCY(ANCHAN),DELTA
      REAL LZENANG,TPW,COSZANG,COSZANG2,C0,C1,C2,D0X,D1X,D2X
      REAL A,B,C,DF1,DF2,CICE,RAIN,EMISS,P23,P31,SNOWCOV,LPRECIDX
      REAL TT,AE,BE,SI89,SI31,AMSUAC1,AMSUAC2,AMSUAC3,AMSUAC15,EI
      REAL Q4,Q5,Q4P,SCAT,DF3,DELTACH4,DELTACH5,SIW,CLWADJ4,CH5THRES  
      REAL KVCH1,KVCH2,KLCH1,KLCH2,TAUO2CH1,TAUO2CH2,LEMISCH1,LEMISCH2
      REAL LEMISCH3,A0,A1,A2,B0,B1,B2,CLDLAYTP,CLW,TSURF,EMICECH1    
      REAL EMISH2O,EMCH1HV(2),WIND,EMCH2HV(2),SALINITY,SEAEMCH1,SEAEMCH2
      REAL SINZANG, COEFA,COEFB,ALOGC1,ALOGC2,COSTHETA,SINTHETA 
      REAL SATHGT,EARTHRAD, LPINDX, DELTACH6, DELTACH7
      LOGICAL MISSNG, ISR4SPV
C
C   CLDLAYTP IS SET IN DEGREES CELSIUS
C
      PARAMETER(CLDLAYTP = 12.0, WIND = 5.0, SALINITY = 35.0)
      PARAMETER(COEFA = 0.968, COEFB = -1.878)
C     PARAMETER(SATHGT =833.4, EARTHRAD=6374.0)
C
C
C**********************************************************************
C
C
C THE AMSU-A BUFFERS, PASSED IN THE CALL, CONTAIN A DATA FRAME
C CONSISTING OF 4 SCAN LINES OVERLAP AT THE BEGINNING AND THE END OF
C THE BUFFER.
C
C BEGIN LOOP OF ACTIVE SCAN LINES.  
C
      DO 50 J = 1,ATOTLN
C
C LOAD THE AMSU-A BRIGHTNESS TEMPERATURES FOR CHANNELS 1-15 PER SPOT.
C
         DO 40 I = 1,ANSPOT
C
C  FIRST, DETERMINE IF RDATCY HAS ANY MISSING VALUES.  IF IT IS ALL 
C  MISSING, GO TO THE NEXT SPOT
C
            MISSNG = .TRUE.
            DO K = 1,ANCHAN
               RDATCY(K)=OBSAMA(I,J,K)
               IF (.NOT.(ISR4SPV(RDATCY(K)))) MISSNG = .FALSE.
            END DO
C
C  SINCE ALL RDATCY ARE NOT MISSING, CALCULATE THE SURFACE PRODUCTS
C
            IF(MISSNG) GOTO 40
C
C LOAD THE TERRAIN TYPE OF THE SPOT.
C
            TERTYP = NINT(AMAANC(I,J,8))
            IF(ISR4SPV(AMAANC(I,J,8))) TERTYP = I4SPV
C
C LOAD THE SEA SURFACE TEMPERATURE OF THE SPOT
C 
            TSURF = AMAANC(I,J,15)
C
C LOAD THE SATELLIGHT HEIGHT AT THE SPOT

            SATHGT = AMAANC(I,J,14)
C
C CALCULATE FOR EACH SPOT THE AMSU-A SURFACE PRODUCTS (CLOUD LIQUID
C WATER, TOTAL PRECIPITABLE WATER, SNOW COVER, RAIN/NORAIN FLAG, AND
C SEA ICE CONCENTRATION).
C
C RETRIEVE THE LOCAL ZENITH ANGLE
C
C           LZENANG=AMAANC(I,J,4)*3.1415/180.0
            LZENANG=AMAANC(I,J,4)*D2RAD
C
C DETERMINE IF LIMB ADJUSTED TEMPERATURE WILL BE USED BY
C EXAMINING THE LIMB ADJUST FLAG, LIMBADJ. IF LIMBADJ= 1,
C THE USE THE LIMB ADJUSTED TEMPERATURE TO COMPUTE TPW, CLW,
C SEA ICE, RAIN/NORAIN AND SNOW COVER.
C
            IF(LIMBADJ .EQ. 1) THEN
               AMSUAC1=AMADAT(I,J,1)
               AMSUAC2=AMADAT(I,J,2)
               AMSUAC3=AMADAT(I,J,3)
               AMSUAC15=AMADAT(I,J,15)
               COSZANG= 1.0
               SINZANG = 0.0
C              LZENANG = 90.0 * 3.1415/180.0
               LZENANG = 90.0 * D2RAD
            ELSE
               AMSUAC1=RDATCY(1)
               AMSUAC2=RDATCY(2)
               AMSUAC3=RDATCY(3)
               AMSUAC15=RDATCY(15)
               COSZANG= COS(LZENANG)
               SINZANG= SIN(LZENANG)
            ENDIF
C
C  COMPUTE THE EMMISSIVITY FOR EACH CHANNEL, THE CLOUD LIQUID WATER MASS
C  ABSORPTION COEFFICIENT AND THE WATER VAPOR MASS ABSORPTION COEFFICIENT
C  (KVCH1 & KVCH2) FOR LATER USE IN PROCESSING.
C
C
            KVCH1=  0.00480423
            KVCH2=  0.00193241         
    
            KLCH1 = 0.118201 - 0.00348761*CLDLAYTP +
     >              0.0000501301*(CLDLAYTP**2)
            KLCH2 = 0.198774 - 0.00545692*CLDLAYTP +
     >              0.0000718339*(CLDLAYTP**2)

           
C
C COMPUTE THE CHANNEL EMMISSIVITIES OVER LAND
C
             IF(.NOT. ISR4SPV(AMSUAC1).AND. .NOT. ISR4SPV(AMSUAC2)
     >         .AND.  .NOT. ISR4SPV(AMSUAC3).AND.
     >          .NOT.ISR4SPV(AMSUAC15)) THEN
              LEMISCH1 = -0.25404 + 0.011326*AMSUAC1 -  
     >            (0.000019479*(AMSUAC1**2)) -
     >             0.0045763*AMSUAC2 + 0.000017833*(AMSUAC2**2) +
     >             0.0032324*AMSUAC3 - (0.000019056*(AMSUAC3**2))
              LEMISCH2 = -0.25404 + 0.011326*AMSUAC1 - 
     >             (0.000019479*(AMSUAC1**2)) -
     >             0.0045763*AMSUAC2 + 0.000017833*(AMSUAC2**2) +
     >             0.0032324*AMSUAC3 - (0.000019056*(AMSUAC3**2))
              LEMISCH3 = -0.25404 + 0.011326*AMSUAC1 - 
     >             (0.000019479*(AMSUAC1**2)) -
     >              0.0045763*AMSUAC2 + 0.000017833*(AMSUAC2**2) +
     >              0.0032324*AMSUAC3 - (0.000019056*(AMSUAC3**2))
             ELSE
              LEMISCH1 = R4SPV
              LEMISCH2 = R4SPV
              LEMISCH3 = R4SPV
             ENDIF

C
C IF OVER OPEN OCEAN, CALCULATE THE TOTAL PRECIPITABLE WATER,   
C THE CLOUD LIQUID WATER CONTENT, SEA ICE AND RAIN/NORAIN.
C
CCFT INITIALIZE THE CLW VALUE TO MISSING
C
            CLW = R4SPV
            IF(TERTYP.EQ.0) THEN
             IF((.NOT.(ISR4SPV(AMSUAC1))).AND.
     >          (.NOT.(ISR4SPV(AMSUAC2))).AND.
     >          (.NOT.(ISR4SPV(AMSUAC3))).AND.
     >          (.NOT.(ISR4SPV(AMSUAC15))).AND.
     >          (.NOT.(ISR4SPV(AMAANC(I,J,15))))) THEN
C
C  COMPUTE THE CHANNEL EMISSIVITIES OVER OCEAN (SEAEMCH1 & SEAEMCH2)
C
C               SINTHETA = (SINZANG * (EARTHRAD/(EARTHRAD+ SATHGT)))**2
                SINTHETA = (SINZANG * (EMEANR/(EMEANR+ SATHGT)))**2
                COSTHETA = 1.0 - SINTHETA
                CALL SEAEMS(WIND,LZENANG,TSURF,SALINITY,23.8,EMCH1HV)
                SEAEMCH1 = COSTHETA*EMCH1HV(2) + SINTHETA*EMCH1HV(1)
                CALL SEAEMS(WIND,LZENANG,TSURF,SALINITY,31.4,EMCH2HV)
                SEAEMCH2 = COSTHETA*EMCH2HV(2) + SINTHETA*EMCH2HV(1)

C
C  COMPUTE THE COEFFICIENTS A0,A1,A2,B0,B1 AND B2 AND THE OPTICAL
C  THICKNESS FOR OXYGEN (TAUO2).
C
                TAUO2CH1 = 0.0321410 - 0.000063186*TSURF
                TAUO2CH2 = 0.0534214 - 0.000104835*TSURF
                A0= -0.5*KVCH1/(KVCH1*KLCH2 - KVCH2*KLCH1)
                A1 = KVCH2/KVCH1
                A2 = (-2.0*(TAUO2CH2 - A1*TAUO2CH1)/COSZANG) +
     >              ((1.0 - A1)*ALOG(TSURF)) +
     >              (ALOG(1.0 - SEAEMCH2)) - (A1*ALOG(1.0 - SEAEMCH1))
                B0= 0.5*KLCH1/(KVCH1*KLCH2 - KVCH2*KLCH1)
                B1 = KLCH2/KLCH1
                B2 = (-2.0*(TAUO2CH2 - B1*TAUO2CH1)/COSZANG) +
     >              ((1.0 - B1)*ALOG(TSURF)) +
     >              (ALOG(1.0 - SEAEMCH2)) - (B1*ALOG(1.0 - SEAEMCH1))

C
C CALCULATE TOTAL PRECIPITABLE WATER, TPW (THE WATER VAPOR ALGORITHM)
C
                TPW = COEFA* (COSZANG*B0*((ALOG(TSURF - AMSUAC2)) -
     >                (B1*ALOG(TSURF - AMSUAC1)) - B2)) +COEFB
                IF(TPW .LT. 0.0) TPW=0.0
                IF(TPW .GT. MAXLMT(1)) TPW=MAXLMT(1)
C
C CALCULATE CLOUD LIQUID WATER, CLW (AKA AMAANC(I,J,10))
C
                CLW = COSZANG*A0*((ALOG(TSURF - AMSUAC2)) -
     >                (A1*ALOG(TSURF - AMSUAC1)) - A2)
                IF(CLW .LT. 0.0) CLW=0.0
                IF(CLW .GT. MAXLMT(2)) THEN
                   CLW = MAXLMT(2)
                   TPW = MAXLMT(1)
                ENDIF
              ELSE
                TPW = R4SPV
                CLW = R4SPV
                SEAEMCH1 = R4SPV
                SEAEMCH2 = R4SPV
              ENDIF 
            ELSE
               TPW = R4SPV
               CLW = R4SPV
               SEAEMCH1 = R4SPV
               SEAEMCH2 = R4SPV
            ENDIF
            AMAANC(I,J,10) = CLW
C
C  CALCULATE THE SEA ICE CONCENTRATION
C
            IF(TERTYP .EQ. 0 .OR. TERTYP .EQ. 10 
     >         .AND. AMSUAC1 .NE. R4SPV .AND.
     >         (.NOT.(ISR4SPV(AMSUAC2))).AND.
     >         (.NOT.(ISR4SPV(AMSUAC3))).AND.
     >         (.NOT.(ISR4SPV(AMSUAC15)))) THEN
              CICE=0.0
              IF(AMAANC(I,J,1).GE.50.0 .OR. AMAANC(I,J,1).LE.-50.0)
     >          THEN
               EMICECH1 = (1.84 - 0.723*COSZANG) - 0.00088*AMSUAC1 +
     >                    ((0.0066+0.0029*COSZANG)*AMSUAC2) -
     >                    0.00926*AMSUAC3
               EMISH2O = 0.1824 + 0.9048*COSZANG - 0.6221*COSZANG**2
               IF((AMSUAC1 - AMSUAC2) .LT. 5.0) THEN
                   EI = 0.93
               ELSEIF ((AMSUAC1 - AMSUAC2).GE.5.0 .AND. (AMSUAC1 -
     >                 AMSUAC2).LE. 10.0) THEN 
                   EI = 0.87
               ELSEIF ((AMSUAC1 - AMSUAC2).GT.10.0) THEN
                   EI = 0.83
               ENDIF
               CICE= 100.0*(EMICECH1 - EMISH2O)/(EI - EMISH2O)
               IF(CICE .GT. 100.0) CICE =100.0
               IF(CICE .LE. 30.0) CICE = R4SPV
              ELSE
               CICE = R4SPV
               EMICECH1 = R4SPV
              ENDIF
            ELSE
              CICE = R4SPV
              EMICECH1 = R4SPV
            ENDIF 
C
C IF OVER LAND OR SNOW, CALCULATE SNOW COVER AND RAIN/NORAIN PARAMETERS
C FOR SNOW COVER 0= NO SNOW, 1=SNOW, 2=GLACIAL ICE
C
C MODIFED TO USE UPGRADE SNOWCOVER SOFTWARE. HOWEVER, NEW SOFTWARE USES 89GHZ 
C AMSU-B CHANNEL 1, FOR THE TIME BEING 89GHZ AMSU-A CHANNEL 15 WILL BE USED.
C (ASA, 11/06/02)
C

            IF(TERTYP .EQ. 1 .AND.
     >         (.NOT.(ISR4SPV(AMSUAC1))).AND.
     >         (.NOT.(ISR4SPV(AMSUAC2))).AND.
     >         (.NOT.(ISR4SPV(AMSUAC3))).AND.
     >         (.NOT.(ISR4SPV(AMSUAC15)))) THEN
               SNOWCOV=0.0
               SI31=AMSUAC1 - AMSUAC2 -2.0
               SI89=AMSUAC1 - AMSUAC15 - 3.0
C
C CHECK FOR GLACIAL ICE
C
               IF(AMSUAC1 .LT. 215.0 .AND. SI31 .LT. 3.0) SNOWCOV=2.0
C
C DETERMINE SNOW COVER
C
               IF(SI89 .GE. 1.0) THEN
                  SNOWCOV=1.0
               ELSE
                  SNOWCOV=0.0
               ENDIF

            ELSE
                SNOWCOV= R4SPV
            ENDIF

C
C STORE CLOUD LIQUID WATER CONTENT, TOTAL PRECIPITABLE WATER AND 
C SEA  ICE CONCENTRATION, SNOW COVER AND EMISSIVITY IN THE AMSU-A DATA
C BUFFER.
C
            AMADAT(I,J,16) = AMAANC(I,J,10) 
            AMADAT(I,J,17) = TPW 
            AMADAT(I,J,18) = CICE 
            IF(TERTYP .EQ. 1 .OR. TERTYP .EQ. 2 .OR.
     >         TERTYP .EQ. 11) THEN
               AMADAT(I,J,19) = LEMISCH1 
            ELSEIF(TERTYP .EQ. 0 .OR. TERTYP .EQ. 10) THEN
               IF (CICE .GT. 0.0) THEN 
                  AMADAT(I,J,19) = EMICECH1
               ELSE 
                  AMADAT(I,J,19) = SEAEMCH1 
               END IF
            ELSE
               AMADAT(I,J,19) = R4SPV
            ENDIF 
            AMADAT(I,J,20) = SNOWCOV
            IF(TERTYP .EQ. 1) AMADAT(I,J,24) = LEMISCH2 
            IF(TERTYP .EQ. 0) AMADAT(I,J,24) = SEAEMCH2 

C
C CALCULATE THE CLOUD CLEARED VERSION OF AMSU-A CHANNELS 4 AND 5 USING 
C CLOUD LIQUID WATER.  EMPIRICAL EQUATIONS DERIVED BY M. CHALFANT.

C ADD THE NEW PARAMETERS INTO THE AMSU-A DATA BUFFER.
C
C ADDED AMSU-A CHANNEL 6 TO BE CLOUD CLEARED
C
C REMOVED CHANNEL 6 AND THE LAND PROCESSING. ASA 3/28/00
C
C CHANGED THE METHOD OF REMOVED WATER VAPOR FROM AMSU-A CHANNELS
C 4 AND 5 FROM WR#56 TO WR#79. ASA - 5/11/00.
C
C ADDED A BIMODAL TEST USING AMSUA CHANNEL 6 
C ASA - 7/28/00

            AMADAT(I,J,21) = AMADAT(I,J,4)
            AMADAT(I,J,22) = AMADAT(I,J,5)
            AMADAT(I,J,23) = AMADAT(I,J,6)
C
C  ADDED COPIES OF AMSU-A CHANNELS 4 AND 5 SO THAT THEY CAN BE
C  PRECIPITATION SCREENED AND PLACED ON THE AODF IN POSITIONS 49
C  AND 50.
C
C  ADDED A COPY OF AMSU-A CHANNEL 6 TO BE PRECIPITATION SCREENED
C  IT WILL NOT BE PLACED ON THE AODF AT THIS TIME
C
C  REMOVED CHANNEL 6. ASA 3/28/00
C
            AMADAT(I,J,25) = AMADAT(I,J,4)
            AMADAT(I,J,26) = AMADAT(I,J,5) 
 
   40    CONTINUE
C
C   CHECK NEXT LINE.
C
   50 CONTINUE
C
      RETURN
      END

