!-------------------------------------- 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 vllacar - transformation from a set of points (F_lat,F_lon) in 
*             the spherical coordinate system to cartesian space
*

      subroutine vllacar( F_xyz_8,F_lon,F_lat,ni,nj) 5
#include "taglam4d.cdk"
#include "comlun.cdk"
!include "impnone.cdk"
!ping      IMPLICIT NONE
      integer ni,nj 
      real*8 F_xyz_8(3,ni*nj)
      real F_lon(ni),F_lat(nj) 
*
*author: Luc Fillion from GEM subroutine from Michel Roch - April 90
*
*revision
* v2_00 - Lee V.            - initial MPI version (from llacar v1_03)
* v2_30 - Dugas B.          - output real*8 cartesian coordinates
*
*object
*     See above ID
*
*arguments
*  Name        I/O                 Description
*----------------------------------------------------------------
* F_xyz_8      O    - coordinates in cartesian space
* F_lon        I    - longitudes of the grid in spherical coordinates
* F_lat        I    - latitudes of the grid in spherical coordinates
*
**
      integer i,j,k 
      real*8, parameter :: ONE = 1.0d0, PI = 180.0d0
      real*8 deg2rad_8
*
*     __________________________________________________________________
*
      deg2rad_8 = acos(-ONE)/PI
*
      k=0 
      do j=1,nj
      do i=1,ni
         k=k+1
         F_xyz_8(1,K) = cos(deg2rad_8*F_lat(j))*cos(deg2rad_8*F_lon(i))
         F_xyz_8(2,K) = cos(deg2rad_8*F_lat(j))*sin(deg2rad_8*F_lon(i))
         F_xyz_8(3,K) = sin(deg2rad_8*F_lat(j))
      enddo
      enddo
*
*     __________________________________________________________________
*
      return
      end