!-------------------------------------- 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 sugrd_param 1,6
! use mod4dv, only : l4dvar
#if defined (DOC)
!
!**** sugrd_param - Defines Analysis grid-type and rotation parameters.
! First letter is G or L "GU" for Global or Lam
! Second letter is U or V for Uniform or Variable mesh
!
! Initialization of part of comgrd (rest in sugrdpar.ftn)
!
! Modifications.
! --------------
*Author : L. Fillion ARMA/MSC Dec 2004 Limited area analysis.
*Revision: L. Fillion ARMA/MSC 31 Mar 2005 - Initialize only grid parameters without
! initialization of fields requiring grid dimensions. The latter is
! postponed to sugrdpar.
* L. Fillion ARMA/MSC May 2006: LAM4D upgrade to v10_0_0.
* L. Fillion ARMA/EC Sep 2009: Initialize grd_typ
* L. Fillion ARMA/EC 8 Oct 2009: Initializes rotation parameter of Global grid or LAM grid etc.
!
#endif
!
IMPLICIT NONE
#include "taglam4d.cdk"
#include "comct0.cdk"
#include "comdim.cdk"
#include "comlun.cdk"
#include "comgrd_param.cdk"
#include "comgdpar.cdk"
!#include "comcva.cdk"
!
integer ierr,ji,jj,j1,j2
integer ii0,ij0,Idum,Imargin
!
real zxlon1_4,zxlat1_4,zxlon2_4,zxlat2_4
!
real*8 a_8,b_8,c_8,d_8,xyz1_8(3),xyz2_8(3)
real*8 zrot_t(3,3),zunit(3,3)
!
!!
WRITE(nulout,FMT='(/,'' sugrd_param- Analysis Grid definition and parameters'')')
!
! default
grd_dx = 0.0
grd_dy = 0.0
grd_iref = 23
grd_jref = 23
grd_lonr = 180.
grd_latr = 0.
grd_xlon1=-96.2
grd_xlat1=35.
grd_xlon2=0.0
grd_xlat2=0.0
mextendx=0
mextendy=0
miobsbufw=1
miobsbufe=1
mjobsbufs=1
mjobsbufn=1
Glb_pil_n=0
Glb_pil_s=0
Glb_pil_e=0
Glb_pil_o=0
lpilot = .false.
!
CALL READNML
('NAMGRD',IERR) ! sets rotation parameters for Global or LAM analysis grid
!
write(nulout,*) 'sugrd_param:***********************'
write(nulout,*) 'sugrd_param: lpilot = ',lpilot
write(nulout,*) 'sugrd_param:***********************'
!
if(grd_typ.ne.'LU') then
if(grd_typ.ne.'GU') then
call abort3d
(nulout,'sugrd_param: ERROR: CHECK grd_typ in NAMGRD')
endif
endif
!
if(grd_typ.eq.'LU') then
if(mextendx.lt.7) then
write(nulout,*) 'sugrd_param: LAM4D analysis needs mextendx > 7'
!cluc call abort3d(nulout,'sugrd_param: LAM4D analysis needs mextendx > 7')
else if(mextendy.lt.7) then
write(nulout,*) 'sugrd_param: LAM4D analysis needs mextendy > 7'
!cluc call abort3d(nulout,'sugrd_param: LAM4D analysis needs mextendy > 7')
endif
endif
!
if(grd_typ.eq.'LU') then
!
! LA-Buffer zone used to exclude assimilation of observations near analysis walls
! (see brpacma.ftn)
!
write(nulout,*) 'sugrd_param: # of points West to exclude Obs. = ',miobsbufw
write(nulout,*) 'sugrd_param: # of points East to exclude Obs. = ',miobsbufe
write(nulout,*) 'sugrd_param: # of points South to exclude Obs. = ',mjobsbufs
write(nulout,*) 'sugrd_param: # of points North to exclude Obs. = ',mjobsbufn
!
if (miobsbufw.lt.1) then
write(nulout,*)' sugrd_param: miobsbufw.lt.1: ZERO BUFFER ZONE - CALL ABORT3D '
call abort3d
(nulout,'sugrd_param')
else if (miobsbufe.lt.1) then
write(nulout,*)' sugrd_param: miobsbufe.lt.1: ZERO BUFFER ZONE - CALL ABORT3D '
call abort3d
(nulout,'sugrd_param')
else if (mjobsbufs.lt.1) then
write(nulout,*)' sugrd_param: mjobsbufs.lt.1: ZERO BUFFER ZONE - CALL ABORT3D '
call abort3d
(nulout,'sugrd_param')
else if (mjobsbufn.lt.1) then
write(nulout,*)' sugrd_param: mjobsbufn.lt.1: ZERO BUFFER ZONE - CALL ABORT3D '
call abort3d
(nulout,'sugrd_param')
endif
endif
!
! Here we ensure no obs fall in the piloting zone since this may be a problem when obs. operators
! require LAM forecasted physical fields: e.g. TG. These physical output fields cover only "core" LAM grid.
! These physical fields will be read on their core grid later. Grid parameters are available on LAM output files
! and sugomobs.ftn for instance can properly do the required innovation computations.
!
! if(grd_typ.eq.'LU') then
! if (miobsbufw.le.Glb_pil_o) then
! write(nulout,*)' sugrd_param: miobsbufw.le.Glb_pil_o: - CALL ABORT3D '
! call abort3d(nulout,'sugrd_param')
! endif
! if (miobsbufe.le.Glb_pil_e) then
! write(nulout,*)' sugrd_param: miobsbufe.le.Glb_pil_e: - CALL ABORT3D '
! call abort3d(nulout,'sugrd_param')
! endif
! if (mjobsbufn.le.Glb_pil_n) then
! write(nulout,*)' sugrd_param: mjobsbufn.le.Glb_pil_n: - CALL ABORT3D '
! call abort3d(nulout,'sugrd_param')
! endif
! if (mjobsbufs.le.Glb_pil_s) then
! write(nulout,*)' sugrd_param: mjobsbufs.le.Glb_pil_s: - CALL ABORT3D '
! call abort3d(nulout,'sugrd_param')
! endif
! endif
!
! Check Analysis parameters are compatible with LAM Model Pilot parameters
!
! if(l4dvar) then
!! call checkanpar
! endif
!
! grd_xlon1_4 = grd_xlon1
! grd_xlat1_4 = grd_xlat1
! grd_xlon2_4 = grd_xlon2
! grd_xlat2_4 = grd_xlat2
!
! call cxgaig('E',mig1tic,mig2tic,mig3tic,mig4tic,
! & grd_xlat1_4,grd_xlon1_4,grd_xlat2_4,grd_xlon2_4)
!
! write(nulout,*) 'sugrd_param: '
! write(nulout,*) 'sugrd_param: mig1tic = ',mig1tic
! write(nulout,*) 'sugrd_param: mig2tic = ',mig2tic
! write(nulout,*) 'sugrd_param: mig3tic = ',mig3tic
! write(nulout,*) 'sugrd_param: mig4tic = ',mig4tic
! write(nulout,*) 'sugrd_param: '
!
!
return
end