SURFEX v8.1
General documentation of Surfex
zoom_pgd_cover.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_cover (DTCO, UG, U, GCP, &
7  HPROGRAM,HINIFILE,HINIFILETYPE,OECOCLIMAP)
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 ! Modification 17/04/12 M.Tomasini All COVER physiographic fields are now
39 !! interpolated for spawning =>
40 !! ABOR1_SFX if (.NOT.OECOCLIMAP) in comment
41 ! Modification 05/02/15 M.Moge : use NSIZE_FULL instead of SIZE(XLAT) (for clarity)
42 !! J.Escobar 18/12/2015 : missing interface
43 !----------------------------------------------------------------------------
44 !
45 !* 0. DECLARATION
46 ! -----------
47 !
50 USE modd_surf_atm_n, ONLY : surf_atm_t
52 !
53 USE modd_surf_par, ONLY : xundef
54 USE modd_data_cover_par, ONLY : jpcover
56 !
58 !
59 USE modi_convert_cover_frac
60 USE modi_open_aux_io_surf
62 USE modi_close_aux_io_surf
63 USE modi_prep_grid_extern
64 USE modi_hor_interpol
65 USE modi_prep_output_grid
66 USE modi_old_name
67 USE modi_sum_on_all_procs
68 USE modi_get_luout
69 USE modi_clean_prep_output_grid
70 USE modi_get_1d_mask
71 USE modi_read_lcover
72 #ifdef SFX_MNH
73 USE modi_read_surfx2cov_1cov_mnh
74 #endif
75 !
76 USE yomhook ,ONLY : lhook, dr_hook
77 USE parkind1 ,ONLY : jprb
78 !
79 IMPLICIT NONE
80 !
81 !* 0.1 Declaration of dummy arguments
82 ! ------------------------------
83 !
84 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
85 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
86 TYPE(surf_atm_t), INTENT(INOUT) :: U
87 TYPE(grid_conf_proj_t),INTENT(INOUT) :: GCP
88 !
89  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling
90  CHARACTER(LEN=28), INTENT(IN) :: HINIFILE ! input atmospheric file name
91  CHARACTER(LEN=6), INTENT(IN) :: HINIFILETYPE! input atmospheric file type
92 LOGICAL, INTENT(OUT) :: OECOCLIMAP ! flag to use ecoclimap
93 !
94 !
95 !* 0.2 Declaration of local variables
96 ! ------------------------------
97 !
98 INTEGER :: ICPT1
99 INTEGER :: IRESP
100 INTEGER :: ILUOUT
101 INTEGER :: INI ! total 1D dimension (input grid)
102 INTEGER :: IL ! total 1D dimension (output grid)
103 INTEGER :: JCOVER ! loop counter
104 INTEGER :: IVERSION ! surface version
105 #ifdef MNH_PARALLEL
106 REAL, DIMENSION(:), POINTER :: ZCOVER1D
107 #endif
108 REAL, DIMENSION(:,:), POINTER :: ZCOVER
109 REAL, DIMENSION(:,:), POINTER :: ZSEA1, ZWATER1, ZNATURE1, ZTOWN1
110 REAL, DIMENSION(:,:), POINTER :: ZSEA2, ZWATER2, ZNATURE2, ZTOWN2
111 REAL, DIMENSION(:), ALLOCATABLE :: ZSUM
112  CHARACTER(LEN=12) :: YRECFM ! Name of the article to be read
113  CHARACTER(LEN=100) :: YCOMMENT
114 REAL(KIND=JPRB) :: ZHOOK_HANDLE
115 !------------------------------------------------------------------------------
116 IF (lhook) CALL dr_hook('ZOOM_PGD_COVER',0,zhook_handle)
117  CALL get_luout(hprogram,iluout)
118 !
119 !* 1. Preparation of IO for reading in the file
120 ! -----------------------------------------
121 !
122 !* Note that all points are read, even those without physical meaning.
123 ! These points will not be used during the horizontal interpolation step.
124 ! Their value must be defined as XUNDEF.
125 !
126  CALL open_aux_io_surf(hinifile,hinifiletype,'FULL ')
127 !
128  CALL read_surf(hprogram,'ECOCLIMAP',oecoclimap,iresp)
129 !
130 !------------------------------------------------------------------------------
131 !
132 !* 2. Reading of grid
133 ! ---------------
134 !
135  CALL prep_output_grid(ug%G, ug%G, u%NSIZE_FULL, iluout)
136 !
137  CALL prep_grid_extern(gcp,hinifiletype,iluout,cingrid_type,cinterp_type,ini)
138 
139 !
140 !------------------------------------------------------------------------------
141 !
142 !* 3. Reading of cover
143 ! ----------------
144 !
145 yrecfm='VERSION'
146  CALL read_surf(hprogram,yrecfm,iversion,iresp)
147 !
148 ALLOCATE(u%LCOVER(jpcover))
149 !
150  CALL old_name(hprogram,'COVER_LIST ',yrecfm)
151  CALL read_lcover(hprogram,u%LCOVER)
152 !
153 #ifndef MNH_PARALLEL
154 ALLOCATE(zcover(ini,count(u%LCOVER)))
155  CALL read_surf_cov(hprogram,yrecfm,zcover(:,:),u%LCOVER,iresp,hdir='A')
156 #endif
157 !
158 ALLOCATE(zsea1(ini,1))
159 ALLOCATE(znature1(ini,1))
160 ALLOCATE(zwater1(ini,1))
161 ALLOCATE(ztown1(ini,1))
162 !
163 IF (iversion>=7) THEN
164  CALL read_surf(hprogram,'FRAC_SEA ',zsea1(:,1), iresp,hdir='A')
165  CALL read_surf(hprogram,'FRAC_NATURE',znature1(:,1),iresp,hdir='A')
166  CALL read_surf(hprogram,'FRAC_WATER ',zwater1(:,1), iresp,hdir='A')
167  CALL read_surf(hprogram,'FRAC_TOWN ',ztown1(:,1), iresp,hdir='A')
168  !
169 ELSE
170 #ifndef MNH_PARALLEL
171  CALL convert_cover_frac(dtco,zcover,u%LCOVER,zsea1(:,1),znature1(:,1),ztown1(:,1),zwater1(:,1))
172 #endif
173 ENDIF
174 !
175 !------------------------------------------------------------------------------
176 !
177 !* 4. Interpolations
178 ! --------------
179 !
180 il = u%NSIZE_FULL
181 ALLOCATE(u%XCOVER(il,count(u%LCOVER)))
182 !
183 ! on lit les cover une apres l'autre, et on appelle hor_interpol sur chaque cover separement
184 !
185 #ifdef MNH_PARALLEL
186 IF ( hprogram == 'MESONH' ) THEN
187  ALLOCATE(zcover1d(ini))
188  icpt1 = 0
189  DO jcover=1,jpcover
190  IF ( u%LCOVER( jcover ) ) THEN
191  icpt1 = icpt1 + 1
192  CALL read_surfx2cov_1cov_mnh(yrecfm,ini,jcover,zcover1d(:),iresp,ycomment,'A')
193  CALL hor_interpol(dtco, u,gcp,iluout,spread(zcover1d,2,1),u%XCOVER(:,icpt1:icpt1))
194  ENDIF
195  !
196  ENDDO
197  DEALLOCATE(zcover1d)
198 ENDIF
199 #else
200  CALL hor_interpol(dtco, u, gcp, iluout,zcover,u%XCOVER)
201 DEALLOCATE(zcover)
202 #endif
203 !
204  CALL close_aux_io_surf(hinifile,hinifiletype)
205 !
206 ALLOCATE(zcover(il,count(u%LCOVER)))
207 !
208 ALLOCATE(zsea2(il,1))
209 ALLOCATE(znature2(il,1))
210 ALLOCATE(zwater2(il,1))
211 ALLOCATE(ztown2(il,1))
212 !
213  CALL hor_interpol(dtco, u, gcp, iluout,zsea1,zsea2)
214  CALL hor_interpol(dtco, u, gcp, iluout,znature1,znature2)
215  CALL hor_interpol(dtco, u, gcp, iluout,zwater1,zwater2)
216  CALL hor_interpol(dtco, u, gcp, iluout,ztown1,ztown2)
217 !
218 DEALLOCATE(zsea1)
219 DEALLOCATE(znature1)
220 DEALLOCATE(zwater1)
221 DEALLOCATE(ztown1)
222 !
223 ALLOCATE(u%XSEA (il))
224 ALLOCATE(u%XNATURE(il))
225 ALLOCATE(u%XWATER (il))
226 ALLOCATE(u%XTOWN (il))
227 !
228 u%XSEA(:) = zsea2(:,1)
229 u%XNATURE(:)= znature2(:,1)
230 u%XWATER(:) = zwater2(:,1)
231 u%XTOWN(:) = ztown2(:,1)
232 !
233 DEALLOCATE(zsea2)
234 DEALLOCATE(znature2)
235 DEALLOCATE(zwater2)
236 DEALLOCATE(ztown2)
237 !
239 !------------------------------------------------------------------------------
240 !
241 !* 5. Coherence check
242 ! ---------------
243 !
244 ALLOCATE(zsum(il))
245 zsum = 0.
246 DO jcover=1,SIZE(u%XCOVER,2)
247  zsum(:) = zsum(:) + u%XCOVER(:,jcover)
248 END DO
249 !
250 DO jcover=1,SIZE(u%XCOVER,2)
251  WHERE(zsum(:)/=0.) u%XCOVER(:,jcover) = u%XCOVER(:,jcover)/zsum(:)
252 END DO
253 !
254 !------------------------------------------------------------------------------
255 !
256 !* 6. Fractions
257 ! ---------
258 !
259 ! When the model runs in multiproc, NSIZE* represents the number of points
260 ! on a proc, and NDIM* the total number of points on all procs.
261 ! The following definition of NDIM* won't be correct any more when the PGD
262 ! runs in multiproc.
263 !
264 u%NSIZE_NATURE = count(u%XNATURE(:) > 0.0)
265 u%NSIZE_WATER = count(u%XWATER (:) > 0.0)
266 u%NSIZE_SEA = count(u%XSEA (:) > 0.0)
267 u%NSIZE_TOWN = count(u%XTOWN (:) > 0.0)
268 u%NSIZE_FULL = il
269 !
270 u%NDIM_NATURE = sum_on_all_procs(hprogram,ug%G%CGRID,u%XNATURE(:) > 0., 'DIM')
271 u%NDIM_WATER = sum_on_all_procs(hprogram,ug%G%CGRID,u%XWATER (:) > 0., 'DIM')
272 u%NDIM_SEA = sum_on_all_procs(hprogram,ug%G%CGRID,u%XSEA (:) > 0., 'DIM')
273 u%NDIM_TOWN = sum_on_all_procs(hprogram,ug%G%CGRID,u%XTOWN (:) > 0., 'DIM')
274 zsum=1.
275 u%NDIM_FULL = sum_on_all_procs(hprogram,ug%G%CGRID,zsum(:) ==1., 'DIM')
276 DEALLOCATE(zsum)
277 !
278 ALLOCATE(u%NR_NATURE (u%NSIZE_NATURE))
279 ALLOCATE(u%NR_TOWN (u%NSIZE_TOWN ))
280 ALLOCATE(u%NR_WATER (u%NSIZE_WATER ))
281 ALLOCATE(u%NR_SEA (u%NSIZE_SEA ))
282 !
283 IF (u%NSIZE_SEA >0)CALL get_1d_mask( u%NSIZE_SEA, u%NSIZE_FULL, u%XSEA , u%NR_SEA )
284 IF (u%NSIZE_WATER >0)CALL get_1d_mask( u%NSIZE_WATER, u%NSIZE_FULL, u%XWATER , u%NR_WATER )
285 IF (u%NSIZE_TOWN >0)CALL get_1d_mask( u%NSIZE_TOWN, u%NSIZE_FULL, u%XTOWN , u%NR_TOWN )
286 IF (u%NSIZE_NATURE>0)CALL get_1d_mask( u%NSIZE_NATURE, u%NSIZE_FULL, u%XNATURE, u%NR_NATURE)
287 IF (lhook) CALL dr_hook('ZOOM_PGD_COVER',1,zhook_handle)
288 
289 !_______________________________________________________________________________
290 !
291 END SUBROUTINE zoom_pgd_cover
character(len=10) cingrid_type
Definition: modd_prep.F90:39
subroutine clean_prep_output_grid
subroutine old_name(HPROGRAM, HRECIN, HRECOUT, HDIR)
Definition: old_name.F90:7
integer function sum_on_all_procs(HPROGRAM, HGRID, OIN, HNAME)
character(len=6) cinterp_type
Definition: modd_prep.F90:40
subroutine close_aux_io_surf(HFILE, HFILETYPE)
subroutine read_surf_cov(HPROGRAM, HREC, PFIELD, OFLAG, KRESP, HCOMMENT, HDIR)
subroutine prep_grid_extern(GCP, HFILETYPE, KLUOUT, HGRIDTYPE, HINTER
real, parameter xundef
subroutine hor_interpol(DTCO, U, GCP, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:7
integer, parameter jprb
Definition: parkind1.F90:32
subroutine read_lcover(HPROGRAM, OCOVER)
Definition: read_lcover.F90:7
subroutine prep_output_grid(UG, G, KSIZE_FULL, KLUOUT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
subroutine get_1d_mask(KSIZE, KFRAC, PFRAC, KMASK)
Definition: get_1d_mask.F90:6
logical lhook
Definition: yomhook.F90:15
subroutine open_aux_io_surf(HFILE, HFILETYPE, HMASK, HDIR)
subroutine zoom_pgd_cover(DTCO, UG, U, GCP, HPROGRAM, HINIFILE, HINIFILETYPE, OECOCLIM
subroutine convert_cover_frac(DTCO, PCOVER, OCOVER, PSEA, PNATURE, PTOWN, PWATER)
static int count
Definition: memory_hook.c:21