C$$$  SUBPROGRAM DOCUMENTATION BLOCK 
C                .      .    .                                       . 
C SUBPROGRAM:    M_ESWINV      COMPUTE TEMPERATURE FOR ES
C   PRGMMR: STAN BENJAMIN    ORG: FSL/PROFS  DATE: 90-07-19 
C 
C ABSTRACT: FUNCTION TO COMPUTE THE TEMPERATURE(CELSIUS) 
C   CORRESPONDING TO THE SATURATION VAPOR PRESSURE. THE M_ESW(WOBUS) 
C   ROUTINE IS USED TO FIND THE INVERSE.
C 
C PROGRAM HISTORY LOG: 
C   90-04-19  STAN BENJAMIN    ORIGINAL VERSION
C   05-06-01  LEON BENJAMIN    ADDED LOWER LIMIT FOR TINY E.
C   05-11-18  LEON BENJAMIN    CHANGED LOWER LIMIT FROM
C                              9.99999935E-39 TO 
C                              9.99999935E-37 TO STOP A 
C                              COMPAQ COMPILER UNDERFLOW ERROR
C   08-06-13  LEON BENJAMIN    CHANGED "MADISCON" INCLUDE TO 
C                              "INTQC1CON1".
C 
C USAGE:    M_ESWINV(E)
C   INPUT ARGUMENT LIST: 
C     E            - REAL     SATURATION VAPOR PRESSURE IN MB.
C 
C   OUTPUT ARGUMENT LIST:   
C     M_ESWINV     - REAL     TEMPERATURE IN CELSIUS
C
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    M_ESW
C
C REMARKS: 
C 
C ATTRIBUTES: 
C   LANGUAGE: FORTRAN-77
C   MACHINE:  NAS-9000 
C$$$ 
        FUNCTION M_ESWINV(E)
C       E is the saturation vapor pressure in mb.
C       M_ESWINV is the temperature (Celsius) corresponding to ES.
C       The M_ESW (Wobus) routine is used to find the inverse.
 
C       T.W. Schlatter and S.G. Benjamin        19 April 1990


        INCLUDE 'IMPLICIT'
        INCLUDE 'INTQC1CON1'

        INTEGER I
        REAL M_ESWINV,E,E0,EE,T1,DE,EM1,M_ESW,EP1,DTDE

        IF(E.LE.9.99999935E-37)THEN 
           M_ESWINV = MISS_P
           RETURN
        ENDIF

        E0=6.107
          EE= ALOG(E/E0)
          T1= 243.5 * EE /(17.67-EE)
 
        DO 4 I = 1,10
          DE =  (E-M_ESW(T1))
          IF (ABS(DE).LT. 0.0001) GO TO 5
          EM1 = M_ESW(T1-0.01)
          EP1 = M_ESW(T1+0.01)
          DTDE = 0.02/(EP1-EM1)
4         T1 = T1 + DE * DTDE
5       M_ESWINV = T1
 
        RETURN
        END
C**---------------------------------------------------------------------
C**REQUIRED STANDARD FSL DISCLAIMER (NOVEMBER 2000)
C**---------------------------------------------------------------------
C**  OPEN SOURCE LICENSE/DISCLAIMER,  FORECAST SYSTEMS LABORATORY
C**  NOAA/OAR/FSL, 325 BROADWAY BOULDER, CO 80305
C**
C**  THIS SOFTWARE IS DISTRIBUTED UNDER THE OPEN SOURCE DEFINITION, 
C**  WHICH MAY BE FOUND AT http://www.opensource.org/osd.html.
C**
C**  IN PARTICULAR, REDISTRIBUTION AND USE IN SOURCE AND BINARY FORMS,
C**  WITH OR WITHOUT MODIFICATION, ARE PERMITTED PROVIDED THAT THE 
C**  FOLLOWING CONDITIONS ARE MET:
C**
C**  - REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THIS NOTICE, THIS LIST
C**    OF CONDITIONS AND THE FOLLOWING DISCLAIMER.
C**
C**  - REDISTRIBUTIONS IN BINARY FORM MUST PROVIDE ACCESS TO THIS 
C**    NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER, AND
C**    THE UNDERLYING SOURCE CODE.
C**
C**  - ALL MODIFICATIONS TO THIS SOFTWARE MUST BE CLEARLY DOCUMENTED, 
C**    AND ARE SOLELY THE RESPONSIBILITY OF THE AGENT MAKING THE 
C**    MODIFICATIONS.
C**
C**  - IF SIGNIFICANT MODIFICATIONS OR ENHANCEMENTS ARE MADE TO THIS
C**    SOFTWARE, THE FSL SOFTWARE POLICY MANAGER 
C**    (softwaremgr.fsl@noaa.gov) BE NOTIFIED.
C**
C**  THIS SOFTWARE AND ITS DOCUMENTATION ARE IN THE PUBLIC DOMAIN AND 
C**  ARE FURNISHED "AS IS."  THE AUTHORS, THE UNITED STATES GOVERNMENT,
C**  ITS INSTRUMENTALITIES, OFFICERS, EMPLOYEES, AND AGENTS MAKE NO 
C**  WARRANTY, EXPRESS OR IMPLIED, AS TO THE USEFULNESS OF THE SOFTWARE
C**  AND DOCUMENTATION FOR ANY PURPOSE.  THEY ASSUME NO RESPONSIBILITY 
C**  (1) FOR THE USE OF THE SOFTWARE AND DOCUMENTATION; OR (2) TO 
C**  PROVIDE TECHNICAL SUPPORT TO USERS.
C**---------------------------------------------------------------------
