SURFEX v8.1
General documentation of Surfex
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, DTV, IG, IO, S, K, UG, U, GCP, &
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 !! 10/2016 B. Decharme : bug surface/groundwater coupling
43 !----------------------------------------------------------------------------
44 !
45 !* 0. DECLARATION
46 ! -----------
47 !
48 USE modd_ch_isba_n, ONLY : ch_isba_t
50 USE modd_data_isba_n, ONLY : data_isba_t
51 USE modd_sfx_grid_n, ONLY : grid_t
53 USE modd_isba_n, ONLY : isba_s_t, isba_k_t
55 USE modd_surf_atm_n, ONLY : surf_atm_t
57 !
59 !
60 USE modd_type_date_surf, ONLY : date
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 !
80 !* 0.1 Declaration of dummy arguments
81 ! ------------------------------
82 !
83 !
84 TYPE(ch_isba_t), INTENT(INOUT) :: CHI
85 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
86 TYPE(data_isba_t), INTENT(INOUT) :: DTV
87 TYPE(grid_t), INTENT(INOUT) :: IG
88 TYPE(isba_options_t), INTENT(INOUT) :: IO
89 TYPE(isba_s_t), INTENT(INOUT) :: S
90 TYPE(isba_k_t), INTENT(INOUT) :: K
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 !
95  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling
96  CHARACTER(LEN=28), INTENT(IN) :: HINIFILE ! input atmospheric file name
97  CHARACTER(LEN=6), INTENT(IN) :: HINIFILETYPE ! input atmospheric file type
98 !
99 !* 0.2 Declaration of local variables
100 ! ------------------------------
101 !
102 TYPE(date) :: TDATE_BEG, TDATE_END
103 !
104 INTEGER :: IVERSION, IBUGFIX
105 INTEGER :: IRESP
106 INTEGER :: ILUOUT
107 INTEGER :: INI ! total 1D dimension (input grid)
108 INTEGER :: JLAYER ! loop counter
109 REAL, DIMENSION(:), ALLOCATABLE :: ZFIELD ! field read
110 REAL, DIMENSION(:,:), POINTER :: ZSAND ! sand on all surface points
111 REAL, DIMENSION(:,:), POINTER :: ZCLAY ! clay on all surface points
112 REAL, DIMENSION(:,:), POINTER :: ZRUNOFFB! runoff coef. on all surface points
113 REAL, DIMENSION(:,:), POINTER :: ZWDRAIN ! drainage coef. on all surface points
114 REAL, DIMENSION(:,:), ALLOCATABLE :: ZOUTB ! runoff coef. on all surface points
115 REAL, DIMENSION(:,:), ALLOCATABLE :: ZOUTW ! drainage coef. on all surface points
116 REAL(KIND=JPRB) :: ZHOOK_HANDLE
117 !------------------------------------------------------------------------------
118 IF (lhook) CALL dr_hook('ZOOM_PGD_ISBA_FULL',0,zhook_handle)
119  CALL get_luout(hprogram,iluout)
120 !
121 !* 1. Preparation of IO for reading in the file
122 ! -----------------------------------------
123 !
124 !* Note that all points are read, even those without physical meaning.
125 ! These points will not be used during the horizontal interpolation step.
126 ! Their value must be defined as XUNDEF.
127 !
128  CALL open_aux_io_surf(hinifile,hinifiletype,'FULL ')
129 !
130  CALL read_surf(hinifiletype,'VERSION',iversion,iresp)
131  CALL read_surf(hinifiletype,'BUG',ibugfix,iresp)
132 !
133 !------------------------------------------------------------------------------
134 !
135 !* 2. Reading of grid
136 ! ---------------
137 !
138  CALL prep_output_grid(ug%G, ig, u%NSIZE_FULL, iluout)
139 !
140  CALL prep_grid_extern(gcp,hinifiletype,iluout,cingrid_type,cinterp_type,ini)
141 !
142 !-----------------------------------------------------------------------------
143 !
144 !* 3. Reading of fields
145 ! -----------------
146 !
147 !
148 ALLOCATE(zfield(ini))
149 !
150 ALLOCATE(zsand(ini,io%NGROUND_LAYER))
151  CALL read_surf(hprogram,'SAND',zfield,iresp,hdir='A')
152 DO jlayer=1,io%NGROUND_LAYER
153  zsand(:,jlayer) = zfield(:)
154 END DO
155 !
156 ALLOCATE(zclay(ini,io%NGROUND_LAYER))
157  CALL read_surf(hprogram,'CLAY',zfield,iresp,hdir='A')
158 DO jlayer=1,io%NGROUND_LAYER
159  zclay(:,jlayer) = zfield(:)
160 END DO
161 !
162 !* Soil organic carbon profile
163 !
164 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) THEN
165  CALL read_surf(hprogram,'SOCP',io%LSOCP,iresp)
166 ELSE
167  io%LSOCP=.false.
168 ENDIF
169 !
170 IF(io%LSOCP)THEN
171 !
172  ALLOCATE(s%XSOC (ini,io%NGROUND_LAYER))
173 !
174  CALL read_surf(hprogram,'SOC_TOP',s%XSOC(:,1),iresp)
175  CALL read_surf(hprogram,'SOC_SUB',s%XSOC(:,2),iresp)
176 !
177  DO jlayer=2,io%NGROUND_LAYER
178  s%XSOC (:,jlayer)=s%XSOC (:,2)
179  END DO
180 !
181 ELSE
182 !
183  ALLOCATE(s%XSOC (0,1))
184 !
185 ENDIF
186 !
187 !* permafrost distribution
188 !
189 IF (iversion>7 .OR. iversion==7 .AND. ibugfix>=3) THEN
190  CALL read_surf(hprogram,'PERMAFROST',io%LPERM,iresp)
191 ELSE
192  io%LPERM=.false.
193 ENDIF
194 !
195 IF(io%LPERM)THEN
196 !
197  ALLOCATE(k%XPERM (ini))
198  CALL read_surf(hprogram,'PERM',k%XPERM(:),iresp)
199 !
200 ELSE
201 !
202  ALLOCATE(k%XPERM (0))
203 !
204 ENDIF
205 !
206 !SOILNOX
207 !
208 IF (iversion>7 .OR. (iversion==7 .AND. ibugfix>=3)) THEN
209  CALL read_surf(hprogram,'NO',io%LNOF,iresp)
210 ELSE
211  io%LNOF = .false.
212 ENDIF
213 !
214 IF (chi%LCH_NO_FLUX) THEN
215  !
216  IF (io%LNOF) THEN
217  !
218  ALLOCATE(s%XPH(ini))
219  CALL read_surf(hprogram,'PH',s%XPH(:),iresp,hdir='A')
220  !
221  ALLOCATE(s%XFERT(ini))
222  CALL read_surf(hprogram,'FERT',s%XFERT(:),iresp,hdir='A')
223  !
224  ELSE
225  CALL abor1_sfx("READ_PGD_ISBAn: WITH LCH_NO_FLUX=T, PH AND FERT FIELDS ARE GIVEN AT PGD STEP")
226  ENDIF
227  !
228 ELSE
229  ALLOCATE(s%XPH (0))
230  ALLOCATE(s%XFERT(0))
231 END IF
232 !
233 ALLOCATE(zrunoffb(ini,1))
234  CALL read_surf(hprogram,'RUNOFFB',zfield,iresp,hdir='A')
235 zrunoffb(:,1) = zfield(:)
236 !
237 ALLOCATE(zwdrain(ini,1))
238  CALL read_surf(hprogram,'WDRAIN',zfield,iresp,hdir='A')
239 zwdrain(:,1) = zfield(:)
240 !
241 DEALLOCATE(zfield)
242 !
243 !------------------------------------------------------------------------------
244 !
245 !* 4. Interpolations
246 ! --------------
247 !
248 !* mask where interpolations must be done
249 !
250 linterp(:) = .true.
251 !
252 !* interpolations
253 !
254  CALL hor_interpol(dtco, u, gcp, iluout,zsand,k%XSAND)
255 !
256  CALL hor_interpol(dtco, u, gcp, iluout,zclay,k%XCLAY)
257 !
258 ALLOCATE(zoutb(SIZE(k%XRUNOFFB),1))
259  CALL hor_interpol(dtco, u, gcp, iluout,zrunoffb,zoutb)
260 k%XRUNOFFB(:) = zoutb(:,1)
261 DEALLOCATE(zoutb)
262 ALLOCATE(zoutw(SIZE(k%XWDRAIN),1))
263  CALL hor_interpol(dtco, u, gcp, iluout,zwdrain,zoutw)
264 k%XWDRAIN(:) = zoutw(:,1)
265 DEALLOCATE(zoutw)
266 !
267  CALL get_type_dim_n(dtco, u, 'NATURE',ig%NDIM)
268 !
269 tdate_beg%YEAR = 2016
270 tdate_beg%MONTH = 1
271 tdate_beg%DAY = 1
272 tdate_end%YEAR = 2016
273 tdate_end%MONTH = 12
274 tdate_end%DAY = 31
275  CALL read_pgd_isba_par_n(dtco, u, gcp, dtv, ig%NDIM, io, &
276  hprogram,ini,.false.,tdate_beg, tdate_end, hdir='A')
277 !
278  CALL close_aux_io_surf(hinifile,hinifiletype)
279 !
281 IF (lhook) CALL dr_hook('ZOOM_PGD_ISBA_FULL',1,zhook_handle)
282 !------------------------------------------------------------------------------
283 !
284 END SUBROUTINE zoom_pgd_isba_full
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
character(len=10) cingrid_type
Definition: modd_prep.F90:39
subroutine read_pgd_isba_par_n(DTCO, U, GCP, DTI, KDIM, IO, HPROG
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 abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
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
logical lhook
Definition: yomhook.F90:15
subroutine zoom_pgd_isba_full(CHI, DTCO, DTV, IG, IO, S, K, UG, U
subroutine open_aux_io_surf(HFILE, HFILETYPE, HMASK, HDIR)