SURFEX v8.1
General documentation of Surfex
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,PH,PZFORC,SB)
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 USE modd_canopy_n, ONLY : canopy_t
40 !
41 !* 0. DECLARATIONS
42 ! ------------
43 !
44 !
45 USE yomhook ,ONLY : lhook, dr_hook
46 USE parkind1 ,ONLY : jprb
47 !
48 USE modi_canopy_grid
49 !
50 IMPLICIT NONE
51 !
52 !* 0.1 Declarations of arguments
53 ! -------------------------
54 !
55 INTEGER, INTENT(IN) :: KI ! number of horizontal points
56 REAL, DIMENSION(KI), INTENT(IN) :: PH ! maximum canopy height (m)
57 REAL, DIMENSION(KI), INTENT(IN) :: PZFORC ! height of wind forcing (m)
58 !
59 TYPE(canopy_t), INTENT(INOUT) :: SB
60 !
61 !* 0.2 Declarations of local variables
62 ! -------------------------------
63 !
64 INTEGER, DIMENSION(KI) :: IL ! latest level below forcing height
65 INTEGER, DIMENSION(KI,SB%NLVL) :: ILEVEL ! to test if level is high enough
66 !
67 INTEGER :: ICOUNT ! number of layers above forcing height, these must be changed
68 INTEGER :: JLAYER ! loop counter on layers
69 INTEGER :: JI ! loop counter on points
70 REAL :: ZZTOP ! altitude of top of the grid of the initial level
71 ! ! just below forcing height
72 REAL :: ZDZ ! difference of height between new levels
73 REAL(KIND=JPRB) :: ZHOOK_HANDLE
74 !
75 !-------------------------------------------------------------------------------
76 !
77 IF (lhook) CALL dr_hook('CANOPY_GRID_UPDATE',0,zhook_handle)
78 !
79 IF(all(sb%XZ(:,sb%NLVL)==pzforc(:)) .AND. lhook) CALL dr_hook('CANOPY_GRID_UPDATE',1,zhook_handle)
80 IF(all(sb%XZ(:,sb%NLVL)==pzforc(:))) RETURN
81 !
82 !-------------------------------------------------------------------------------
83 !
84 !* 1. set upper level to forcing height
85 ! ---------------------------------
86 !
87 sb%XZ(:,sb%NLVL) = 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 !
94 ilevel=0
95 DO ji=1,ki
96  DO jlayer=1,sb%NLVL-1
97  IF( pzforc(ji) > sb%XZF(ji,jlayer+1) + 0.25 * sb%XDZ(ji,jlayer) .AND. &
98  sb%XZ(ji,jlayer) < pzforc(ji) ) ilevel(ji,jlayer) = jlayer
99  ENDDO
100  ! determination of latest level from the ones selected before
101  il(ji)=maxval(ilevel(ji,1:sb%NLVL-1))
102  !
103  icount = sb%NLVL-il(ji)-1
104  !
105  !* determination grid top of this level
106  zztop = sb%XZF(ji,il(ji)+1) ! ZZTOP=0 for IL=0
107  zdz = 2. * ( sb%XZ(ji,sb%NLVL)-zztop ) / ( 2*icount+1 )
108  DO jlayer=1,icount
109  sb%XZ(ji,jlayer+il(ji)) = zztop + (jlayer-0.5) * zdz
110  END DO
111 END DO
112 !
113 !* 3. New grid characteristics
114 ! ------------------------
115 !
116  CALL canopy_grid(ki,sb)
117 !
118 !
119 !* 5. at least one canopy level in addition to forcing level must be above canopy top
120 ! -------------------------------------------------------------------------------
121 !
122 DO ji=1,ki
123  !
124  !* tests if the level below forcing height is high enough above canopy
125  IF(sb%XZF(ji,sb%NLVL-1) < ph(ji) ) THEN
126  !
127  !* sets bottom of grid box that is below the forcing level one at canopy height
128  !
129  sb%XZF(ji,sb%NLVL-1) = ph(ji)
130  !
131  !* rebuilds vertical grid from the bottom of each grid
132  !
133  sb%XZ(ji,sb%NLVL-2) = 0.5 * ( sb%XZF(ji,sb%NLVL-2) + sb%XZF(ji,sb%NLVL-1) )
134  sb%XZ(ji,sb%NLVL-1) = ( 2.* sb%XZF(ji,sb%NLVL-1) + sb%XZ (ji,sb%NLVL) ) /3.
135  END IF
136 END DO
137 !
138 !* 6. Final grid characteristics
139 ! --------------------------
140 !
141  CALL canopy_grid(ki,sb)
142 !
143 IF (lhook) CALL dr_hook('CANOPY_GRID_UPDATE',1,zhook_handle)
144 !
145 !-------------------------------------------------------------------------------
146 END SUBROUTINE canopy_grid_update
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine canopy_grid(KI, SB)
Definition: canopy_grid.F90:7
subroutine canopy_grid_update(KI, PH, PZFORC, SB)