!-------------------------------------- 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 sugemla 1,12
#if defined (DOC)
!
!**** *sugemla * - Definition of the geometry of the Limited-Area
! analysis and associated metric factors.
!
! Initialization of Limited-Area part of COMGEM
!
!
*Author : Luc Fillion - MSC/CAN - 16 Oct 2004.
*Revision:
*: Luc Fillion - ARMA/EC CAN - 27 Jan 2010. Remove call to sudxdy_lu. Done previously in sugrdlam.ftn
#endif
C
IMPLICIT NONE
#include "taglam4d.cdk"
#include "pardim.cdk"
#include "comdim.cdk"
#include "comlun.cdk"
#include "comct0.cdk"
#include "comcst.cdk"
#include "comgem.cdk"
#include "comgrd_param.cdk"
#include "comgrd.cdk"
#include "comgemla.cdk"
#include "namgem.cdk"
#include "comgdpar.cdk"
#include "rpnstd.cdk"
!
logical llprint
integer ji,jj,njp1
real*8 zdel,zlonbeg,zlatbeg,zlat
real*8 ztheta,ztheta1,ztheta2,z1,zcon
real*8 zdxin(mni_in,mnj_in), zdyin(mni_in,mnj_in)
real*8 zdx(ni,nj), zdy(ni,nj)
!
!!
WRITE(NULOUT,FMT='(/,'' SUGEMLA- Geometry of the Limited-Area'')')
!
!*1. Set Half Lat-Lon of the computational grid
! ------------------------------------------
!
llprint = .false.
!
do jj=-3,nj+3
rlath_an(jj)=(rlat_an(1,jj)+rlat_an(1,jj+1))*0.5
! write(nulout,*) 'sugemla: jj,rlath_an(jj)=',jj,rlath_an(jj)
enddo
!
!*2. Set Metric Factors
! ------------------
!
do ji=-4,ni+4
do jj=-3,nj+2
rrcos_an(1,jj)=1.0/cos(rlat_an(1,jj))
rrcosh_an(1,jj)=1.0/cos(rlath_an(jj))
enddo
enddo
if(llprint) then
do jj=-3,nj+2
write(nulout,*) 'sugemla: cos_an(1,jj)=',jj,cos(rlat_an(1,jj))
enddo
endif
!
do jj=-3,nj+2
ztheta1=rlat_an(1,jj)
ztheta2=rlat_an(1,jj+1)
rdmu(jj)=sin(ztheta2)-sin(ztheta1)
! write(nulout,*) 'sugemla: jj,rlat_an(1,jj)=',jj,rlat_an(1,jj)
! write(nulout,*) 'sugemla: jj,rlat_an(1,jj+1)=',jj,rlat_an(1,jj+1)
! write(nulout,*) 'sugemla: jj,rdmu(jj)=',jj,rdmu(jj)
if(rdmu(jj).le.0.) then
write(nulout,*) 'SUGEMLA: jj = ',jj
call abort3d
(nulout,'SUGEMLA: rdmu(jj).le.0.')
endif
enddo
!
do jj=-3,nj+2
ztheta=sin(rlath_an(jj))
ztheta1=sin(rlath_an(jj+1))
rdmuh(jj)= ztheta1-ztheta
! write(nulout,*) 'sugemla: jj,rdmuh(jj)=',jj,rdmuh(jj)
if(rdmuh(jj).le.0.) then
write(nulout,*) 'SUGEMLA: jj = ',jj
call abort3d
(nulout,'SUGEMLA: rdmuh(jj).le.0.')
endif
enddo
!
do jj=-3,nj+2
z1=(cos(rlat_an(1,jj)))**2
r1mmu2(jj)=z1
z1=(cos(rlath_an(jj)))**2
r1mmu2h(jj)=z1
if(r1mmu2(jj).le.0.) then
write(nulout,*) 'SUGEMLA: jj = ',jj
call abort3d
(nulout,'SUGEMLA: r1mmu2(jj).le.0.')
endif
! write(nulout,*) 'sugemla: jj,r1mmu2(jj),r1mmu2h(jj)=',jj,r1mmu2(jj),r1mmu2h(jj)
if(r1mmu2h(jj).le.0.) then
write(nulout,*) 'SUGEMLA: jj = ',jj
call abort3d
(nulout,'SUGEMLA: r1mmu2h(jj).le.0.')
endif
enddo
!
! Bi-periodize and symmetrize Metric coefficients etc.
!
njp1=nj+1
call mach2
(rdmu(1),1,nj,1,njp1)
call mach2
(rdmuh(1),1,nj,1,njp1)
call mach2
(r1mmu2(1),1,nj,1,njp1)
call mach2
(r1mmu2h(1),1,nj,1,njp1)
call symmetrize_coef
!
! Conversion of wind images to physical winds and vice-versa
! N.B.: Those are geometrical factors of the COMPUTATIONAL grid ==> only computational latitude variation...
!
do jj = 1, nj
conphy(jj) = rrcos_an(1,jj) ! to go from Wind Images to true winds
conima(jj) = 1.0/conphy(jj) ! to go from true winds to Wind Images
enddo
write(nulout,*) 'sugemla: conphy(25)=',conphy(25)
!
!*3. Set matrices for tridiagonal solver
! -----------------------------------
!
call settrila
('P') ! Psi grid
call settrila
('S') ! Scalar grid
!
!*4. Set matrices for Euclidean Laplacian and its inverse
! ----------------------------------------------------
!
call sulapxy
!
!
return
end