SURFEX v8.1
General documentation of Surfex
prep_flake.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 prep_flake (DTCO, USS, FG, F, SB, UG, U, GCP, &
7  HPROGRAM,HATMFILE,HATMFILETYPE,HPGDFILE,HPGDFILETYPE,YDCTL)
8 ! #################################################################################
9 !
10 !!**** *PREP_FLAKE* - prepares FLAKE fields
11 !!
12 !! PURPOSE
13 !! -------
14 !
15 !!** METHOD
16 !! ------
17 !!
18 !! REFERENCE
19 !! ---------
20 !!
21 !!
22 !! AUTHOR
23 !! ------
24 !! S. Malardel
25 !!
26 !! MODIFICATIONS
27 !! -------------
28 !! Original 01/2004
29 !! S. Riette 06/2009 PREP_FLAKE_SBL has no more argument
30 !! E. Kourzeneva 09/2010 (i) Change the default initialisation,
31 !! (ii) Include the possibility to use
32 !! lake climate data
33 !! P. Marguinaud10/2014, Support for a 2-part PREP
34 !!------------------------------------------------------------------
35 !
36 !
37 USE modd_sfx_grid_n, ONLY : grid_t
38 USE modd_flake_n, ONLY : flake_t
39 USE modd_canopy_n, ONLY : canopy_t
40 !
42 USE modd_sso_n, ONLY : sso_t
43 !
45 USE modd_surf_atm_n, ONLY : surf_atm_t
47 !
48 USE modi_prep_hor_flake_field
49 USE modi_prep_ver_flake
50 USE modi_prep_sbl
51 USE modi_prep_output_grid
52 USE modi_get_luout
53 USE modi_cli_lake
54 !
56 !
58 USE modd_surf_atm, ONLY : lvertshift
59 USE modd_prep, ONLY : xzs_ls
60 USE modd_prep_flake, ONLY : lclim_lake
61 USE modd_surf_par, ONLY : xundef
62 !
63 USE modd_csts, ONLY : xtt
65 !
66 USE yomhook ,ONLY : lhook, dr_hook
67 USE parkind1 ,ONLY : jprb
68 !
69 USE modi_clean_prep_output_grid
70 !
71 USE modi_abor1_sfx
72 IMPLICIT NONE
73 !
74 !* 0.1 declarations of arguments
75 !
76 !
77 !
78 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
79 TYPE(sso_t), INTENT(INOUT) :: USS
80 !
81 TYPE(grid_t), INTENT(INOUT) :: FG
82 TYPE(flake_t), INTENT(INOUT) :: F
83 TYPE(canopy_t), INTENT(INOUT) :: SB
84 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
85 TYPE(surf_atm_t), INTENT(INOUT) :: U
86 TYPE(grid_conf_proj_t),INTENT(INOUT) :: GCP
87 !
88 type(prep_ctl), INTENT(INOUT) :: ydctl
89 !
90  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling surf. schemes
91  CHARACTER(LEN=28), INTENT(IN) :: HATMFILE ! name of the Atmospheric file
92  CHARACTER(LEN=6), INTENT(IN) :: HATMFILETYPE! type of the Atmospheric file
93  CHARACTER(LEN=28), INTENT(IN) :: HPGDFILE ! name of the Atmospheric file
94  CHARACTER(LEN=6), INTENT(IN) :: HPGDFILETYPE! type of the Atmospheric file
95 !
96 !* 0.2 declarations of local variables
97 !
98 INTEGER :: ISIZE
99 INTEGER :: ILUOUT
100 LOGICAL :: GNOVALUE ! if the variable is not defined
101 REAL(KIND=JPRB) :: ZHOOK_HANDLE
102 !-------------------------------------------------------------------------------------
103 !
104 !* 1. Default of configuration
105 !
106 !
107 IF (lhook) CALL dr_hook('PREP_FLAKE',0,zhook_handle)
108 !
109 IF (.NOT. prep_ctl_can(ydctl)) THEN
110  CALL abor1_sfx('PREP_FLAKE: TWO STEP PREP NOT IMPLEMENTED')
111 ENDIF
112 
113  CALL get_luout(hprogram,iluout)
114 !
115  CALL prep_output_grid(ug%G, fg, u%NSIZE_FULL, iluout)
116 !
117 isize = SIZE(fg%XLAT)
118 !
119 !-------------------------------------------------------------------------------------
120 !
121 !* 2. Reading and horizontal interpolations
122 !
123 !
124 !* 2.0 Large scale orography
125 !
126  CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
127  hprogram,'ZS ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype)
128 !
129 !* 2.1 FLake variables
130 !
131 gnovalue = .false.
132 !
133 IF (.NOT.lclim_lake) THEN
134  !
135  CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
136  hprogram,'TS ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
137  IF (gnovalue) CALL abor1_sfx('PREP_FLAKE: AT LEAST TS SHOULD BE GIVEN!')
138  !
139  CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
140  hprogram,'T_SNOW ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
141  !
142  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
143  hprogram,'T_ICE ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
144  !
145  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
146  hprogram,'T_WML ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
147  !
148  ALLOCATE(f%XT_MNW(isize))
149  !
150  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
151  hprogram,'T_BOT ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
152  !
153  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
154  hprogram,'T_B1 ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
155  !
156  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
157  hprogram,'CT ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
158  !
159  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
160  hprogram,'H_SNOW ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
161  !
162  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
163  hprogram,'H_ICE ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
164  !
165  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
166  hprogram,'H_ML ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
167  !
168  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, gcp, isize, f, &
169  hprogram,'H_B1 ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
170  !
171 ENDIF
172 !
173 IF (lclim_lake .OR. gnovalue) THEN
174  IF (lclim_lake) THEN
175  ALLOCATE(f%XTS(isize))
176  f%XTS(:)=xundef
177  ENDIF
178  ALLOCATE(f%XT_SNOW(isize))
179  ALLOCATE(f%XT_ICE(isize))
180  ALLOCATE(f%XT_WML(isize))
181  ALLOCATE(f%XT_MNW(isize))
182  ALLOCATE(f%XT_BOT(isize))
183  ALLOCATE(f%XT_B1(isize))
184  ALLOCATE(f%XCT(isize))
185  ALLOCATE(f%XH_SNOW(isize))
186  ALLOCATE(f%XH_ICE(isize))
187  ALLOCATE(f%XH_ML(isize))
188  ALLOCATE(f%XH_B1(isize))
189  f%XT_SNOW(:)=xundef
190  f%XT_ICE(:)=xundef
191  f%XT_WML(:)=xundef
192  f%XT_MNW(:)=xundef
193  f%XT_BOT(:)=xundef
194  f%XT_B1(:)=xundef
195  f%XCT(:)=xundef
196  f%XH_SNOW(:)=xundef
197  f%XH_ICE(:)=xundef
198  f%XH_ML(:)=xundef
199  f%XH_B1(:)=xundef
200 ENDIF
201 !
202 !-------------------------------------------------------------------------------------
203 !
205 !
206 !* 2.2 Roughness
207 !
208 ALLOCATE(f%XZ0(SIZE(f%XTS)))
209 f%XZ0 = 0.001
210 !
211 !* 2.2 Friction velocity
212 !
213 ALLOCATE(f%XUSTAR(SIZE(f%XTS)))
214 f%XUSTAR = 0.
215 !
216 !-------------------------------------------------------------------------------------
217 
218 !
219 !* 3. Vertical interpolations of all variables
220 !
221 IF(.NOT.lclim_lake) THEN
222  IF (lvertshift)THEN
223  CALL prep_ver_flake(f)
224  WRITE(iluout,*) "WARNING: You want the vertical shift for lakes?"
225  WRITE(iluout,*) "WARNING: Vertical shift for the lake temperature profile is impossible!"
226  WRITE(iluout,*) "WARNING: So, set the default vertical profiles from the shifted surface temperature." !
227  gnovalue=.true.
228  ENDIF
229 END IF
230 !
231 DEALLOCATE(xzs_ls)
232 !-------------------------------------------------------------------------------------
233 !
234 !* 4. Compute T_MNW and give the default profile if needed
235 ! or read data from climate files
236 !
237 IF (lclim_lake) THEN
238  CALL cli_lake(fg, f)
239 ELSEIF (.NOT.gnovalue) THEN
240  f%XT_MNW(:)=f%XT_WML(:)-(f%XT_WML(:)-f%XT_BOT(:))*(1.-f%XH_ML(:)/f%XWATER_DEPTH(:))*f%XCT(:)
241 ELSE
242  WRITE(iluout,*) "WARNING! One of the lake profile variales was not indicated, so set the default profile!"
243  f%XT_WML=max(f%XTS(:),xtt)
244  f%XT_SNOW=min(f%XTS(:),xtt)
245  f%XT_ICE=min(f%XTS(:),xtt)
246  f%XH_B1=0.0
247  f%XCT=0.5
248  f%XH_SNOW=0.0
249  WHERE (f%XTS <= xtt)
250  f%XT_BOT=xtt+4.
251  f%XT_B1=xtt+3.9
252  f%XH_ICE=0.01
253  f%XH_ML=f%XWATER_DEPTH/2.
254  f%XT_MNW=f%XT_WML-(f%XT_WML-f%XT_BOT)*(1.-f%XH_ML/f%XWATER_DEPTH)*f%XCT
255  ELSEWHERE
256  f%XT_BOT=f%XTS
257  f%XT_B1=f%XTS-0.1
258  f%XH_ICE=0.0
259  f%XH_ML=f%XWATER_DEPTH
260  f%XT_MNW=f%XTS
261  END WHERE
262 END IF
263 !
264 !-------------------------------------------------------------------------------------
265 !
266 !* 6. Preparation of SBL air variables
267 !
268 f%LSBL = lwat_sbl
269 IF (f%LSBL) CALL prep_sbl(isize, sb)
270 !
271 IF (lhook) CALL dr_hook('PREP_FLAKE',1,zhook_handle)
272 !
273 !-------------------------------------------------------------------------------------
274 !
275 END SUBROUTINE prep_flake
subroutine prep_sbl(KDIM, SB)
Definition: prep_sbl.F90:7
subroutine prep_ver_flake(F)
subroutine cli_lake(G, F)
Definition: cli_lake.F90:7
subroutine clean_prep_output_grid
real, dimension(:), allocatable xzs_ls
Definition: modd_prep.F90:45
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
real, parameter xundef
integer, parameter jprb
Definition: parkind1.F90:32
subroutine prep_output_grid(UG, G, KSIZE_FULL, KLUOUT)
logical function prep_ctl_can(YDCTL)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
subroutine prep_flake(DTCO, USS, FG, F, SB, UG, U, GCP, HPROGRAM, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, YDCTL)
Definition: prep_flake.F90:8
subroutine prep_hor_flake_field(DTCO, UG, U, USS, GCP, KLAT, F, HPROGRAM, HSURF, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, ONOVALUE)
logical lvertshift
real, save xtt
Definition: modd_csts.F90:66