Newer
Older
!MNH_LIC Copyright 1994-2021 CNRS, Meteo-France and Universite Paul Sabatier
!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence

WAUTELET Philippe
committed
!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
!MNH_LIC for details. version 1.
!-----------------------------------------------------------------
! #######################
MODULE MODI_SET_PERTURB
! #######################
!
INTERFACE
!
SUBROUTINE SET_PERTURB(TPEXPREFILE)
!

WAUTELET Philippe
committed
USE MODD_IO, ONLY: TFILEDATA
!
TYPE(TFILEDATA), INTENT(IN) :: TPEXPREFILE ! input data file
!
END SUBROUTINE SET_PERTURB
!
END INTERFACE
!
END MODULE MODI_SET_PERTURB
!
! ##############################
SUBROUTINE SET_PERTURB(TPEXPREFILE)
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
! ##############################
!
!!**** *SET_PERTURB* - add a perturbation to a larger scale state field
!!
!! PURPOSE
!! -------
! The purpose of this routine is to add a perturbation to a balanced
! mass and wind fields. This perturbation is added either to the theta
! field to initiate either a convective development, or to the wind field
! to initiate a normal mode selection or ...
!
!!** METHOD
!! ------
!!
!! An analytical function is used to prescribe the theta perturbation
!! variation and a stream function is used to set the wind perturbation in
!! not to create a divergent field.
!!
!!
!! EXTERNAL
!! --------
!! NONE
!!
!! IMPLICIT ARGUMENTS
!! ------------------
!! Module MODD_PARAMETERS : contains parameters
!! JPHEXT : number of horizontal external points
!! JPVEXT : number of vertical external points
!! Module MODD_GRID1 : contains grid variables
!! XXHAT : Position x in the conformal
!! plane or on the cartesian plane
!! XYHAT : Position y in the conformal
!! plane or on the cartesian plane
!! XZHAT : Position z in the grid without orography
!! Module MODD_CST : contains physical constants
!! XPI : pi
!! Module MODD_FIELD1 : contains prognostic variables
!! XTHT : potential temperature
!! XUT : x-component of the wind
!! XVT : y-component of the wind
!! Module MODD_CONF : model configuration
!! L2D : switch for 2D configuration
!! Module MODD_DIM1 : model dimensions
!! NIMAX,NJMAX
!! Module MODD_LBC1 : model lateral boudary conditions
!! CLBCX(2),CLBCY(2)
!!
!! REFERENCE
!! ---------
!!
!! Book2 subroutine SET_PERTURB
!!
!! AUTHOR
!! ------
!! J.Stein * Meteo France *
!!
!! MODIFICATIONS
!! -------------
!! Original 6/12/94
!! I.Mallet and J.Stein 07/01/95 add the perturbation for the wind field
!! J. Stein 16/03/95 remove R from the historical variables
!! J. Stein 16/03/95 remove MODD_REF1 which is not used
!! P. Mascart 01/09/95 change the bubble center computation
!! J. Stein+F. Lohou 06/02/96 add the white noise perturbation
!! J.-P. Pinty 06/12/96 add the argument list to control the
!! perturbation type, amplitude and location
!! J-P Pinty P Jabouille 30/08/00 parallelization of the code
!! I. Mallet 06/06 cleaning (namelist inside the routine)
!! J.Escobar 25/03/2012 optim. parallelization of White noise
!! J.Escobar 27/03/2012 force identical random seed & correct XOR/YOR global shift
!! J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1
!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O

Gaelle DELAUTIER
committed
!! C.Lac, V.Masson 1/2018 : White noise in the LBC

RODIER Quentin
committed
!! Q.Rodier 10/2018 : move allocate(ZWHITE) for NKWH>2

WAUTELET Philippe
committed
! P. Wautelet 26/04/2019: replace non-standard FLOAT function by REAL function

RODIER Quentin
committed
!! J.L Redelsperger 03/2021 : : white noise in Ocean LES case at the top of domain(Sfc)
!!
!-------------------------------------------------------------------------------
!
!* 0. DECLARATIONS
! ------------
!
USE MODD_CST
USE MODD_CONF

RODIER Quentin
committed
USE MODD_DYN_n, ONLY : LOCEAN
USE MODD_FIELD_n
USE MODD_GRID_n

WAUTELET Philippe
committed
USE MODD_IO, ONLY: TFILEDATA

WAUTELET Philippe
committed
USE MODD_LUNIT_n, ONLY: TLUOUT

Gaelle DELAUTIER
committed
USE MODD_LSFIELD_n
USE MODD_PARAMETERS

RODIER Quentin
committed
USE MODD_REF

WAUTELET Philippe
committed
USE MODD_VAR_ll , ONLY : NMNH_COMM_WORLD
USE MODE_GATHER_ll
USE MODE_ll
USE MODE_MPPDB
USE MODE_POS

WAUTELET Philippe
committed
use MODE_SCATTER_ll, only: SCATTER_XYFIELD
USE MODI_GET_HALO
!
IMPLICIT NONE
!
!* 0.1 Declarations of arguments
!
TYPE(TFILEDATA), INTENT(IN) :: TPEXPREFILE ! input data file
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
!
!* 0.2 Declarations of local variables
!
INTEGER :: ILUPRE,IRESP ! logical unit number of the EXPRE and FM return code
INTEGER :: ILUOUT ! Logical unit number for output-listing
LOGICAL :: GFOUND ! Return code when searching namelist
!
REAL, DIMENSION(SIZE(XXHAT),SIZE(XYHAT),SIZE(XZHAT)) :: ZDIST ! distance
! from the center of the
! disturbance
REAL :: ZCENTERX,ZCENTERY ! coordinates of the disturbance center
INTEGER :: IIB,IJB,IKB ! Begining useful area in x,y,z directions
INTEGER :: IIE,IJE,IKE ! End useful area in x,y,z directions
INTEGER :: IIU,IJU,IKU ! Array sizes in i,j,k directions
INTEGER :: JI,JJ,JK ! Loop indexes along the x,y,z directions
INTEGER :: IJ0 ! J value of the center of the perturb.
INTEGER :: IJMIN,IJMAX ! J values for the y-width of the perturb.
REAL,DIMENSION(:,:),ALLOCATABLE :: ZPHI_ll ! stream function
REAL,DIMENSION(:,:),ALLOCATABLE :: ZPU_ll,ZPV_ll ! hor. wind components
REAL,DIMENSION(:,:),ALLOCATABLE :: ZPU,ZPV
REAL :: ZX, ZY, ZRANDOM, ZT1, ZT2, ZAL, ZBL, ZCL, ZDL, ZVAR
INTEGER :: IKX, IKY, JX, JY ! loop index in Fourier space
REAL,DIMENSION(:,:),ALLOCATABLE :: ZWHITE ! white noise perturbation
REAL,DIMENSION(:,:),ALLOCATABLE :: ZWHITE_ll ! global ZWHITE
REAL,DIMENSION(:,:),ALLOCATABLE :: ZCX_ll,ZSX_ll ! Fourier coefficient for x
REAL,DIMENSION(:,:),ALLOCATABLE :: ZCY_ll,ZSY_ll ! and y directions
!
REAL, DIMENSION(SIZE(XXHAT),SIZE(XYHAT),SIZE(XZHAT)) :: ZT ! temperature
REAL, DIMENSION(SIZE(XXHAT),SIZE(XYHAT),SIZE(XZHAT)) :: ZHU ! rel. humidity
!
REAL, DIMENSION(:), ALLOCATABLE :: ZXHAT_ll ! Position x in the conformal
! plane (array on the complete domain)
REAL, DIMENSION(:), ALLOCATABLE :: ZYHAT_ll ! Position y in the conformal
! plane (array on the complete domain)
INTEGER :: IIU_ll,IJU_ll ! horizontal,vertical size of the extended global domain
INTEGER :: IIB_ll,IJB_ll ! global coordinate of the physical global domain
INTEGER :: IIE_ll,IJE_ll !
!
!* 0.3 Namelist declarations
!
CHARACTER(LEN=2) :: CPERT_KIND='TH'! Perturbation type
REAL :: XAMPLITH=1.5 ! Perturbation amplitude maximum for THETA
REAL :: XAMPLIRV=0.0 ! Perturbation amplitude maximum for R_V
REAL :: XAMPLIUV=1.083367E6
! Perturbation amplitude maximum for U and V
! initially XAMPLIUV=1.7E5/(2*SIN(XPI/40.))
REAL :: XAMPLIWH=0.1 ! Perturbation amplitude maximum for the
! WHite noise

Gaelle DELAUTIER
committed
LOGICAL :: LWH_LBXU=.FALSE.! White noise in inflow and outflow LBC of U
LOGICAL :: LWH_LBYV=.FALSE.! White noise in inflow and outflow LBC of V
INTEGER :: NKWH=2 ! Upper level of the layer
! where white noise is applied
LOGICAL :: LSET_RHU=.TRUE.! Conservation of the Relative HUmidity when
! TRUE
REAL :: XCENTERZ=2000. ! Height of the maximum of TH perturbation
REAL :: XRADX= 10000. ! X-Radius of the perturbation
REAL :: XRADY= 10000. ! Y-Radius of the perturbation
REAL :: XRADZ= 2200. ! Z-Radius of the perturbation
!
INTEGER, PARAMETER :: i_seed_param = 26032012
INTEGER, DIMENSION(:), ALLOCATABLE :: i_seed
INTEGER :: ni_seed
!
INTEGER :: IXOR,IYOR,JI_ll,JJ_ll

RODIER Quentin
committed
INTEGER :: INOISB,INOISE ! Loop indice for White noise
!
NAMELIST/NAM_PERT_PRE/CPERT_KIND,XAMPLITH, &! Perturbation parameters
XAMPLIRV,XCENTERZ,XRADX, &!
XRADY,XRADZ,LSET_RHU, &
XAMPLIUV,XAMPLIWH,NKWH,LWH_LBXU,LWH_LBYV
!-------------------------------------------------------------------------------
!
!* 1. PROLOGUE :
! ----------
!
!* 1.1 Retrieve unit numbers and read namelist
!
ILUPRE = TPEXPREFILE%NLU
ILUOUT = TLUOUT%NLU
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
!
CALL POSNAM(ILUPRE,'NAM_PERT_PRE',GFOUND,ILUOUT)
IF (GFOUND) READ(UNIT=ILUPRE,NML=NAM_PERT_PRE)
!
! Distribue/set identical parameter seed to all the proc
!
CALL RANDOM_SEED(SIZE=ni_seed) ! get size of seed
ALLOCATE(i_seed(ni_seed))
i_seed(:) = i_seed_param !
CALL RANDOM_SEED(PUT=i_seed)
!
!
!* 1.2
!
IIU=SIZE(XXHAT)
IJU=SIZE(XYHAT)
IKU=SIZE(XZHAT)
IKB=1+JPVEXT
IKE=IKU-JPVEXT
!
IIB=JPHEXT+1
IIE=IIU-JPHEXT
IJB=JPHEXT+1
IJE=IJU-JPHEXT
!
IIU_ll=NIMAX_ll+2*JPHEXT
IJU_ll=NJMAX_ll+2*JPHEXT
ALLOCATE(ZXHAT_ll(IIU_ll),ZYHAT_ll(IJU_ll))
CALL GATHERALL_FIELD_ll('XX',XXHAT,ZXHAT_ll,IRESP)
CALL GATHERALL_FIELD_ll('YY',XYHAT,ZYHAT_ll,IRESP)
!
CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
IIB_ll=1+JPHEXT
IJB_ll=1+JPHEXT
IIE_ll=IIU_ll-JPHEXT
IJE_ll=IJU_ll-JPHEXT
!
CALL GET_OR_ll('B',IXOR,IYOR)
!

RODIER Quentin
committed
IF (LOCEAN) THEN
INOISB=NKWH
INOISE=IKE
ELSE

WAUTELET Philippe
committed
INOISB=IKB

RODIER Quentin
committed
INOISE=NKWH
ENDIF
!-------------------------------------------------------------------------------
!
!* 2. COMPUTE THE PERTURBATION ON THETA :
! -----------------------------------
!
SELECT CASE(CPERT_KIND)
CASE('TH')
ZDIST(:,:,:) = 2.
! C grid shift
ZCENTERX=(ZXHAT_ll(2)+ZXHAT_ll(IIU_ll))*0.5
ZCENTERY=(ZYHAT_ll(2)+ZYHAT_ll(IJU_ll))*0.5
!
DO JK =IKB,IKE
DO JJ = IJB,IJE
DO JI = IIB,IIE
ZDIST(JI,JJ,JK) = SQRT( &
(( (XXHAT(JI)+XXHAT(JI+1))*0.5 - ZCENTERX ) / XRADX)**2 + &
(( (XYHAT(JJ)+XYHAT(JJ+1))*0.5 - ZCENTERY ) / XRADY)**2 + &
(( (XZHAT(JK)+XZHAT(JK+1))*0.5 - XCENTERZ ) / XRADZ)**2 &
)
END DO
END DO
END DO
!
CALL MPPDB_CHECK3D(ZDIST,"SET_PERTURB::ZDIST",PRECISION)

WAUTELET Philippe
committed
!CALL MPPDB_CHECK3D(XTHM,"SET_PERTURB::XTHM",PRECISION)
!
IF ( LSET_RHU) THEN
ZT(:,:,:) = 0.0
ZHU(:,:,:) = 0.0
WHERE ( ZDIST(:,:,:) <= 1.)
!
! save the actual relative humidity
!
ZT(:,:,:) =XTHT(:,:,:)*(XPABST(:,:,:)/XP00) **(XRD/XCPD)
ZHU(:,:,:) = (XRT(:,:,:,1)*XPABST(:,:,:)) / (((XMV/XMD)+XRT(:,:,:,1))* &
EXP( XALPW - XBETAW/ZT(:,:,:) - XGAMW*ALOG(ZT(:,:,:)) ))
!
! set the perturbation for Theta
!
XTHT(:,:,:) = XTHT(:,:,:) + XAMPLITH * COS (XPI*0.5*ZDIST(:,:,:)) **2
!
! compute the new vapor pressure (stored in ZHU!)
!
ZT(:,:,:) =XTHT(:,:,:)*(XPABST(:,:,:)/XP00) **(XRD/XCPD)
ZHU(:,:,:) = ZHU(:,:,:)* &
EXP( XALPW - XBETAW/ZT(:,:,:) - XGAMW*ALOG(ZT(:,:,:)) )
!
! set the perturbation for r_v such that the relative humidity is conserved
!
XRT(:,:,:,1) = (XMV/XMD) * ZHU(:,:,:) / ( XPABST(:,:,:) - ZHU(:,:,:) )
END WHERE
CALL MPPDB_CHECK3D(ZT,"SET_PERTURB::ZT",PRECISION)
CALL MPPDB_CHECK3D(ZHU,"SET_PERTURB::ZHU",PRECISION)
ELSE
WHERE ( ZDIST(:,:,:) <= 1.)
XTHT(:,:,:) = XTHT(:,:,:) + XAMPLITH * COS (XPI*0.5*ZDIST(:,:,:)) **2
XRT(:,:,:,1) = XRT(:,:,:,1) + XAMPLIRV * COS (XPI*0.5*ZDIST(:,:,:)) **2
CALL MPPDB_CHECK3D(XRT(:,:,:,1),"SET_PERTURB::XRT",PRECISION)

WAUTELET Philippe
committed
!CALL MPPDB_CHECK3D(XTHM,"SET_PERTURB::XTHM",PRECISION)
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
!
!-------------------------------------------------------------------------------
!
!* 3. COMPUTE THE PERTURBATION ON THE WIND :
! --------------------------------------
!
CASE('UV')
IJ0 = IJU_ll/2
IJMIN = IJ0 - NINT(IJU_ll*3./8.)
IJMAX = IJ0 + NINT(IJU_ll*3./8.)
ALLOCATE(ZPHI_ll(IIU_ll,IJU_ll))
ALLOCATE(ZPU_ll(IIU_ll,IJU_ll))
ALLOCATE(ZPV_ll(IIU_ll,IJU_ll))
!
!* 3.1 stream function at vorticity point :
!
DO JI = 1,IIU_ll
DO JJ = 1,IJU_ll
ZPHI_ll(JI,JJ) = XAMPLIUV*EXP(-((ZYHAT_ll(JJ)-ZYHAT_ll(IJ0))/XRADY)**2) &
* COS(2.*XPI/XRADX*ZXHAT_ll(JI))
END DO
END DO
!
!* 3.2 Wind perturbation :
!
DO JI = 1,IIU_ll
DO JJ = IJMIN,IJMAX
ZPU_ll(JI,JJ) = (ZPHI_ll(JI,JJ+1)-ZPHI_ll(JI,JJ)) / (-ZYHAT_ll(JJ+1)+ZYHAT_ll(JJ) )
ZPV_ll(JI,JJ) = (ZPHI_ll(JI+1,JJ)-ZPHI_ll(JI,JJ)) / ( ZXHAT_ll(JI+1)-ZXHAT_ll(JI) )
END DO
END DO
!
DO JJ = 1,IJMIN-1
ZPU_ll(:,JJ) = ZPU_ll(:,IJMIN)
ZPV_ll(:,JJ) = ZPV_ll(:,IJMIN)
END DO
DO JJ = IJMAX+1,IJU_ll
ZPU_ll(:,JJ) = ZPU_ll(:,IJMAX)
ZPV_ll(:,JJ) = ZPV_ll(:,IJMAX)
END DO
!
!* 3.3 Add to the U and V fields :
!
ALLOCATE(ZPU(IIU,IJU),ZPV(IIU,IJU))

WAUTELET Philippe
committed
CALL SCATTER_XYFIELD(ZPU_ll,ZPU,1,NMNH_COMM_WORLD)
CALL SCATTER_XYFIELD(ZPV_ll,ZPV,1,NMNH_COMM_WORLD)
DEALLOCATE(ZPU_ll,ZPV_ll)
DO JI = 1,IIU
DO JJ = 1,IJU
END DO
END DO
DO JJ = 1,IJU
DO JI = 1,IIU
END DO
END DO
DEALLOCATE(ZPU,ZPV)
!
!
CASE('WH','WW') ! white noise is computed on global domain
! J.Escobar optim => need only identical random on all domain

RODIER Quentin
committed
!
ALLOCATE(ZWHITE(IIU,IJU))

RODIER Quentin
committed
DO JK = INOISB,INOISE
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
IKX = (NIMAX_ll+1)/2
ZX = 2*XPI/NIMAX_ll
ALLOCATE(ZCX_ll(IIU_ll,IKX))
ALLOCATE(ZSX_ll(IIU_ll,IKX))
IKY = (NJMAX_ll+1)/2
ALLOCATE(ZCY_ll(IJU_ll,IKY))
ALLOCATE(ZSY_ll(IJU_ll,IKY))
!
DO JX = 1, IKX
DO JI = IIB_ll,IIE_ll
ZCX_ll(JI,JX) = COS(ZX*JX*(JI-IIB_ll))
ZSX_ll(JI,JX) = SIN(ZX*JX*(JI-IIB_ll))
END DO
END DO
IKY = (NJMAX_ll+1)/2
ZY = 2*XPI/NJMAX_ll
DO JY = 1, IKY
DO JJ = IJB_ll,IJE_ll
ZCY_ll(JJ,JY) = COS(ZY*JY*(JJ-IJB_ll))
ZSY_ll(JJ,JY) = SIN(ZY*JY*(JJ-IJB_ll))
END DO
END DO
!
ZWHITE(:,:) = 0.0
!
DO JY = 1, IKY
DO JX = 1, IKX
CALL RANDOM_NUMBER(ZRANDOM)
ZT1 = 2*XPI*ZRANDOM
ZAL = SIN(ZT1)
ZBL = COS(ZT1)
IF ( .NOT. L2D ) THEN
CALL RANDOM_NUMBER(ZRANDOM)
ZT2 = 2*XPI*ZRANDOM
ZCL = SIN(ZT2)
ZDL = COS(ZT2)
ELSE
ZCL=0.
ZDL=0.
END IF
!
DO JJ = IJB,IJE
ZWHITE(JI,JJ) = ZWHITE(JI,JJ)+ &
(ZBL+ZDL)*ZSX_ll(JI_ll,JX)*ZCY_ll(JJ_ll,JY) + &
(ZAL+ZCL)*ZCX_ll(JI_ll,JX)*ZCY_ll(JJ_ll,JY) + &
(ZCL-ZAL)*ZSX_ll(JI_ll,JX)*ZSY_ll(JJ_ll,JY) + &
(ZBL-ZDL)*ZCX_ll(JI_ll,JX)*ZSY_ll(JJ_ll,JY)
END DO
END DO
END DO
END DO
DEALLOCATE(ZCX_ll,ZSX_ll,ZCY_ll,ZSY_ll)
!

WAUTELET Philippe
committed
ZVAR= SUM_DD_R2_ll( (ZWHITE(IIB:IIE,IJB:IJE))**2 )/REAL(NIMAX_ll*NJMAX_ll)
CALL MPPDB_CHECK2D(ZWHITE,"SET_PERTURB::ZWHITE",PRECISION)
ZWHITE(:,:) = ZWHITE(:,:)/SQRT(ZVAR)
!
!!$ CALL GET_HALO(XTHM)
CALL MPPDB_CHECK2D(XTHM(:,:,JK),"SET_PERTURB::XTHM",PRECISION)
CALL MPPDB_CHECK2D(ZWHITE,"SET_PERTURB::ZWHITE",PRECISION)
IF (CPERT_KIND=='WH') THEN ! white noise on theta
XTHT(:,:,JK) = XTHT(:,:,JK) + XAMPLIWH * ZWHITE(:,:)
CALL MPPDB_CHECK2D(XTHT(:,:,JK),"SET_PERTURB::XTHT",PRECISION)
XWT(:,:,JK) = XWT(:,:,JK) + XAMPLIWH * ZWHITE(:,:)
XUT(:,:,JK) = XUT(:,:,JK) + XAMPLIWH * ZWHITE(:,:)
XVT(:,:,JK) = XVT(:,:,JK) + XAMPLIWH * ZWHITE(:,:)

Gaelle DELAUTIER
committed
!
! white noise for inflow/outflow U field in X direction
!

RODIER Quentin
committed
IF (LWH_LBXU) THEN
ALLOCATE(ZWHITE_ll(IIU_ll,IJU_ll))
CALL GATHERALL_FIELD_ll('XY',ZWHITE,ZWHITE_ll,IRESP)
DO JK=1,MIN(IKU,IIU_ll)
DO JI=1,SIZE(XLBXUM,1)
XLBXUM(JI,:,JK) = XLBXUM(JI,:,JK) + XAMPLIWH * ZWHITE_ll(JK,:)
END DO
END DO
DEALLOCATE(ZWHITE_ll)
END IF

Gaelle DELAUTIER
committed
!
! white noise for inflow/outflow V field in Y direction
!

RODIER Quentin
committed
IF (LWH_LBYV) THEN
ALLOCATE(ZWHITE_ll(IIU_ll,IJU_ll))
CALL GATHERALL_FIELD_ll('XY',ZWHITE,ZWHITE_ll,IRESP)
DO JK=1,MIN(IKU,IJU_ll)
DO JJ=1,SIZE(XLBXVM,2)
XLBXVM(:,JJ,JK) = XLBXVM(:,JJ,JK) + XAMPLIWH * ZWHITE_ll(JK,:)
END DO
END DO
DEALLOCATE(ZWHITE_ll)
END IF

Gaelle DELAUTIER
committed

RODIER Quentin
committed
DEALLOCATE(ZWHITE)
CALL GET_HALO(XTHT)
CALL GET_HALO(XUT)
CALL GET_HALO(XVT)
CALL GET_HALO(XWT)
CALL MPPDB_CHECK3D(XTHT,"SET_PERTURB::XTHT",PRECISION)
CALL MPPDB_CHECK3D(XUT,"SET_PERTURB::XUT",PRECISION)
CALL MPPDB_CHECK3D(XVT,"SET_PERTURB::XVT",PRECISION)
CALL MPPDB_CHECK3D(XWT,"SET_PERTURB::XWT",PRECISION)
CALL MPPDB_CHECK3D(XRT(:,:,:,1),"SET_PERTURB::XRT",PRECISION)
!-------------------------------------------------------------------------------
!
!* 4. LATERAL BOUNDARY CONDITIONS :
! -----------------------------
!
!
IF (CPERT_KIND=='WH') THEN ! white noise on theta
IF (LWEST_ll() .AND. CLBCX(1)/='CYCL') &
XTHT(IIB-1,:,IKB) = 2. * XTHT(IIB,:,IKB) - XTHT(IIB+1,:,IKB)
IF (LEAST_ll() .AND. CLBCX(1)/='CYCL') &
XTHT(IIE+1,:,IKB) = 2. * XTHT(IIE,:,IKB) - XTHT(IIE-1,:,IKB)
IF (LSOUTH_ll() .AND. CLBCY(1)/='CYCL') &
XTHT(:,IJB-1,IKB) = 2. * XTHT(:,IJB,IKB) - XTHT(:,IJB+1,IKB)
IF (LNORTH_ll() .AND. CLBCY(1)/='CYCL') &
XTHT(:,IJE+1,IKB) = 2. * XTHT(:,IJE,IKB) - XTHT(:,IJE-1,IKB)
ELSE ! white noise on wind
IF (LWEST_ll() .AND. CLBCX(1)/='CYCL') &
XWT(IIB-1,:,IKB) = 2. * XWT(IIB,:,IKB) - XWT(IIB+1,:,IKB)
IF (LEAST_ll() .AND. CLBCX(1)/='CYCL') &
XWT(IIE+1,:,IKB) = 2. * XWT(IIE,:,IKB) - XWT(IIE-1,:,IKB)
IF (LSOUTH_ll() .AND. CLBCY(1)/='CYCL') &
XWT(:,IJB-1,IKB) = 2. * XWT(:,IJB,IKB) - XWT(:,IJB+1,IKB)
IF (LNORTH_ll() .AND. CLBCY(1)/='CYCL') &
XWT(:,IJE+1,IKB) = 2. * XWT(:,IJE,IKB) - XWT(:,IJE-1,IKB)
!
IF (LWEST_ll() .AND. CLBCX(1)/='CYCL') &
XUT(IIB-1,:,IKB) = 2. * XUT(IIB,:,IKB) - XUT(IIB+1,:,IKB)
IF (LEAST_ll() .AND. CLBCX(1)/='CYCL') &
XUT(IIE+1,:,IKB) = 2. * XUT(IIE,:,IKB) - XUT(IIE-1,:,IKB)
IF (LSOUTH_ll() .AND. CLBCY(1)/='CYCL') &
XUT(:,IJB-1,IKB) = 2. * XUT(:,IJB,IKB) - XUT(:,IJB+1,IKB)
IF (LNORTH_ll() .AND. CLBCY(1)/='CYCL') &
XUT(:,IJE+1,IKB) = 2. * XUT(:,IJE,IKB) - XUT(:,IJE-1,IKB)
!
IF (LWEST_ll() .AND. CLBCX(1)/='CYCL') &
XVT(IIB-1,:,IKB) = 2. * XVT(IIB,:,IKB) - XVT(IIB+1,:,IKB)
IF (LEAST_ll() .AND. CLBCX(1)/='CYCL') &
XVT(IIE+1,:,IKB) = 2. * XVT(IIE,:,IKB) - XVT(IIE-1,:,IKB)
IF (LSOUTH_ll() .AND. CLBCY(1)/='CYCL') &
XVT(:,IJB-1,IKB) = 2. * XVT(:,IJB,IKB) - XVT(:,IJB+1,IKB)
IF (LNORTH_ll() .AND. CLBCY(1)/='CYCL') &
XVT(:,IJE+1,IKB) = 2. * XVT(:,IJE,IKB) - XVT(:,IJE-1,IKB)
!
!
CASE('SH') ! Shock (Burger's Equation)
!

WAUTELET Philippe
committed
ZOMEGA = 2.0*XPI/REAL(IIE-IIB)

WAUTELET Philippe
committed
XUT(JI,:,:) = XUT(JI,:,:) + XAMPLIUV*SIN( ZOMEGA*REAL(JI-IIB) )
END DO
XVT(:,:,:) = 0.0
XWT(:,:,:) = 0.0
!
!
END SELECT
!
DEALLOCATE(ZXHAT_ll,ZYHAT_ll)
!
!-------------------------------------------------------------------------------
!
END SUBROUTINE SET_PERTURB