SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
zoom_pgd_teb.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 zoom_pgd_teb (B, DGCT, DGMT, T, TGD, TGDPE, TGR, TGRPE, &
7  bop, bdd, dtb, dtco, dtt, ug, u, tgdo, tgdp, tg, &
8  top, tvg, &
9  hprogram,hinifile,hinifiletype,oecoclimap,ogarden)
10 ! ###########################################################
11 
12 !!
13 !! PURPOSE
14 !! -------
15 !! This program prepares the physiographic data fields.
16 !!
17 !! METHOD
18 !! ------
19 !!
20 !! EXTERNAL
21 !! --------
22 !!
23 !!
24 !! IMPLICIT ARGUMENTS
25 !! ------------------
26 !!
27 !!
28 !! REFERENCE
29 !! ---------
30 !!
31 !! AUTHOR
32 !! ------
33 !!
34 !! V. Masson Meteo-France
35 !!
36 !! MODIFICATION
37 !! ------------
38 !!
39 !! Original 13/10/03
40 !----------------------------------------------------------------------------
41 !
42 !* 0. DECLARATION
43 ! -----------
44 !
45 !
46 USE modd_bem_n, ONLY : bem_t
49 USE modd_teb_n, ONLY : teb_t
56 USE modd_data_bem_n, ONLY : data_bem_t
58 USE modd_data_teb_n, ONLY : data_teb_t
60 USE modd_surf_atm_n, ONLY : surf_atm_t
63 USE modd_teb_grid_n, ONLY : teb_grid_t
66 !
67 USE modd_data_cover_par, ONLY : jpcover
68 !
69 USE modd_prep, ONLY : cingrid_type, cinterp_type, linterp
70 !
71 USE modi_get_luout
72 USE modi_abor1_sfx
73 USE modi_open_aux_io_surf
74 USE modi_get_surf_size_n
75 USE modi_pack_pgd
76 USE modi_prep_grid_extern
77 USE modi_prep_output_grid
79 USE modi_read_pgd_teb_par_n
80 USE modi_close_aux_io_surf
81 USE modi_clean_prep_output_grid
82 USE modi_goto_wrapper_teb_patch
83 !
84 USE yomhook ,ONLY : lhook, dr_hook
85 USE parkind1 ,ONLY : jprb
86 !
87 !
88 IMPLICIT NONE
89 !
90 !* 0.1 Declaration of dummy arguments
91 ! ------------------------------
92 !
93 !
94 TYPE(bem_t), INTENT(INOUT) :: b
95 TYPE(diag_cumul_teb_t), INTENT(INOUT) :: dgct
96 TYPE(diag_misc_teb_t), INTENT(INOUT) :: dgmt
97 TYPE(teb_t), INTENT(INOUT) :: t
98 TYPE(teb_garden_pgd_evol_t), INTENT(INOUT) :: tgdpe
99 TYPE(teb_garden_t), INTENT(INOUT) :: tgd
100 TYPE(teb_greenroof_t), INTENT(INOUT) :: tgr
101 TYPE(teb_greenroof_pgd_evol_t), INTENT(INOUT) :: tgrpe
102 TYPE(bem_options_t), INTENT(INOUT) :: bop
103 TYPE(bld_desc_t), INTENT(INOUT) :: bdd
104 TYPE(data_bem_t), INTENT(INOUT) :: dtb
105 TYPE(data_cover_t), INTENT(INOUT) :: dtco
106 TYPE(data_teb_t), INTENT(INOUT) :: dtt
107 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
108 TYPE(surf_atm_t), INTENT(INOUT) :: u
109 TYPE(teb_garden_options_t), INTENT(INOUT) :: tgdo
110 TYPE(teb_garden_pgd_t), INTENT(INOUT) :: tgdp
111 TYPE(teb_grid_t), INTENT(INOUT) :: tg
112 TYPE(teb_options_t), INTENT(INOUT) :: top
113 TYPE(teb_veg_options_t), INTENT(INOUT) :: tvg
114 !
115  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling
116  CHARACTER(LEN=28), INTENT(IN) :: hinifile ! file to read
117  CHARACTER(LEN=6), INTENT(IN) :: hinifiletype! file type
118 LOGICAL, INTENT(IN) :: oecoclimap ! flag to use ecoclimap
119 LOGICAL, INTENT(IN) :: ogarden ! flag to use garden
120 !
121 !
122 !* 0.2 Declaration of local variables
123 ! ------------------------------
124 !
125 INTEGER :: iresp ! error return code
126 INTEGER :: iluout ! output listing logical unit
127 INTEGER :: ini ! total 1D dimension (input grid)
128 INTEGER :: jlayer ! loop counter
129 INTEGER :: ilu ! total 1D dimension (output grid, TOWN points only)
130 INTEGER :: jpatch ! TEB patch
131 REAL(KIND=JPRB) :: zhook_handle
132 INTEGER :: iversion
133 INTEGER :: ibugfix
134 !------------------------------------------------------------------------------
135 IF (lhook) CALL dr_hook('ZOOM_PGD_TEB',0,zhook_handle)
136  CALL get_luout(hprogram,iluout)
137 !
138 top%LECOCLIMAP = oecoclimap
139 top%LGARDEN = ogarden
140 !
141 IF (.NOT. oecoclimap) THEN
142  WRITE(iluout,*) 'ERROR'
143  WRITE(iluout,*) 'Ecoclimap is not used'
144  WRITE(iluout,*) 'Routine zoom_pgd_teb.f90 must be updated'
145  WRITE(iluout,*) 'to interpolate all TEB physiographic fields'
146  CALL abor1_sfx('ZOOM_PGD_TEB: ECOCLIMAP NOT USED, ROUTINE MUST BE UPDATED')
147 END IF
148 !
149 !
150 !* 1. Preparation of IO for reading in the file
151 ! -----------------------------------------
152 !
153 !* Note that all points are read, even those without physical meaning.
154 ! These points will not be used during the horizontal interpolation step.
155 ! Their value must be defined as XUNDEF.
156 !
157  CALL open_aux_io_surf(&
158  hinifile,hinifiletype,'FULL ')
159 !
160  CALL goto_wrapper_teb_patch(b, dgct, dgmt, t, tgd, tgdpe, tgr, tgrpe, 1)
161 !-------------------------------------------------------------------------------
162 !
163 !* 2. Number of points and packing of general fields
164 ! ----------------------------------------------
165 !
166 !
167  CALL get_surf_size_n(dtco, u, &
168  'TOWN ',ilu)
169 !
170 ALLOCATE(top%LCOVER (jpcover))
171 ALLOCATE(top%XZS (ilu))
172 ALLOCATE(tg%XLAT (ilu))
173 ALLOCATE(tg%XLON (ilu))
174 ALLOCATE(tg%XMESH_SIZE (ilu))
175 !
176  CALL pack_pgd(dtco, u, &
177  hprogram, 'TOWN ', &
178  tg%CGRID, tg%XGRID_PAR, &
179  top%LCOVER, top%XCOVER, top%XZS, &
180  tg%XLAT, tg%XLON, tg%XMESH_SIZE )
181 !
182 tg%NDIM = ilu
183 !
184 !
185  CALL read_surf(&
186  hprogram,'VERSION',iversion,iresp)
187  CALL read_surf(&
188  hprogram,'BUG',ibugfix,iresp)
189 !------------------------------------------------------------------------------
190 !
191 !* 3. Reading of grid
192 ! ---------------
193 !
194  CALL prep_grid_extern(&
195  hinifiletype,iluout,cingrid_type,cinterp_type,ini)
196 !
197  CALL prep_output_grid(ug, u, &
198  iluout,tg%CGRID,tg%XGRID_PAR,tg%XLAT,tg%XLON)
199 !
200 !
201 !------------------------------------------------------------------------------
202 !
203 !* 4. Reading & interpolation of fields
204 ! ---------------------------------
205 !
206 !
207 IF (iversion<7 .OR. iversion==7 .AND. ibugfix<=2) THEN
208  top%NTEB_PATCH=1
209 ELSE
210  CALL read_surf(&
211  hprogram,'TEB_PATCH',top%NTEB_PATCH,iresp)
212 END IF
213 
214 !
215  CALL read_surf(&
216  hprogram,'ROOF_LAYER',top%NROOF_LAYER,iresp)
217  CALL read_surf(&
218  hprogram,'ROAD_LAYER',top%NROAD_LAYER,iresp)
219  CALL read_surf(&
220  hprogram,'WALL_LAYER',top%NWALL_LAYER,iresp)
221 !
222 IF (iversion<7 .OR.( iversion==7 .AND. ibugfix<=2)) THEN
223  top%CBLD_ATYPE='ARI'
224  top%CBEM = 'DEF'
225 ELSE
226  CALL read_surf(&
227  hprogram,'BLD_ATYPE' ,top%CBLD_ATYPE,iresp)
228  CALL read_surf(&
229  hprogram,'BEM' ,top%CBEM ,iresp)
230 END IF
231 !
232 IF (top%CBEM/='DEF') THEN
233  CALL read_surf(&
234  hprogram,'FLOOR_LAYER',bop%NFLOOR_LAYER,iresp)
235 END IF
236 !
237 DO jpatch=1,top%NTEB_PATCH
238  CALL goto_wrapper_teb_patch(b, dgct, dgmt, t, tgd, tgdpe, tgr, tgrpe, jpatch)
239  CALL read_pgd_teb_par_n(dtco, u, &
240  bdd, dtb, dtt, tg, top, &
241  hprogram,ini,'A')
242 !
243 !------------------------------------------------------------------------------
244 !
245 !* 5. Gardens
246 ! -------
247 !
248  IF (top%LGARDEN) CALL zoom_pgd_teb_garden
249 END DO
250 !
251  CALL close_aux_io_surf(hinifile,hinifiletype)
252 !
254 !
255 !------------------------------------------------------------------------------
256 IF (lhook) CALL dr_hook('ZOOM_PGD_TEB',1,zhook_handle)
257 !------------------------------------------------------------------------------
258 !
259  CONTAINS
260 !
262 !
263 USE modi_hor_interpol
264 !
265 !
266 IMPLICIT NONE
267 !
268 REAL, DIMENSION(:,:), POINTER :: zin ! field on all surface points
269 !
270 REAL, DIMENSION(INI) :: zfield ! field read
271 REAL, DIMENSION(ILU,1) :: zout ! final field
272 REAL(KIND=JPRB) :: zhook_handle
273  CHARACTER(LEN=12) :: yrecfm ! Name of the article to be read
274 !
275 IF (lhook) CALL dr_hook('ZOOM_PGD_TEB:ZOOM_PGD_TEB_GARDEN',0,zhook_handle)
276 !
277 linterp(:) = .true.
278 !
279 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) THEN
280  CALL read_surf(&
281  hprogram,'GD_LAYER',tgdo%NGROUND_LAYER,iresp)
282  CALL read_surf(&
283  hprogram,'GD_ISBA',tvg%CISBA,iresp)
284  CALL read_surf(&
285  hprogram,'GD_PHOTO',tvg%CPHOTO,iresp)
286  CALL read_surf(&
287  hprogram,'GD_PEDOTF',tvg%CPEDOTF,iresp)
288  tvg%NNBIOMASS=1
289  IF (tvg%CPHOTO=='NIT') tvg%NNBIOMASS=3
290 ELSE
291  CALL read_surf(&
292  hprogram,'TWN_LAYER',tgdo%NGROUND_LAYER,iresp)
293  CALL read_surf(&
294  hprogram,'TWN_ISBA',tvg%CISBA,iresp)
295  CALL read_surf(&
296  hprogram,'TWN_PHOTO',tvg%CPHOTO,iresp)
297  CALL read_surf(&
298  hprogram,'TWN_PEDOTF',tvg%CPEDOTF,iresp)
299  CALL read_surf(&
300  hprogram,'TWN_NBIOMASS',tvg%NNBIOMASS,iresp)
301 ENDIF
302 !
303 !* sand
304 !
305 ALLOCATE(zin(ini,tgdo%NGROUND_LAYER))
306 yrecfm='TWN_SAND'
307 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) yrecfm='GD_SAND'
308  CALL read_surf(&
309  hprogram,yrecfm,zfield,iresp,hdir='A')
310 DO jlayer=1,tgdo%NGROUND_LAYER
311  zin(:,jlayer) = zfield(:)
312 END DO
313 ALLOCATE(tgdp%XSAND(ilu,tgdo%NGROUND_LAYER))
314  CALL hor_interpol(dtco, u, &
315  iluout,zin,tgdp%XSAND)
316 DEALLOCATE(zin)
317 !
318 !* clay
319 !
320 ALLOCATE(zin(ini,tgdo%NGROUND_LAYER))
321 yrecfm='TWN_CLAY'
322 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) yrecfm='GD_CLAY'
323  CALL read_surf(&
324  hprogram,yrecfm,zfield,iresp,hdir='A')
325 DO jlayer=1,tgdo%NGROUND_LAYER
326  zin(:,jlayer) = zfield(:)
327 END DO
328 ALLOCATE(tgdp%XCLAY(ilu,tgdo%NGROUND_LAYER))
329  CALL hor_interpol(dtco, u, &
330  iluout,zin,tgdp%XCLAY)
331 DEALLOCATE(zin)
332 !
333 !* runoff & drainage
334 !
335 ALLOCATE(zin(ini,1))
336 yrecfm='TWN_RUNOFFB'
337 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) yrecfm='GD_RUNOFFB'
338  CALL read_surf(&
339  hprogram,yrecfm,zfield,iresp,hdir='A')
340 zin(:,1) = zfield(:)
341 ALLOCATE(tgdp%XRUNOFFB(ilu))
342  CALL hor_interpol(dtco, u, &
343  iluout,zin,zout)
344 tgdp%XRUNOFFB(:) = zout(:,1)
345 !
346 IF (iversion<=3) THEN
347  tgdp%XWDRAIN = 0.
348 ELSE
349  yrecfm='TWN_WDRAIN'
350  IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) yrecfm='GD_WDRAIN'
351  CALL read_surf(&
352  hprogram,yrecfm,zfield,iresp,hdir='A')
353  zin(:,1) = zfield(:)
354  ALLOCATE(tgdp%XWDRAIN(ilu))
355  CALL hor_interpol(dtco, u, &
356  iluout,zin,zout)
357  tgdp%XWDRAIN(:) = zout(:,1)
358 ENDIF
359 !
360 DEALLOCATE(zin)
361 !
362 !* other garden parameters
363 !
364  CALL read_surf(&
365  hprogram,'PAR_GARDEN',tgdo%LPAR_GARDEN,iresp)
366 !
367 !!
368 IF (tgdo%LPAR_GARDEN) THEN
369  WRITE(iluout,*) 'ERROR'
370  WRITE(iluout,*) 'Specific garden fields are prescribed'
371  WRITE(iluout,*) 'Routine zoom_pgd_teb.f90 must be updated'
372  WRITE(iluout,*) 'to interpolate all TEB physiographic garden fields'
373  CALL abor1_sfx('ZOOM_PGD_TEB: GARDEN fields used, ROUTINE MUST BE UPDATED')
374 END IF
375 !
376 IF (lhook) CALL dr_hook('ZOOM_PGD_TEB:ZOOM_PGD_TEB_GARDEN',1,zhook_handle)
377 !
378 END SUBROUTINE zoom_pgd_teb_garden
379 !_______________________________________________________________________________
380 !
381 END SUBROUTINE zoom_pgd_teb
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 clean_prep_output_grid
subroutine zoom_pgd_teb(B, DGCT, DGMT, T, TGD, TGDPE, TGR, TGRPE, BOP, BDD, DTB, DTCO, DTT, UG, U, TGDO, TGDP, TG, TOP, TVG, HPROGRAM, HINIFILE, HINIFILETYPE, OECOCLIMAP, OGARDEN)
Definition: zoom_pgd_teb.F90:6
subroutine close_aux_io_surf(HFILE, HFILETYPE)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine hor_interpol(DTCO, U, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:6
subroutine open_aux_io_surf(HFILE, HFILETYPE, HMASK)
subroutine goto_wrapper_teb_patch(B, DGCT, DGMT, T, TGD, TGDPE, TGR, TGRPE, KTO_PATCH)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine read_pgd_teb_par_n(DTCO, U, BDD, DTB, DTT, TG, TOP, HPROGRAM, KNI, HDIRIN)
subroutine prep_grid_extern(HFILETYPE, KLUOUT, HGRIDTYPE, HINTERP_TYPE, KNI)
subroutine prep_output_grid(UG, U, KLUOUT, HGRID, PGRID_PAR, PLAT, PLON)
subroutine zoom_pgd_teb_garden