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