!-------------------------------------- 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 sudxdy_lu(kfileid) 1
!
      IMPLICIT NONE
!
      integer kfileid
!
#if defined (DOC)
*
*s/r sudxdy_lu :
*     L. Fillion - ARMA/EC - 15 Aug 2008 - From sudxdy.ftn from C. Page.
*Revision:
*     L. Fillion - ARMA/EC - 27 Jan 2010 - Comment printout.
*-----------------------------------------------------------------------
*
*     Purpose: to compute grid point spacing in meters needed for
*              Limited-Area option.
*
*-----------------------------------------------------------------------
*
*     Argument: none
*
#endif
*
#include "taglam4d.cdk"
#include "pardim.cdk"
#include "comdim.cdk"
#include "comlun.cdk"
#include "comcst.cdk"
#include "comgrd_param.cdk"
#include "comgrd.cdk"
#include "comgemla.cdk"

      real rx(nila,njla), ry(nila,njla), zlat(nila,njla), zlon(nila,njla)
      real*8 un_deg_lon, un_deg_lat, cur_circ_eq, circ_pol, circ_eq
      real*8 z2pi
      integer gdllfxy
      integer ierr, ji, jj
      integer idum1,idum2,idum3,idum4
      real*8 zmin,zmax
!
!!

c     /* Earth circumference (polar and equatorial) */
!cluc      circ_pol = 2.0 * rpi * 6356.79 * 1000.0
      circ_eq  = 2.0 * rpi * 6378.17 * 1000.0
      circ_pol  = circ_eq

c     /* Distance in meters for 1 deg lat */
      z2pi = (2.*rpi)
      un_deg_lat = circ_pol / z2pi

      do jj=1,njla
        do ji=1,nila
!
!         Equatorial circumference at given latitude */
!
          cur_circ_eq = cos(rlat_an(1,jj)) * circ_eq
!
!         Distance in meters of 1 deg longitude */
!
          un_deg_lon = 1.0 * cur_circ_eq / z2pi
          un_deg_lat = 1.0 * circ_eq / z2pi
!
          dxlam(ji,jj) = rdlon_an(ji,jj)*un_deg_lon
          dylam(ji,jj) = rdlat_an(1,jj)*un_deg_lat
        enddo
      enddo
!
      do ji=1,1
        write(nulout,*) 'sudxdy_lu: dxlam(ji,1)=',dxlam(ji,1)
      enddo
      do jj=1,1
        write(nulout,*) 'sudxdy_lu: dylam(1,jj)=',dylam(1,jj)
      enddo
!
!      call maxmin(z2d,nila,njla,1,zmin,zmax,
!     &            idum1,idum2,idum3,idum4,'sudxdy_lu   ',
!     &            'DY')
!
      return
      end