SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
canopy_grid_update.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 canopy_grid_update(KI,KLVL,PH,PZFORC,PZ,PZF,PDZ,PDZF)
7 ! #########################################
8 !
9 !!**** *CANOPY_GRID_UPDATE* - set the upper levels at and just below forcing level
10 !!
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !!** METHOD
16 !! ------
17 !!
18 !! EXTERNAL
19 !! --------
20 !!
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !!
29 !! AUTHOR
30 !! ------
31 !! V. Masson *Meteo France*
32 !!
33 !! MODIFICATIONS
34 !! -------------
35 !! Original 07/2006
36 !! S. Riette Oct 2010 Vectorisation
37 !-------------------------------------------------------------------------------
38 !
39 !* 0. DECLARATIONS
40 ! ------------
41 !
42 !
43 USE yomhook ,ONLY : lhook, dr_hook
44 USE parkind1 ,ONLY : jprb
45 !
46 USE modi_canopy_grid
47 !
48 IMPLICIT NONE
49 !
50 !* 0.1 Declarations of arguments
51 ! -------------------------
52 !
53 INTEGER, INTENT(IN) :: ki ! number of horizontal points
54 INTEGER, INTENT(IN) :: klvl ! number of levels in canopy
55 REAL, DIMENSION(KI), INTENT(IN) :: ph ! maximum canopy height (m)
56 REAL, DIMENSION(KI), INTENT(IN) :: pzforc ! height of wind forcing (m)
57 REAL, DIMENSION(KI,KLVL), INTENT(INOUT) :: pz ! heights of canopy levels (m)
58 REAL, DIMENSION(KI,KLVL), INTENT(INOUT) :: pzf ! heights of bottom of canopy levels (m)
59 REAL, DIMENSION(KI,KLVL), INTENT(INOUT) :: pdz ! depth of canopy levels (m)
60 REAL, DIMENSION(KI,KLVL), INTENT(INOUT) :: pdzf ! depth between canopy levels (m)
61 !
62 !* 0.2 Declarations of local variables
63 ! -------------------------------
64 !
65 INTEGER, DIMENSION(KI) :: il ! latest level below forcing height
66 INTEGER, DIMENSION(KI,KLVL) :: ilevel ! to test if level is high enough
67 !
68 INTEGER :: icount ! number of layers above forcing height, these must be changed
69 INTEGER :: jlayer ! loop counter on layers
70 INTEGER :: ji ! loop counter on points
71 REAL :: zztop ! altitude of top of the grid of the initial level
72 ! ! just below forcing height
73 REAL :: zdz ! difference of height between new levels
74 REAL(KIND=JPRB) :: zhook_handle
75 !
76 !-------------------------------------------------------------------------------
77 !
78 IF (lhook) CALL dr_hook('CANOPY_GRID_UPDATE',0,zhook_handle)
79 IF(all(pz(:,klvl)==pzforc(:)) .AND. lhook) CALL dr_hook('CANOPY_GRID_UPDATE',1,zhook_handle)
80 IF(all(pz(:,klvl)==pzforc(:))) RETURN
81 !
82 !-------------------------------------------------------------------------------
83 !
84 !* 1. set upper level to forcing height
85 ! ---------------------------------
86 !
87 pz(:,klvl) = pzforc(:)
88 !
89 !* 2. all canopy levels remaining above forcing height are relocated below
90 ! --------------------------------------------------------------------
91 !
92 ! determination of levels below forcing height, low enough
93 ilevel=0
94 DO ji=1,ki
95  DO jlayer=1,klvl-1
96  IF( pzforc(ji) > pzf(ji,jlayer+1) + 0.25 * pdz(ji,jlayer) .AND. &
97  pz(ji,jlayer) < pzforc(ji) ) ilevel(ji,jlayer) = jlayer
98  ENDDO
99  ! determination of latest level from the ones selected before
100  il(ji)=maxval(ilevel(ji,1:klvl-1))
101  !
102  icount = klvl-il(ji)-1
103  !
104  !* determination grid top of this level
105  zztop = pzf(ji,il(ji)+1) ! ZZTOP=0 for IL=0
106  zdz = 2. * ( pz(ji,klvl)-zztop ) / ( 2*icount+1 )
107  DO jlayer=1,icount
108  pz(ji,jlayer+il(ji)) = zztop + (jlayer-0.5) * zdz
109  END DO
110 END DO
111 !
112 !* 3. New grid characteristics
113 ! ------------------------
114 !
115  CALL canopy_grid(ki,klvl,pz,pzf,pdz,pdzf)
116 !
117 !
118 !* 5. at least one canopy level in addition to forcing level must be above canopy top
119 ! -------------------------------------------------------------------------------
120 !
121 DO ji=1,ki
122  !
123  !* tests if the level below forcing height is high enough above canopy
124  IF(pzf(ji,klvl-1) < ph(ji) ) THEN
125  !
126  !* sets bottom of grid box that is below the forcing level one at canopy height
127  !
128  pzf(ji,klvl-1) = ph(ji)
129  !
130  !* rebuilds vertical grid from the bottom of each grid
131  !
132  pz(ji,klvl-2) = 0.5 * ( pzf(ji,klvl-2) + pzf(ji,klvl-1) )
133  pz(ji,klvl-1) = ( 2.* pzf(ji,klvl-1) + pz(ji,klvl) ) /3.
134  END IF
135 END DO
136 !
137 !* 6. Final grid characteristics
138 ! --------------------------
139 !
140  CALL canopy_grid(ki,klvl,pz,pzf,pdz,pdzf)
141 !
142 IF (lhook) CALL dr_hook('CANOPY_GRID_UPDATE',1,zhook_handle)
143 !
144 !-------------------------------------------------------------------------------
145 END SUBROUTINE canopy_grid_update
subroutine canopy_grid_update(KI, KLVL, PH, PZFORC, PZ, PZF, PDZ, PDZF)
subroutine canopy_grid(KI, KLVL, PZ, PZF, PDZ, PDZF)
Definition: canopy_grid.F90:6