!copyright (C) 2001  MSC-RPN COMM  %%%RPNPHY%%%
*** S/P FICEMXP
*

      SUBROUTINE FICEMXP (FICE, TF, DF, T, N, M, NK) 7
*
#include "impnone.cdk"
*
*
      INTEGER N, M, NK
      REAL FICE(N,NK), TF(N,NK), DF(N,NK)
      REAL T(M,NK)
*
*Author
*          J. Mailhot (Jan 2000)
*
*Object
*          Calculate the fraction of ice and set the values of threshold
*          and derivative w/r to T for computation of saturation values 
*          in the presence of mixed phases.
*
*Arguments
*
*          - Output -
* FICE     fraction of ice
* TF       threshold value for saturation w/r to ice or liquid
* DF       value of derivative w/r to T for saturation w/r to ice or liquid
*
*          - Input -
* T        temperature 
*
*          - Input -
* N        horizontal dimension
* M        first dimension of T
* NK       vertical dimension
*
*
*Notes
*          Based on the definition in: 
*          - Burk et al. 1997, JGR 102, 16529-16544
*          and the observations of:
*          - Curry et al. 1990, Int. J. Climatol. 10, 749-764.
*          - Curry et al. 1997, JGR 102, 13851-13860.
*
*          For F (fraction of ice), linear variation between Tmin and Tmax 
*          For TF and DF, values are set such that saturation is w/r to liquid for T > Tmin
*                 "         "             "        saturation is w/r to ice    for T < Tmin
*                                                
**
*
      INTEGER J, K
* 
      REAL DT
      REAL TMIN, TMAX
*
      SAVE TMIN, TMAX
      DATA TMIN, TMAX / 248.16, 258.16 /
*
      DT= 1.0/(TMAX-TMIN)
*                                              
      DO K=1,NK
      DO J=1,N
        FICE(J,K)= MAX( 0.0 , MIN( 1.0 , (TMAX-T(J,K))*DT ) )
        TF(J,K)= FICE(J,K)
        DF(J,K)= -DT
        IF( T(J,K).LT.TMIN .OR. T(J,K).GT.TMAX) DF(J,K) = 0.0
      END DO
      END DO
*
*
      RETURN
      END