SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
zoom_pgd_isba_full.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_isba_full (CHI, DTCO, DTI, IG, I, UG, U, &
7  hprogram,hinifile,hinifiletype)
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 !! B. Decharme 2008 XWDRAIN
39 !! M.Tomasini 17/04/12 All COVER physiographic fields are now
40 !! interpolated for spawning =>
41 !! ABOR1_SFX if (.NOT.OECOCLIMAP) in comment
42 !----------------------------------------------------------------------------
43 !
44 !* 0. DECLARATION
45 ! -----------
46 !
47 !
48 !
49 !
50 !
51 !
52 USE modd_ch_isba_n, ONLY : ch_isba_t
54 USE modd_data_isba_n, ONLY : data_isba_t
55 USE modd_isba_grid_n, ONLY : isba_grid_t
56 USE modd_isba_n, ONLY : isba_t
58 USE modd_surf_atm_n, ONLY : surf_atm_t
59 !
60 USE modd_prep, ONLY : cingrid_type, cinterp_type, linterp
61 !
62 USE modi_get_luout
63 USE modi_open_aux_io_surf
64 USE modi_prep_grid_extern
65 USE modi_prep_output_grid
67 USE modi_close_aux_io_surf
68 USE modi_hor_interpol
69 USE modi_get_type_dim_n
70 USE modi_read_pgd_isba_par_n
71 USE modi_clean_prep_output_grid
72 USE modi_abor1_sfx
73 !
74 USE yomhook ,ONLY : lhook, dr_hook
75 USE parkind1 ,ONLY : jprb
76 !
77 IMPLICIT NONE
78 !
79 !* 0.1 Declaration of dummy arguments
80 ! ------------------------------
81 !
82 !
83 TYPE(ch_isba_t), INTENT(INOUT) :: chi
84 TYPE(data_cover_t), INTENT(INOUT) :: dtco
85 TYPE(data_isba_t), INTENT(INOUT) :: dti
86 TYPE(isba_grid_t), INTENT(INOUT) :: ig
87 TYPE(isba_t), INTENT(INOUT) :: i
88 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
89 TYPE(surf_atm_t), INTENT(INOUT) :: u
90 !
91  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling
92  CHARACTER(LEN=28), INTENT(IN) :: hinifile ! input atmospheric file name
93  CHARACTER(LEN=6), INTENT(IN) :: hinifiletype ! input atmospheric file type
94 !
95 !* 0.2 Declaration of local variables
96 ! ------------------------------
97 !
98 INTEGER :: iversion, ibugfix
99 INTEGER :: iresp
100 INTEGER :: iluout
101 INTEGER :: ini ! total 1D dimension (input grid)
102 INTEGER :: jlayer ! loop counter
103 REAL, DIMENSION(:), ALLOCATABLE :: zfield ! field read
104 REAL, DIMENSION(:,:), POINTER :: zsand ! sand on all surface points
105 REAL, DIMENSION(:,:), POINTER :: zclay ! clay on all surface points
106 REAL, DIMENSION(:,:), POINTER :: zrunoffb! runoff coef. on all surface points
107 REAL, DIMENSION(:,:), POINTER :: zwdrain ! drainage coef. on all surface points
108 REAL, DIMENSION(:,:), ALLOCATABLE :: zoutb ! runoff coef. on all surface points
109 REAL, DIMENSION(:,:), ALLOCATABLE :: zoutw ! drainage coef. on all surface points
110 REAL(KIND=JPRB) :: zhook_handle
111 !------------------------------------------------------------------------------
112 IF (lhook) CALL dr_hook('ZOOM_PGD_ISBA_FULL',0,zhook_handle)
113  CALL get_luout(hprogram,iluout)
114 !
115 !* 1. Preparation of IO for reading in the file
116 ! -----------------------------------------
117 !
118 !* Note that all points are read, even those without physical meaning.
119 ! These points will not be used during the horizontal interpolation step.
120 ! Their value must be defined as XUNDEF.
121 !
122  CALL open_aux_io_surf(&
123  hinifile,hinifiletype,'FULL ')
124 !
125  CALL read_surf(&
126  hinifiletype,'VERSION',iversion,iresp)
127  CALL read_surf(&
128  hinifiletype,'BUG',ibugfix,iresp)
129 !
130 !------------------------------------------------------------------------------
131 !
132 !* 2. Reading of grid
133 ! ---------------
134 !
135  CALL prep_grid_extern(&
136  hinifiletype,iluout,cingrid_type,cinterp_type,ini)
137 !
138  CALL prep_output_grid(ug, u, &
139  iluout,ig%CGRID,ig%XGRID_PAR,ig%XLAT,ig%XLON)
140 !
141 !------------------------------------------------------------------------------
142 !
143 !* 3. Reading of fields
144 ! -----------------
145 !
146 !
147 ALLOCATE(zfield(ini))
148 !
149 ALLOCATE(zsand(ini,i%NGROUND_LAYER))
150  CALL read_surf(&
151  hprogram,'SAND',zfield,iresp,hdir='A')
152 DO jlayer=1,i%NGROUND_LAYER
153  zsand(:,jlayer) = zfield(:)
154 END DO
155 !
156 ALLOCATE(zclay(ini,i%NGROUND_LAYER))
157  CALL read_surf(&
158  hprogram,'CLAY',zfield,iresp,hdir='A')
159 DO jlayer=1,i%NGROUND_LAYER
160  zclay(:,jlayer) = zfield(:)
161 END DO
162 !
163 !* Soil organic carbon profile
164 !
165 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) THEN
166  CALL read_surf(&
167  hprogram,'SOCP',i%LSOCP,iresp)
168 ELSE
169  i%LSOCP=.false.
170 ENDIF
171 !
172 IF(i%LSOCP)THEN
173 !
174  ALLOCATE(i%XSOC (ini,i%NGROUND_LAYER))
175 !
176  CALL read_surf(&
177  hprogram,'SOC_TOP',i%XSOC(:,1),iresp)
178  CALL read_surf(&
179  hprogram,'SOC_SUB',i%XSOC(:,2),iresp)
180 !
181  DO jlayer=2,i%NGROUND_LAYER
182  i%XSOC (:,jlayer)=i%XSOC (:,2)
183  END DO
184 !
185 ELSE
186 !
187  ALLOCATE(i%XSOC (0,1))
188 !
189 ENDIF
190 !
191 !* permafrost distribution
192 !
193 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) THEN
194  CALL read_surf(&
195  hprogram,'PERMAFROST',i%LPERM,iresp)
196 ELSE
197  i%LPERM=.false.
198 ENDIF
199 !
200 IF(i%LPERM)THEN
201 !
202  ALLOCATE(i%XPERM (ini))
203  CALL read_surf(&
204  hprogram,'PERM',i%XPERM(:),iresp)
205 !
206 ELSE
207 !
208  ALLOCATE(i%XPERM (0))
209 !
210 ENDIF
211 !
212 !* groundwater distribution
213 !
214 IF (iversion>=8) THEN
215  CALL read_surf(&
216  hprogram,'GWKEY',i%LGW,iresp)
217 ELSE
218  i%LGW=.false.
219 ENDIF
220 !
221 IF(i%LGW)THEN
222 !
223  ALLOCATE(i%XGW (ini))
224  CALL read_surf(&
225  hprogram,'GWFRAC',i%XGW(:),iresp)
226 !
227 ELSE
228 !
229  ALLOCATE(i%XGW (0))
230 !
231 ENDIF
232 !
233 IF (iversion>7 .OR. (iversion==7 .AND. ibugfix>=3)) THEN
234  CALL read_surf(&
235  hprogram,'NO',i%LNOF,iresp)
236 ELSE
237  i%LNOF = .false.
238 ENDIF
239 !
240 !SOILNOX
241 !
242 IF (chi%LCH_NO_FLUX) THEN
243  !
244  IF (i%LNOF) THEN
245  !
246  ALLOCATE(i%XPH(ini))
247  CALL read_surf(&
248  hprogram,'PH',i%XPH(:),iresp)
249  !
250  ALLOCATE(i%XFERT(ini))
251  CALL read_surf(&
252  hprogram,'FERT',i%XFERT(:),iresp)
253  !
254  ELSE
255  CALL abor1_sfx("READ_PGD_ISBAn: WITH LCH_NO_FLUX=T, PH AND FERT FIELDS ARE GIVEN AT PGD STEP")
256  ENDIF
257  !
258 ELSE
259  ALLOCATE(i%XPH (0))
260  ALLOCATE(i%XFERT(0))
261 END IF
262 !
263 ALLOCATE(zrunoffb(ini,1))
264  CALL read_surf(&
265  hprogram,'RUNOFFB',zfield,iresp,hdir='A')
266 zrunoffb(:,1) = zfield(:)
267 !
268 ALLOCATE(zwdrain(ini,1))
269  CALL read_surf(&
270  hprogram,'WDRAIN',zfield,iresp,hdir='A')
271 zwdrain(:,1) = zfield(:)
272 !
273 DEALLOCATE(zfield)
274 !
275 !------------------------------------------------------------------------------
276 !
277 !* 4. Interpolations
278 ! --------------
279 !
280 !* mask where interpolations must be done
281 !
282 linterp(:) = .true.
283 !
284 !* interpolations
285 !
286  CALL hor_interpol(dtco, u, &
287  iluout,zsand,i%XSAND)
288  CALL hor_interpol(dtco, u, &
289  iluout,zclay,i%XCLAY)
290 ALLOCATE(zoutb(SIZE(i%XRUNOFFB),1))
291  CALL hor_interpol(dtco, u, &
292  iluout,zrunoffb,zoutb)
293 i%XRUNOFFB(:) = zoutb(:,1)
294 DEALLOCATE(zoutb)
295 ALLOCATE(zoutw(SIZE(i%XWDRAIN),1))
296  CALL hor_interpol(dtco, u, &
297  iluout,zwdrain,zoutw)
298 i%XWDRAIN(:) = zoutw(:,1)
299 DEALLOCATE(zoutw)
300 !
301  CALL get_type_dim_n(dtco, u, &
302  'NATURE',ig%NDIM)
303  CALL read_pgd_isba_par_n(dtco, u, &
304  dti, ig, i, &
305  hprogram,ini,.false.,hdir='A')
306 !
307  CALL close_aux_io_surf(hinifile,hinifiletype)
308 !
310 IF (lhook) CALL dr_hook('ZOOM_PGD_ISBA_FULL',1,zhook_handle)
311 !------------------------------------------------------------------------------
312 !
313 END SUBROUTINE zoom_pgd_isba_full
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
subroutine zoom_pgd_isba_full(CHI, DTCO, DTI, IG, I, UG, U, HPROGRAM, HINIFILE, HINIFILETYPE)
subroutine clean_prep_output_grid
subroutine read_pgd_isba_par_n(DTCO, U, DTI, IG, I, HPROGRAM, KSIZE, OLAND_USE, HDIR)
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 get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine prep_grid_extern(HFILETYPE, KLUOUT, HGRIDTYPE, HINTERP_TYPE, KNI)
subroutine prep_output_grid(UG, U, KLUOUT, HGRID, PGRID_PAR, PLAT, PLON)