!-------------------------------------- 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 --------------------------------------
!
***S/P LATID - BAND INTERPOLATION FACTORS
*

      SUBROUTINE LATID(ZFACTOR,KLAT1,KLAT2,PLAT) 1
*
      IMPLICIT NONE
      INTEGER KLAT1,KLAT2
      REAL*8    ZFACTOR,PLAT,ZLAT,ZTORAD
*
#if defined (DOC)
*AUTHOR   - M. VALIN  RPN OCT 1984
*Revision:
*          . P. Koclas *CMC/AES February  1995:
*          . Conversion to "DOCTOR" CODING STANDARDS
*          . Removal of argument nlband
*
*OBJECT    - CALCULATION OF THE INTERPOLATION FACTOR
*         - DETERMINES THE INFERIOR AND SUPERIOR BANDS
*
*ARGUMENTS
*   o     - ZFACTOR - WEIGHT OF THE  SUPERIOR BAND(KLAT2)
*   o     - KLAT1   - INFERIOR BAND
*   o     - KLAT2   - SUPERIOR BAND
*   i     - PLAT    - LATITUDE (+VE NH,-VE SH)
*
*LANGAGE  - FORTRAN 77
*
*NOTE     -
*         - BANDS ARE IN COLATITUDE (N-S) ORDER
*         - ORIGINAL CODE WAS EXTRACTED FROM OI LIBRARY
**
#endif
*-------------------------------------------------------------
#include "comlun.cdk"
#include "comcst.cdk"
*
      ZTORAD=RPI/180.
      ZLAT= PLAT/ZTORAD
      IF(ZLAT .GE. 30.)THEN
        KLAT1   = 1
        KLAT2   = 1
        ZFACTOR = 1.
      ELSEIF(ZLAT.GE.00. .AND. ZLAT.LT.30.)THEN
        KLAT1   = 1
        KLAT2   = 2
        ZFACTOR = (30. - ZLAT)/30.
      ELSEIF(ZLAT.GT.-30. .AND. ZLAT.LT.00.)THEN
        KLAT1   = 2
        KLAT2   = 3
        ZFACTOR = (00. - ZLAT)/30.
      ELSEIF(ZLAT.LE.-30.)THEN
        KLAT1   = 3
        KLAT2   = 3
        ZFACTOR = 1.
      ELSE
        WRITE(NULOUT,*)' LATID: WRONG LATITUDE -LAT ',ZLAT
      ENDIF
*
      RETURN
      END