!-------------------------------------- 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/r E_GENAB   - Using Laprise & Girard, generates de A and B of the
*                hybrid coordinate
*

      subroutine genab(frpia, frpib,   2
     +                 freta, frptop, frcoef, fnk)
#include "impnone.cdk"
*
*author s gravel  - rpn - nov 1998
*
*revision
* v1_03 - s edouard    -  correction d'une erreur ds la def de PIB
*
*language
*     fortran 77
*
*object(genab)
*    Using Laprise & Girard, generates de A and B of the hybrid coordinate
*    see: Laprise & Girard, 1990, J. of Climate, eq. 5.1
*
*arguments
      integer fnk    
      real    frpia(fnk), frpib(fnk), freta(fnk), frptop, frcoef
*
      integer k
*
      real prpref, pr1
*
*     BEWARE
*     if frcoef is greater than 1., prpref is subject to restriction for
*     stability reasons.
*
      prpref = 100.*frptop/freta(1)   ! convert to pascal
*

      pr1 = 1./(1. - freta(1))
      do k = 1,fnk
        frpib(k)  = ((freta(k) - freta(1))*pr1 ) ** frcoef
        frpia(k)  = prpref * ( freta(k) - frpib(k) )
      enddo
*
      return
      end