!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!

      SUBROUTINE TRIMES (PLOWBOUND,PHIGHBOUND) 1
#if defined (DOC) 
*
***   s/r TRIMES  - To trim ES so that PLOWBOUND <= ES <= PHIGHBOUND
*     .             (applied to the analysis only for cosmetic purposes)
*
*Author  : P. Gauthier *ARMA/AES  Sept. 20, 1993
*     . 
*Revision:
**
*Arguments
*     PHIGHBOUND :  upper bound
*     PLOWBOUND  :  lower bound
*
#endif
C
      IMPLICIT NONE
#include "pardim.cdk"
#include "comdim.cdk"
#include "comlun.cdk"
#include "comgem.cdk"
#include "comgd0.cdk"
C
*     Arguments
*
      REAL*8 PLOWBOUND, PHIGHBOUND
C
*     Local variables
*
      INTEGER JLEV, JLAT, JLON, ICOUNTLOW, ICOUNTHIGH, ILON
*
      ICOUNTLOW  = 0
      ICOUNTHIGH = 0
*
      DO JLEV = 1, NFLEV
         DO JLAT = 1, NJ
            ILON = NILON(JLAT)
            DO JLON = 1, ILON
               IF(Q0(JLON,JLEV,JLAT).LT.PLOWBOUND) THEN
                  ICOUNTLOW = ICOUNTLOW + 1
                  Q0(JLON,JLEV,JLAT) = PLOWBOUND
               END IF
               IF(Q0(JLON,JLEV,JLAT).GT.PHIGHBOUND) THEN
                  ICOUNTHIGH = ICOUNTHIGH + 1
                  Q0(JLON,JLEV,JLAT) = PHIGHBOUND
               END IF
            END DO
         END DO
      END DO
*
      WRITE(NULOUT,9100)PLOWBOUND,ICOUNTLOW,PHIGHBOUND,ICOUNTHIGH
 9100 FORMAT(//,10x,'Correction to the humidity analysis',/
     S     ,15x,'NUMBER OF POINTS WITH Q0 < ',G12.6,' :',I6,/
     S     ,15x,'NUMBER OF POINTS WITH Q0 > ',G12.6,' :',I6)
*
      RETURN
      END