SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
pgd_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 pgd_flake (DTCO, FG, F, UG, U, USS, &
7  hprogram,oecoclimap,orm_river)
8 ! ##############################################################
9 !
10 !!**** *PGD_FLAKE* monitor for averaging and interpolations of FLAKE physiographic fields
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !! METHOD
16 !! ------
17 !!
18 !
19 !! EXTERNAL
20 !! --------
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !! AUTHOR
29 !! ------
30 !!
31 !! V. Masson Meteo-France
32 !!
33 !! MODIFICATION
34 !! ------------
35 !!
36 !! Original 03/2004
37 !! 04/2013, P. Le Moigne : allow limitation of lake depth
38 !!
39 !----------------------------------------------------------------------------
40 !
41 !* 0. DECLARATION
42 ! -----------
43 !
44 !
45 !
46 !
49 USE modd_flake_n, ONLY : flake_t
51 USE modd_surf_atm_n, ONLY : surf_atm_t
53 !
54 USE modd_data_lake, ONLY : clakeldb, cstatusldb
55 USE modd_data_cover_par, ONLY : jpcover
56 USE modd_surf_par, ONLY : xundef
57 !
58 USE modd_pgdwork, ONLY : catype
59 !
60 !
61 USE modi_abor1_sfx
62 USE modi_get_luout
63 USE modi_pgd_field
64 
65 USE modi_get_surf_size_n
66 USE modi_pack_pgd
67 !
68 USE modi_open_namelist
69 USE modi_close_namelist
70 !
71 USE modi_treat_global_lake_depth
72 !
73 USE mode_pos_surf
74 !
75 !
76 USE yomhook ,ONLY : lhook, dr_hook
77 USE parkind1 ,ONLY : jprb
78 !
79 USE modi_write_cover_tex_water
80 !
81 IMPLICIT NONE
82 !
83 !* 0.1 Declaration of arguments
84 ! ------------------------
85 !
86 !
87 TYPE(data_cover_t), INTENT(INOUT) :: dtco
88 TYPE(flake_grid_t), INTENT(INOUT) :: fg
89 TYPE(flake_t), INTENT(INOUT) :: f
90 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
91 TYPE(surf_atm_t), INTENT(INOUT) :: u
92 TYPE(surf_atm_sso_t), INTENT(INOUT) :: uss
93 !
94  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! Type of program
95 LOGICAL, INTENT(IN) :: oecoclimap
96 LOGICAL, INTENT(IN) :: orm_river ! delete river coverage (default = false)
97 !
98 !
99 !* 0.2 Declaration of local variables
100 ! ------------------------------
101 !
102 INTEGER :: iluout ! output listing logical unit
103 INTEGER :: ilunam ! namelist file logical unit
104 LOGICAL :: gfound ! flag when namelist is present
105 INTEGER,DIMENSION(:),ALLOCATABLE :: iwater_status
106 !
107 !* 0.3 Declaration of namelists
108 ! ------------------------
109 !
110  CHARACTER(LEN=28) :: ywater_depth ! file name for water depth
111  CHARACTER(LEN=28) :: ywater_depth_status ! file name for water depth status
112  CHARACTER(LEN=28) :: ywater_fetch
113  CHARACTER(LEN=28) :: yt_bs
114  CHARACTER(LEN=28) :: ydepth_bs
115  CHARACTER(LEN=28) :: yextcoef_water
116 
117  CHARACTER(LEN=6) :: ywater_depthfiletype ! water depth file type
118  CHARACTER(LEN=6) :: ywater_fetchfiletype
119  CHARACTER(LEN=6) :: yt_bsfiletype
120  CHARACTER(LEN=6) :: ydepth_bsfiletype
121  CHARACTER(LEN=6) :: yextcoef_waterfiletype
122 
123 REAL :: xunif_water_depth ! uniform value of water depth
124 REAL :: xunif_water_fetch
125 REAL :: xunif_t_bs
126 REAL :: xunif_depth_bs
127 REAL :: xunif_extcoef_water
128 REAL :: xmax_depth
129 REAL(KIND=JPRB) :: zhook_handle
130 !
131 namelist/nam_data_flake/ ywater_depth, ywater_depth_status, ywater_depthfiletype, &
132  xunif_water_depth, ywater_fetch, ywater_fetchfiletype, &
133  xunif_water_fetch, yt_bs, yt_bsfiletype, xunif_t_bs, &
134  ydepth_bs, ydepth_bsfiletype, xunif_depth_bs, &
135  yextcoef_water, yextcoef_waterfiletype, xunif_extcoef_water, &
136  xmax_depth
137 !-------------------------------------------------------------------------------
138 !
139 IF (lhook) CALL dr_hook('PGD_FLAKE',0,zhook_handle)
140  CALL get_luout(hprogram,iluout)
141 !
142 !-------------------------------------------------------------------------------
143 !
144 !* 1. Initializations of defaults
145 ! ---------------------------
146 !
147 xunif_water_depth = 10.
148 xunif_water_fetch = 1000.
149 xunif_t_bs = 286.
150 xunif_depth_bs = 1.
151 xunif_extcoef_water= 3.
152 !
153 ywater_depth = ' '
154 ywater_depth_status = ' '
155 ywater_fetch = ' '
156 yt_bs = ' '
157 ydepth_bs = ' '
158 yextcoef_water = ' '
159 !
160 ywater_depthfiletype = ' '
161 ywater_fetchfiletype = ' '
162 yt_bsfiletype = ' '
163 ydepth_bsfiletype = ' '
164 yextcoef_waterfiletype = ' '
165 !
166 xmax_depth = 1.e+20
167 !
168 !-------------------------------------------------------------------------------
169 !
170 !* 2. Reading of namelist
171 ! -------------------
172 !
173  CALL open_namelist(hprogram,ilunam)
174 !
175  CALL posnam(ilunam,'NAM_DATA_FLAKE',gfound,iluout)
176 IF (gfound) READ(unit=ilunam,nml=nam_data_flake)
177 !
178  CALL close_namelist(hprogram,ilunam)
179 !
180 !-------------------------------------------------------------------------------
181 !
182 !* 3. Coherence of options
183 ! --------------------
184 !
185 !-------------------------------------------------------------------------------
186 !
187 !* 4. Number of points and packing
188 ! ----------------------------
189 !
190  CALL get_surf_size_n(dtco, u, &
191  'WATER ',fg%NDIM)
192 !
193 ALLOCATE(f%LCOVER (jpcover))
194 ALLOCATE(f%XZS (fg%NDIM))
195 ALLOCATE(fg%XLAT (fg%NDIM))
196 ALLOCATE(fg%XLON (fg%NDIM))
197 ALLOCATE(fg%XMESH_SIZE (fg%NDIM))
198 !
199  CALL pack_pgd(dtco, u, &
200  hprogram, 'WATER ', &
201  fg%CGRID, fg%XGRID_PAR, &
202  f%LCOVER, f%XCOVER, f%XZS, &
203  fg%XLAT, fg%XLON, fg%XMESH_SIZE )
204 !
205 !-------------------------------------------------------------------------------
206 !
207 !* 5. Water depth
208 ! -----------
209 !
210 ALLOCATE(f%XWATER_DEPTH (fg%NDIM))
211 !
212 IF (trim(ywater_depth)==trim(clakeldb) .AND. trim(ywater_depthfiletype)=='DIRECT') THEN
213  !
214  IF (trim(ywater_depth_status)=='') THEN
215  WRITE(iluout,*)'Depth Status file name not initialized'
216  WRITE(iluout,*)'add YWATER_DEPTH_STATUS="GlobalLakeStatus" in NAM_DATA_FLAKE'
217  CALL abor1_sfx('PGD_FLAKE: STATUS INPUT FILE NAME NOT SET')
218  ELSEIF (trim(ywater_depth_status)==trim(cstatusldb)) THEN
219  ALLOCATE(iwater_status(fg%NDIM))
220  CALL treat_global_lake_depth(dtco, ug, u, uss, &
221  hprogram,f%XWATER_DEPTH(:),iwater_status(:))
222  ELSE
223  WRITE(iluout,*)'Wrong name for Depth Status file :',' expected: ',trim(cstatusldb),' input: ',trim(ywater_depth_status)
224  CALL abor1_sfx('PGD_FLAKE: WRONG STATUS INPUT FILE NAME')
225  ENDIF
226  !
227 ELSE
228  !
229  IF(oecoclimap.AND.(.NOT.orm_river))THEN
230  WRITE(iluout,*)'With this version of Flake, river must be removed'
231  WRITE(iluout,*)'Indeed, river energy budget can not be computed '
232  WRITE(iluout,*)'using static lake scheme without 2D informations.'
233  WRITE(iluout,*)'Please add LRM_RIVER = T in NAM_COVER '
234  WRITE(iluout,*)' '
235  WRITE(iluout,*)'If you still want to use Flake to comput river '
236  WRITE(iluout,*)'energy budget, please use the two files for the '
237  WRITE(iluout,*)'Kourzeneva 2009 method: ',clakeldb(1:len_trim(clakeldb)),' ',&
238  cstatusldb(1:len_trim(cstatusldb))
239  CALL abor1_sfx('PGD_FLAKE: WITH THIS VERSION OF FLAKE, LRM_RIVER MUST BE TRUE')
240  ENDIF
241  !
242  catype='INV'
243  CALL pgd_field(dtco, ug, u, uss, &
244  hprogram,'water depth','WAT',ywater_depth,ywater_depthfiletype,xunif_water_depth,f%XWATER_DEPTH(:))
245  !
246 ENDIF
247 !
248 f%XWATER_DEPTH(:) = min(f%XWATER_DEPTH(:),xmax_depth)
249 WRITE(iluout,*)'MAXIMUM LAKE DEPTH = ',xmax_depth
250 !
251 !-------------------------------------------------------------------------------
252 !
253 !* 6. Wind fetch
254 ! ----------
255 !
256 ALLOCATE(f%XWATER_FETCH (fg%NDIM))
257 !
258  catype='ARI'
259  CALL pgd_field(dtco, ug, u, uss, &
260  hprogram,'wind fetch','WAT',ywater_fetch,ywater_fetchfiletype,xunif_water_fetch,f%XWATER_FETCH(:))
261 !
262 !-------------------------------------------------------------------------------
263 !
264 !* 7. Sediments bottom temperature
265 ! ----------------------------
266 !
267 ALLOCATE(f%XT_BS (fg%NDIM))
268 !
269  catype='ARI'
270  CALL pgd_field(dtco, ug, u, uss, &
271  hprogram,'sediments bottom temperature ','WAT',yt_bs,yt_bsfiletype,xunif_t_bs,f%XT_BS(:))
272 !
273 !-------------------------------------------------------------------------------
274 !
275 !* 8. Depth of sediments layer
276 ! ------------------------
277 !
278 ALLOCATE(f%XDEPTH_BS (fg%NDIM))
279 !
280  catype='INV'
281  CALL pgd_field(dtco, ug, u, uss, &
282  hprogram,'depth of sediments layer','WAT',ydepth_bs,ydepth_bsfiletype,xunif_depth_bs,f%XDEPTH_BS(:))
283 !
284 !-------------------------------------------------------------------------------
285 !
286 !* 9. Water extinction coefficient
287 ! ----------------------------
288 
289 ALLOCATE(f%XEXTCOEF_WATER(fg%NDIM))
290 !
291  catype='ARI'
292  CALL pgd_field(dtco, ug, u, uss, &
293  hprogram,'water extinction coefficient','WAT', &
294  yextcoef_water,yextcoef_waterfiletype,xunif_extcoef_water, &
295  f%XEXTCOEF_WATER(:))
296 !
297 !-------------------------------------------------------------------------------
298 !
299 !* 10. Prints of flake parameters in a tex file
300 ! ----------------------------------------
301 !
302  CALL write_cover_tex_water
303 !
304 IF (lhook) CALL dr_hook('PGD_FLAKE',1,zhook_handle)
305 !-------------------------------------------------------------------------------
306 !
307 END SUBROUTINE pgd_flake
subroutine get_surf_size_n(DTCO, U, HTYPE, KL)
subroutine pack_pgd(DTCO, U, HPROGRAM, HSURF, HGRID, PGRID_PAR, OCOVER, PCOVER, PZS, PLAT, PLON, PMESH_SIZE, PDIR)
Definition: pack_pgd.F90:6
subroutine pgd_field(DTCO, UG, U, USS, HPROGRAM, HFIELD, HAREA, HFILE, HFILETYPE, PUNIF, PFIELD, OPRESENT)
Definition: pgd_field.F90:6
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine close_namelist(HPROGRAM, KLUNAM)
subroutine pgd_flake(DTCO, FG, F, UG, U, USS, HPROGRAM, OECOCLIMAP, ORM_RIVER)
Definition: pgd_flake.F90:6
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine treat_global_lake_depth(DTCO, UG, U, USS, HPROGRAM, PDEPTH, KSTATUS)
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)