SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
orography_filter.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE orography_filter(HGRID,PGRID_PAR,PSEA,KZSFILTER,PZS)
7 ! ##############################################################
8 !
9 !!**** *OROGRAPHY_FILTER* filters the orography
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !! METHOD
15 !! ------
16 !!
17 !
18 !! EXTERNAL
19 !! --------
20 !!
21 !! IMPLICIT ARGUMENTS
22 !! ------------------
23 !!
24 !! REFERENCE
25 !! ---------
26 !!
27 !! AUTHOR
28 !! ------
29 !!
30 !! V. Masson Meteo-France
31 !!
32 !! MODIFICATION
33 !! ------------
34 !!
35 !! Original 06/2004
36 !!
37 !----------------------------------------------------------------------------
38 !
39 !* 0. DECLARATION
40 ! -----------
41 !
42 USE modi_get_grid_dim
43 USE modi_zsfilter
44 !
45 !
46 USE yomhook ,ONLY : lhook, dr_hook
47 USE parkind1 ,ONLY : jprb
48 !
49 IMPLICIT NONE
50 !
51 !* 0.1 Declaration of arguments
52 ! ------------------------
53 !
54  CHARACTER(LEN=10), INTENT(IN) :: hgrid ! type of grid
55 REAL, DIMENSION(:), POINTER :: pgrid_par! lits of parameters used to define the grid
56 REAL, DIMENSION(:), INTENT(IN) :: psea ! sea fraction
57 INTEGER, INTENT(IN) :: kzsfilter! number of filter iteration
58 REAL, DIMENSION(:), INTENT(INOUT) :: pzs ! orography
59 !
60 !
61 !* 0.2 Declaration of local variables
62 ! ------------------------------
63 !
64 LOGICAL :: grect ! true when grid is rectangular
65 INTEGER :: ix ! number of points in X direction
66 INTEGER :: iy ! number of points in Y direction
67 INTEGER :: jx ! loop counter
68 INTEGER :: jy ! loop counter
69 REAL, DIMENSION(:,:), ALLOCATABLE :: zzs ! orography in a 2D array
70 REAL, DIMENSION(:,:), ALLOCATABLE :: zsea! sea fraction in a 2D array
71 REAL(KIND=JPRB) :: zhook_handle
72 !-------------------------------------------------------------------------------
73 !
74 !* 1. Gets the geometry of the grid
75 ! -----------------------------
76 !
77 IF (lhook) CALL dr_hook('OROGRAPHY_FILTER',0,zhook_handle)
78  CALL get_grid_dim(hgrid,SIZE(pgrid_par),pgrid_par,grect,ix,iy)
79 !
80 !-------------------------------------------------------------------------------
81 !
82 !* 2. If grid is not rectangular, nothing is done
83 ! -------------------------------------------
84 !
85 IF (.NOT. grect .AND. lhook) CALL dr_hook('OROGRAPHY_FILTER',1,zhook_handle)
86 IF (.NOT. grect) RETURN
87 !
88 IF (SIZE(pzs) /= ix * iy .AND. lhook) CALL dr_hook('OROGRAPHY_FILTER',1,zhook_handle)
89 IF (SIZE(pzs) /= ix * iy) RETURN
90 !
91 !-------------------------------------------------------------------------------
92 !
93 !* 3. Grid rectangular: orography is put in a 2D array
94 ! ------------------------------------------------
95 !
96 ALLOCATE(zzs(ix,iy))
97 ALLOCATE(zsea(ix,iy))
98 !
99 DO jy=1,iy
100  DO jx=1,ix
101  zzs(jx,jy) = pzs( jx + (jy-1)*ix )
102  zsea(jx,jy) = psea( jx + (jy-1)*ix )
103  END DO
104 END DO
105 !
106 !-------------------------------------------------------------------------------
107 !
108 !* 4. Filtering in x and Y directions
109 ! -------------------------------
110 !
111 IF (kzsfilter>0) CALL zsfilter(zzs,(1.-zsea),kzsfilter)
112 !
113 !-------------------------------------------------------------------------------
114 !
115 !* 5. Output field comes back into 1D vector
116 ! --------------------------------------
117 !
118 DO jy=1,iy
119  DO jx=1,ix
120  pzs( jx + (jy-1)*ix ) = zzs(jx,jy)
121  END DO
122 END DO
123 !
124 DEALLOCATE(zzs )
125 DEALLOCATE(zsea)
126 IF (lhook) CALL dr_hook('OROGRAPHY_FILTER',1,zhook_handle)
127 !
128 !-------------------------------------------------------------------------------
129 !
130 END SUBROUTINE orography_filter
subroutine zsfilter(PZS, PMASK, KZSFILTER)
Definition: zsfilter.F90:6
subroutine get_grid_dim(HGRID, KGRID_PAR, PGRID_PAR, ORECT, KDIM1, KDIM2)
Definition: get_grid_dim.F90:6
subroutine orography_filter(HGRID, PGRID_PAR, PSEA, KZSFILTER, PZS)