MODULE YEMVARGP
USE PARKIND1  ,ONLY : JPIM     ,JPRB
IMPLICIT NONE
SAVE

! This module contains several parameters dealing with gridpoint computations
! for the analytical LAM Jb (Aladin-only).

! 2 kind of analytical formulations are at stake:

! * when called from SUEVARGP:
! define an analytical gridpoint function for a simply varying scalar field.
! The idea is to prescribe a function GVARGP which takes values of 0 in an
! interior domain, 1 in an outer domain, and a continuous set of values between 0
! and 1 in a rim zone in between:

! (1-Epsilon) * MAX(SIN(x)^Expvar , SIN(y)^Expvar)
! x=y=0 in the interior domain, and vary linearly in the rim zone

! This specification is mimicking the ALPHA function of Davies relaxation, but
! it is an independent one. 
! The scalar function (1.-GVARGP) is then used as a multiplying factor on all
! gridpoint Sigma_b values if LEVARGP = .T. 
! This development is kept in the code in order to possibly re-test in future a
! gridpoint constraint on Jb standard deviations in the Extension zone.

! * when called from SUEJBCOSU:
! define the application of compact support in gridpoint space, for bi-Fourier auto-regression
! functions, following Gaspari and Cohn (98).


! A detailed description of all parameters follows:

REAL(KIND=JPRB),ALLOCATABLE :: GVARGP(:)  ! data array for the scalar gridpoint function (DM-global)
REAL(KIND=JPRB) :: EVAREPSILON     ! small positive value to avoid exact zeroes in the Sigma_b's
REAL(KIND=JPRB) :: EXPVAR          ! exponent on the sine arch linking the zeroes and the ones (rim zone)
INTEGER(KIND=JPIM) :: NBZONVAR_EW  ! width of the rim zone in rows of longitude
INTEGER(KIND=JPIM) :: NBZONVAR_NS  ! width of the rim zone in rows of latitude 
LOGICAL :: LEVARGP                 ! key to activate GP analytical rim zone for Sigma_b's

LOGICAL :: LCORCOSU_AUTO           ! key to switch on compact support on all horizontal auto-correlations
LOGICAL :: LCORCOSU_STAT           ! key to switch on compact support on all statistical regressions
LOGICAL :: LCORCOSU_HBAL           ! key to switch on compact support on the linear horizontal balance
LOGICAL :: LSTREAM                 ! key to use streamfunction instead of vorticity in the linear hor. balance

REAL(KIND=JPRB) :: ENIL1, ENIL2, ENILHBAL1, ENILHBAL2
! radii for the gripoint masking functions to ensure compactly supported
! correlations in GP space:
! ENIL1 = start of mask for auto-correlations and statistical regressions (in km)
! ENIL2 = end of mask for auto-correlations and statistical regressions (in km)
! ENILHBAL1 = start of mask for the linear hor. balance (in km)
! ENILHBAL2 = end of mask for the linear hor. balance (in km)
END MODULE YEMVARGP
