!-------------------------------------- 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 uv_acg2g_tr - To obtain the i,j boundaries
*
#include "model_macros_f.h"
*

      subroutine uv_acg2g_tr (F_gridi,F_grido,F_i0,F_in,F_j0,F_jn) 4
#include "impnone.cdk"
*
      integer F_i0,F_in,F_j0,F_jn
      integer F_gridi, F_grido
*
*author 
*     S. Laroche        - Febuary 2002
*
*revision
* v3_00 - Laroche S.    - initial MPI version 
*
*object
*     Subroutine to obtain the i,j boundaries for uv_acg2g_ad
*
*arguments
*  Name        I/O                 Description
*----------------------------------------------------------------
* F_gridi      I    - type of input grid : 0 - scalar-grid
*                                          1 - u-grid
*                                          2 - v-grid
* F_grido      I    - type of output grid: see F_gridi    
* F_i0         O    - starting point of computation on W-E axis
* F_in         O    - ending   point of computation on W-E axis
* F_j0         O    - starting point of computation on N-S axis
* F_jn         O    - ending   point of computation on N-S axis
*
*implicits
#include "glb_ld.cdk"
#include "schm.cdk"
*
*modules
**
      logical cubic
      integer i,j,k
*-----------------------------------------------------------------
*
      cubic = Schm_adcub_L

      if (F_grido .eq. F_gridi) then
         F_i0 = 1
         F_in = l_ni
         F_j0 = 1
         F_jn = l_nj
      endif

      if ( F_gridi .eq. 1 .and. F_grido .eq. 0) then
         F_i0 = 1
         F_in = l_niu
         F_j0 = 1
         F_jn = l_nj
         if ((G_lam).and.(l_west)) then
            F_i0 = 2
            if (cubic) F_i0 = 3
         endif
         if ((G_lam).and.(l_east).and.(cubic)) F_in = l_niu-1
      endif

      if ( F_gridi .eq. 2 .and. F_grido .eq. 0) then
         F_i0 = 1
         F_in = l_ni
         F_j0 = 1
         F_jn = l_njv
         if (cubic) then
            if (l_south) F_j0 = 3
            if (l_north) F_jn = l_njv - 1
         else
            if (l_south) F_j0 = 2
         endif
         if (.not.G_lam) then
            F_j0 = 1
            F_jn = l_nj
         endif
      endif
*
*     ------------------- NEW OPTIONS--------------------------------
*               Linear interpolation not coded yet
*
      if ( F_gridi .eq. 0 .and. F_grido .eq. 1) then
         F_i0 = 1
         F_in = l_niu
         F_j0 = 1
         F_jn = l_nj
         if ((G_lam).and.(l_west)) F_i0 = 2
         if ((G_lam).and.(l_east)) F_in = l_niu-1
      endif

      if ( F_gridi .eq. 0 .and. F_grido .eq. 2) then
         F_i0 = 1
         F_in = l_ni
         F_j0 = 1
         F_jn = l_njv
         if (l_south) F_j0 = 2
         if (l_north) F_jn = l_njv - 1
         if (.not.G_lam) then
            F_j0 = 1
            F_jn = l_njv
         endif
      endif
*
      return
      end