SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
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, FM, UG, U, &
7  hprogram,hatmfile,hatmfiletype,hpgdfile,hpgdfiletype)
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 !!------------------------------------------------------------------
34 !
35 !
36 !
37 USE modd_surfex_n, ONLY : flake_model_t
38 !
41 !
43 USE modd_surf_atm_n, ONLY : surf_atm_t
44 !
45 USE modi_prep_hor_flake_field
46 USE modi_prep_ver_flake
47 USE modi_prep_flake_sbl
48 USE modi_prep_output_grid
49 USE modi_get_luout
50 USE modi_cli_lake
51 !
53 !
54 USE modd_read_namelist,ONLY : lnam_read
55 USE modd_surf_atm, ONLY : lvertshift
56 USE modd_prep, ONLY : xzs_ls
57 USE modd_prep_flake, ONLY : lclim_lake
58 USE modd_surf_par, ONLY : xundef
59 !
60 !
61 USE modd_csts, ONLY : xtt
62 
63 !
64 USE yomhook ,ONLY : lhook, dr_hook
65 USE parkind1 ,ONLY : jprb
66 !
67 USE modi_clean_prep_output_grid
68 !
69 USE modi_abor1_sfx
70 IMPLICIT NONE
71 !
72 !* 0.1 declarations of arguments
73 !
74 !
75 !
76 TYPE(data_cover_t), INTENT(INOUT) :: dtco
77 TYPE(surf_atm_sso_t), INTENT(INOUT) :: uss
78 !
79 TYPE(flake_model_t), INTENT(INOUT) :: fm
80 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
81 TYPE(surf_atm_t), INTENT(INOUT) :: u
82 !
83  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling surf. schemes
84  CHARACTER(LEN=28), INTENT(IN) :: hatmfile ! name of the Atmospheric file
85  CHARACTER(LEN=6), INTENT(IN) :: hatmfiletype! type of the Atmospheric file
86  CHARACTER(LEN=28), INTENT(IN) :: hpgdfile ! name of the Atmospheric file
87  CHARACTER(LEN=6), INTENT(IN) :: hpgdfiletype! type of the Atmospheric file
88 !
89 !* 0.2 declarations of local variables
90 !
91 INTEGER :: iluout
92 LOGICAL :: gnovalue ! if the variable is not defined
93 REAL(KIND=JPRB) :: zhook_handle
94 !-------------------------------------------------------------------------------------
95 !
96 !* 1. Default of configuration
97 !
98 !
99 IF (lhook) CALL dr_hook('PREP_FLAKE',0,zhook_handle)
100  CALL get_luout(hprogram,iluout)
101 !
102  CALL prep_output_grid(ug, u, &
103  iluout,fm%FG%CGRID,fm%FG%XGRID_PAR,fm%FG%XLAT,fm%FG%XLON)
104 !
105 !-------------------------------------------------------------------------------------
106 !
107 !* 2. Reading and horizontal interpolations
108 !
109 !
110 !* 2.0 Large scale orography
111 !
112  CALL prep_hor_flake_field(dtco, ug, u, uss, &
113  fm%FG, fm%F, &
114  hprogram,'ZS ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype)
115 !
116 !* 2.1 FLake variables
117 !
118 gnovalue = .false.
119 !
120 IF (.NOT.lclim_lake) THEN
121  !
122  CALL prep_hor_flake_field(dtco, ug, u, uss, &
123  fm%FG, fm%F, &
124  hprogram,'TS ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
125  IF (gnovalue) CALL abor1_sfx('PREP_FLAKE: AT LEAST TS SHOULD BE GIVEN!')
126  !
127  CALL prep_hor_flake_field(dtco, ug, u, uss, &
128  fm%FG, fm%F, &
129  hprogram,'T_SNOW ',hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,gnovalue)
130  !
131  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
132  fm%FG, fm%F, &
133  hprogram,'T_ICE ',hatmfile,hatmfiletype,&
134  hpgdfile,hpgdfiletype,gnovalue)
135  !
136  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
137  fm%FG, fm%F, &
138  hprogram,'T_WML ',hatmfile,hatmfiletype,&
139  hpgdfile,hpgdfiletype,gnovalue)
140  !
141  ALLOCATE(fm%F%XT_MNW(SIZE(fm%FG%XLAT)))
142  !
143  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
144  fm%FG, fm%F, &
145  hprogram,'T_BOT ',hatmfile,hatmfiletype,&
146  hpgdfile,hpgdfiletype,gnovalue)
147  !
148  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
149  fm%FG, fm%F, &
150  hprogram,'T_B1 ',hatmfile,hatmfiletype,&
151  hpgdfile,hpgdfiletype,gnovalue)
152  !
153  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
154  fm%FG, fm%F, &
155  hprogram,'CT ',hatmfile,hatmfiletype,&
156  hpgdfile,hpgdfiletype,gnovalue)
157  !
158  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
159  fm%FG, fm%F, &
160  hprogram,'H_SNOW ',hatmfile,hatmfiletype,&
161  hpgdfile,hpgdfiletype,gnovalue)
162  !
163  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
164  fm%FG, fm%F, &
165  hprogram,'H_ICE ',hatmfile,hatmfiletype,&
166  hpgdfile,hpgdfiletype,gnovalue)
167  !
168  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
169  fm%FG, fm%F, &
170  hprogram,'H_ML ',hatmfile,hatmfiletype,&
171  hpgdfile,hpgdfiletype,gnovalue)
172  !
173  IF (.NOT.gnovalue) CALL prep_hor_flake_field(dtco, ug, u, uss, &
174  fm%FG, fm%F, &
175  hprogram,'H_B1 ',hatmfile,hatmfiletype,&
176  hpgdfile,hpgdfiletype,gnovalue)
177  !
178 ENDIF
179 !
180 IF (lclim_lake .OR. gnovalue) THEN
181  IF (lclim_lake) THEN
182  ALLOCATE(fm%F%XTS(SIZE(fm%FG%XLAT)))
183  fm%F%XTS(:)=xundef
184  ENDIF
185  ALLOCATE(fm%F%XT_SNOW(SIZE(fm%FG%XLAT)))
186  ALLOCATE(fm%F%XT_ICE(SIZE(fm%FG%XLAT)))
187  ALLOCATE(fm%F%XT_WML(SIZE(fm%FG%XLAT)))
188  ALLOCATE(fm%F%XT_MNW(SIZE(fm%FG%XLAT)))
189  ALLOCATE(fm%F%XT_BOT(SIZE(fm%FG%XLAT)))
190  ALLOCATE(fm%F%XT_B1(SIZE(fm%FG%XLAT)))
191  ALLOCATE(fm%F%XCT(SIZE(fm%FG%XLAT)))
192  ALLOCATE(fm%F%XH_SNOW(SIZE(fm%FG%XLAT)))
193  ALLOCATE(fm%F%XH_ICE(SIZE(fm%FG%XLAT)))
194  ALLOCATE(fm%F%XH_ML(SIZE(fm%FG%XLAT)))
195  ALLOCATE(fm%F%XH_B1(SIZE(fm%FG%XLAT)))
196  fm%F%XT_SNOW(:)=xundef
197  fm%F%XT_ICE(:)=xundef
198  fm%F%XT_WML(:)=xundef
199  fm%F%XT_MNW(:)=xundef
200  fm%F%XT_BOT(:)=xundef
201  fm%F%XT_B1(:)=xundef
202  fm%F%XCT(:)=xundef
203  fm%F%XH_SNOW(:)=xundef
204  fm%F%XH_ICE(:)=xundef
205  fm%F%XH_ML(:)=xundef
206  fm%F%XH_B1(:)=xundef
207 ENDIF
208 !
209 !-------------------------------------------------------------------------------------
210 !
212 !
213 !* 2.2 Roughness
214 !
215 ALLOCATE(fm%F%XZ0(SIZE(fm%F%XTS)))
216 fm%F%XZ0 = 0.001
217 !
218 !* 2.2 Friction velocity
219 !
220 ALLOCATE(fm%F%XUSTAR(SIZE(fm%F%XTS)))
221 fm%F%XUSTAR = 0.
222 !
223 !-------------------------------------------------------------------------------------
224 
225 !
226 !* 3. Vertical interpolations of all variables
227 !
228 IF(.NOT.lclim_lake) THEN
229  IF (lvertshift)THEN
230  CALL prep_ver_flake(fm%F)
231  WRITE(iluout,*) "WARNING: You want the vertical shift for lakes?"
232  WRITE(iluout,*) "WARNING: Vertical shift for the lake temperature profile is impossible!"
233  WRITE(iluout,*) "WARNING: So, set the default vertical profiles from the shifted surface temperature." !
234  gnovalue=.true.
235  ENDIF
236 END IF
237 !
238 DEALLOCATE(xzs_ls)
239 !-------------------------------------------------------------------------------------
240 !
241 !* 4. Compute T_MNW and give the default profile if needed
242 ! or read data from climate files
243 !
244 IF (lclim_lake) THEN
245  CALL cli_lake(fm%FG, fm%F)
246 ELSEIF (.NOT.gnovalue) THEN
247  fm%F%XT_MNW(:)=fm%F%XT_WML(:)-(fm%F%XT_WML(:)-fm%F%XT_BOT(:))*(1.-fm%F%XH_ML(:)/fm%F%XWATER_DEPTH(:))*fm%F%XCT(:)
248 ELSE
249  WRITE(iluout,*) "WARNING! One of the lake profile variales was not indicated, so set the default profile!"
250  fm%F%XT_WML=max(fm%F%XTS(:),xtt)
251  fm%F%XT_SNOW=min(fm%F%XTS(:),xtt)
252  fm%F%XT_ICE=min(fm%F%XTS(:),xtt)
253  fm%F%XH_B1=0.0
254  fm%F%XCT=0.5
255  fm%F%XH_SNOW=0.0
256  WHERE (fm%F%XTS <= xtt)
257  fm%F%XT_BOT=xtt+4.
258  fm%F%XT_B1=xtt+3.9
259  fm%F%XH_ICE=0.01
260  fm%F%XH_ML=fm%F%XWATER_DEPTH/2.
261  fm%F%XT_MNW=fm%F%XT_WML-(fm%F%XT_WML-fm%F%XT_BOT)*(1.-fm%F%XH_ML/fm%F%XWATER_DEPTH)*fm%F%XCT
262  ELSEWHERE
263  fm%F%XT_BOT=fm%F%XTS
264  fm%F%XT_B1=fm%F%XTS-0.1
265  fm%F%XH_ICE=0.0
266  fm%F%XH_ML=fm%F%XWATER_DEPTH
267  fm%F%XT_MNW=fm%F%XTS
268  END WHERE
269 END IF
270 !
271 !-------------------------------------------------------------------------------------
272 !
273 !* 6. Preparation of SBL air variables
274 !
275 fm%F%LSBL = lwat_sbl
276 IF (fm%F%LSBL) CALL prep_flake_sbl(fm%FG, fm%FSB)
277 IF (lhook) CALL dr_hook('PREP_FLAKE',1,zhook_handle)
278 !
279 !-------------------------------------------------------------------------------------
280 !
281 END SUBROUTINE prep_flake
subroutine prep_ver_flake(F)
subroutine prep_flake(DTCO, USS, FM, UG, U, HPROGRAM, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE)
Definition: prep_flake.F90:6
subroutine clean_prep_output_grid
subroutine prep_hor_flake_field(DTCO, UG, U, USS, FG, F, HPROGRAM, HSURF, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, ONOVALUE)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine prep_flake_sbl(FG, FSB)
subroutine cli_lake(FG, F)
Definition: cli_lake.F90:6
subroutine prep_output_grid(UG, U, KLUOUT, HGRID, PGRID_PAR, PLAT, PLON)