1 | ! |
---|
2 | MODULE surf_land_orchidee_mod |
---|
3 | #ifndef ORCHIDEE_NOOPENMP |
---|
4 | ! |
---|
5 | ! This module controles the interface towards the model ORCHIDEE |
---|
6 | ! |
---|
7 | ! Subroutines in this module : surf_land_orchidee |
---|
8 | ! Init_orchidee_index |
---|
9 | ! Get_orchidee_communicator |
---|
10 | ! Init_neighbours |
---|
11 | |
---|
12 | USE dimphy |
---|
13 | #ifdef CPP_VEGET |
---|
14 | USE intersurf ! module d'ORCHIDEE |
---|
15 | #endif |
---|
16 | USE cpl_mod, ONLY : cpl_send_land_fields |
---|
17 | USE surface_data, ONLY : type_ocean |
---|
18 | USE comgeomphy, ONLY : cuphy, cvphy |
---|
19 | USE mod_grid_phy_lmdz |
---|
20 | USE mod_phys_lmdz_para, mpi_root_rank=>mpi_root |
---|
21 | |
---|
22 | IMPLICIT NONE |
---|
23 | |
---|
24 | PRIVATE |
---|
25 | PUBLIC :: surf_land_orchidee |
---|
26 | |
---|
27 | LOGICAL, ALLOCATABLE, SAVE :: flag_omp(:) |
---|
28 | CONTAINS |
---|
29 | ! |
---|
30 | !**************************************************************************************** |
---|
31 | ! |
---|
32 | SUBROUTINE surf_land_orchidee(itime, dtime, date0, knon, & |
---|
33 | knindex, rlon, rlat, pctsrf, & |
---|
34 | debut, lafin, & |
---|
35 | plev, u1_lay, v1_lay, temp_air, spechum, epot_air, ccanopy, & |
---|
36 | tq_cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, & |
---|
37 | precip_rain, precip_snow, lwdown, swnet, swdown, & |
---|
38 | ps, & |
---|
39 | evap, fluxsens, fluxlat, & |
---|
40 | tsol_rad, tsurf_new, alb1_new, alb2_new, & |
---|
41 | emis_new, z0_new, qsurf) |
---|
42 | USE mod_surf_para |
---|
43 | USE mod_synchro_omp |
---|
44 | |
---|
45 | ! |
---|
46 | ! Cette routine sert d'interface entre le modele atmospherique et le |
---|
47 | ! modele de sol continental. Appel a sechiba |
---|
48 | ! |
---|
49 | ! L. Fairhead 02/2000 |
---|
50 | ! |
---|
51 | ! input: |
---|
52 | ! itime numero du pas de temps |
---|
53 | ! dtime pas de temps de la physique (en s) |
---|
54 | ! nisurf index de la surface a traiter (1 = sol continental) |
---|
55 | ! knon nombre de points de la surface a traiter |
---|
56 | ! knindex index des points de la surface a traiter |
---|
57 | ! rlon longitudes de la grille entiere |
---|
58 | ! rlat latitudes de la grille entiere |
---|
59 | ! pctsrf tableau des fractions de surface de chaque maille |
---|
60 | ! debut logical: 1er appel a la physique (lire les restart) |
---|
61 | ! lafin logical: dernier appel a la physique (ecrire les restart) |
---|
62 | ! (si false calcul simplifie des fluxs sur les continents) |
---|
63 | ! plev hauteur de la premiere couche (Pa) |
---|
64 | ! u1_lay vitesse u 1ere couche |
---|
65 | ! v1_lay vitesse v 1ere couche |
---|
66 | ! temp_air temperature de l'air 1ere couche |
---|
67 | ! spechum humidite specifique 1ere couche |
---|
68 | ! epot_air temp pot de l'air |
---|
69 | ! ccanopy concentration CO2 canopee |
---|
70 | ! tq_cdrag cdrag |
---|
71 | ! petAcoef coeff. A de la resolution de la CL pour t |
---|
72 | ! peqAcoef coeff. A de la resolution de la CL pour q |
---|
73 | ! petBcoef coeff. B de la resolution de la CL pour t |
---|
74 | ! peqBcoef coeff. B de la resolution de la CL pour q |
---|
75 | ! precip_rain precipitation liquide |
---|
76 | ! precip_snow precipitation solide |
---|
77 | ! lwdown flux IR descendant a la surface |
---|
78 | ! swnet flux solaire net |
---|
79 | ! swdown flux solaire entrant a la surface |
---|
80 | ! ps pression au sol |
---|
81 | ! radsol rayonnement net aus sol (LW + SW) |
---|
82 | ! |
---|
83 | ! |
---|
84 | ! output: |
---|
85 | ! evap evaporation totale |
---|
86 | ! fluxsens flux de chaleur sensible |
---|
87 | ! fluxlat flux de chaleur latente |
---|
88 | ! tsol_rad |
---|
89 | ! tsurf_new temperature au sol |
---|
90 | ! alb1_new albedo in visible SW interval |
---|
91 | ! alb2_new albedo in near IR interval |
---|
92 | ! emis_new emissivite |
---|
93 | ! z0_new surface roughness |
---|
94 | ! qsurf air moisture at surface |
---|
95 | ! |
---|
96 | INCLUDE "indicesol.h" |
---|
97 | INCLUDE "temps.h" |
---|
98 | INCLUDE "YOMCST.h" |
---|
99 | INCLUDE "iniprint.h" |
---|
100 | INCLUDE "dimensions.h" |
---|
101 | |
---|
102 | ! |
---|
103 | ! Parametres d'entree |
---|
104 | !**************************************************************************************** |
---|
105 | INTEGER, INTENT(IN) :: itime |
---|
106 | REAL, INTENT(IN) :: dtime |
---|
107 | REAL, INTENT(IN) :: date0 |
---|
108 | INTEGER, INTENT(IN) :: knon |
---|
109 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
110 | LOGICAL, INTENT(IN) :: debut, lafin |
---|
111 | REAL, DIMENSION(klon,nbsrf), INTENT(IN) :: pctsrf |
---|
112 | REAL, DIMENSION(klon), INTENT(IN) :: rlon, rlat |
---|
113 | REAL, DIMENSION(klon), INTENT(IN) :: plev |
---|
114 | REAL, DIMENSION(klon), INTENT(IN) :: u1_lay, v1_lay |
---|
115 | REAL, DIMENSION(klon), INTENT(IN) :: temp_air, spechum |
---|
116 | REAL, DIMENSION(klon), INTENT(IN) :: epot_air, ccanopy |
---|
117 | REAL, DIMENSION(klon), INTENT(IN) :: tq_cdrag |
---|
118 | REAL, DIMENSION(klon), INTENT(IN) :: petAcoef, peqAcoef |
---|
119 | REAL, DIMENSION(klon), INTENT(IN) :: petBcoef, peqBcoef |
---|
120 | REAL, DIMENSION(klon), INTENT(IN) :: precip_rain, precip_snow |
---|
121 | REAL, DIMENSION(klon), INTENT(IN) :: lwdown, swnet, swdown, ps |
---|
122 | REAL, DIMENSION(klon) :: swdown_vrai |
---|
123 | |
---|
124 | ! Parametres de sortie |
---|
125 | !**************************************************************************************** |
---|
126 | REAL, DIMENSION(klon), INTENT(OUT) :: evap, fluxsens, fluxlat, qsurf |
---|
127 | REAL, DIMENSION(klon), INTENT(OUT) :: tsol_rad, tsurf_new |
---|
128 | REAL, DIMENSION(klon), INTENT(OUT) :: alb1_new, alb2_new |
---|
129 | REAL, DIMENSION(klon), INTENT(OUT) :: emis_new, z0_new |
---|
130 | |
---|
131 | ! Local |
---|
132 | !**************************************************************************************** |
---|
133 | INTEGER :: ij, jj, igrid, ireal, index |
---|
134 | INTEGER :: error |
---|
135 | CHARACTER (len = 20) :: modname = 'surf_land_orchidee' |
---|
136 | CHARACTER (len = 80) :: abort_message |
---|
137 | LOGICAL,SAVE :: check = .FALSE. |
---|
138 | !$OMP THREADPRIVATE(check) |
---|
139 | |
---|
140 | ! type de couplage dans sechiba |
---|
141 | ! character (len=10) :: coupling = 'implicit' |
---|
142 | ! drapeaux controlant les appels dans SECHIBA |
---|
143 | ! type(control_type), save :: control_in |
---|
144 | ! Preserved albedo |
---|
145 | REAL, ALLOCATABLE, DIMENSION(:), SAVE :: albedo_keep, zlev |
---|
146 | !$OMP THREADPRIVATE(albedo_keep,zlev) |
---|
147 | ! coordonnees geographiques |
---|
148 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: lalo |
---|
149 | !$OMP THREADPRIVATE(lalo) |
---|
150 | ! pts voisins |
---|
151 | INTEGER,ALLOCATABLE, DIMENSION(:,:), SAVE :: neighbours |
---|
152 | !$OMP THREADPRIVATE(neighbours) |
---|
153 | ! fractions continents |
---|
154 | REAL,ALLOCATABLE, DIMENSION(:), SAVE :: contfrac |
---|
155 | !$OMP THREADPRIVATE(contfrac) |
---|
156 | ! resolution de la grille |
---|
157 | REAL, ALLOCATABLE, DIMENSION (:,:), SAVE :: resolution |
---|
158 | !$OMP THREADPRIVATE(resolution) |
---|
159 | |
---|
160 | REAL, ALLOCATABLE, DIMENSION (:,:), SAVE :: lon_scat, lat_scat |
---|
161 | !$OMP THREADPRIVATE(lon_scat,lat_scat) |
---|
162 | |
---|
163 | LOGICAL, SAVE :: lrestart_read = .TRUE. |
---|
164 | !$OMP THREADPRIVATE(lrestart_read) |
---|
165 | LOGICAL, SAVE :: lrestart_write = .FALSE. |
---|
166 | !$OMP THREADPRIVATE(lrestart_write) |
---|
167 | |
---|
168 | REAL, DIMENSION(knon,2) :: albedo_out |
---|
169 | |
---|
170 | ! Pb de nomenclature |
---|
171 | REAL, DIMENSION(klon) :: petA_orc, peqA_orc |
---|
172 | REAL, DIMENSION(klon) :: petB_orc, peqB_orc |
---|
173 | ! Pb de correspondances de grilles |
---|
174 | INTEGER, DIMENSION(:), SAVE, ALLOCATABLE :: ig, jg |
---|
175 | !$OMP THREADPRIVATE(ig,jg) |
---|
176 | INTEGER :: indi, indj |
---|
177 | INTEGER, SAVE, ALLOCATABLE,DIMENSION(:) :: ktindex |
---|
178 | !$OMP THREADPRIVATE(ktindex) |
---|
179 | |
---|
180 | ! Essai cdrag |
---|
181 | REAL, DIMENSION(klon) :: cdrag |
---|
182 | INTEGER,SAVE :: offset |
---|
183 | !$OMP THREADPRIVATE(offset) |
---|
184 | |
---|
185 | REAL, DIMENSION(klon_glo) :: rlon_g,rlat_g |
---|
186 | INTEGER, SAVE :: orch_comm |
---|
187 | !$OMP THREADPRIVATE(orch_comm) |
---|
188 | |
---|
189 | REAL, ALLOCATABLE, DIMENSION(:), SAVE :: coastalflow |
---|
190 | !$OMP THREADPRIVATE(coastalflow) |
---|
191 | REAL, ALLOCATABLE, DIMENSION(:), SAVE :: riverflow |
---|
192 | !$OMP THREADPRIVATE(riverflow) |
---|
193 | |
---|
194 | INTEGER :: orch_omp_rank |
---|
195 | INTEGER :: orch_omp_size |
---|
196 | ! |
---|
197 | ! Fin definition |
---|
198 | !**************************************************************************************** |
---|
199 | |
---|
200 | IF (check) WRITE(lunout,*)'Entree ', modname |
---|
201 | |
---|
202 | ! Initialisation |
---|
203 | |
---|
204 | IF (debut) THEN |
---|
205 | ! Test of coherence between variable ok_veget and cpp key CPP_VEGET |
---|
206 | #ifndef CPP_VEGET |
---|
207 | abort_message='Pb de coherence: ok_veget = .true. mais CPP_VEGET = .false.' |
---|
208 | CALL abort_gcm(modname,abort_message,1) |
---|
209 | #endif |
---|
210 | |
---|
211 | CALL Init_surf_para(knon) |
---|
212 | ALLOCATE(ktindex(knon)) |
---|
213 | IF ( .NOT. ALLOCATED(albedo_keep)) THEN |
---|
214 | !ym ALLOCATE(albedo_keep(klon)) |
---|
215 | !ym bizarre que non alloué en knon precedement |
---|
216 | ALLOCATE(albedo_keep(knon)) |
---|
217 | ALLOCATE(zlev(knon)) |
---|
218 | ENDIF |
---|
219 | ! Pb de correspondances de grilles |
---|
220 | ALLOCATE(ig(klon)) |
---|
221 | ALLOCATE(jg(klon)) |
---|
222 | ig(1) = 1 |
---|
223 | jg(1) = 1 |
---|
224 | indi = 0 |
---|
225 | indj = 2 |
---|
226 | DO igrid = 2, klon - 1 |
---|
227 | indi = indi + 1 |
---|
228 | IF ( indi > iim) THEN |
---|
229 | indi = 1 |
---|
230 | indj = indj + 1 |
---|
231 | ENDIF |
---|
232 | ig(igrid) = indi |
---|
233 | jg(igrid) = indj |
---|
234 | ENDDO |
---|
235 | ig(klon) = 1 |
---|
236 | jg(klon) = jjm + 1 |
---|
237 | |
---|
238 | IF ((.NOT. ALLOCATED(lalo))) THEN |
---|
239 | ALLOCATE(lalo(knon,2), stat = error) |
---|
240 | IF (error /= 0) THEN |
---|
241 | abort_message='Pb allocation lalo' |
---|
242 | CALL abort_gcm(modname,abort_message,1) |
---|
243 | ENDIF |
---|
244 | ENDIF |
---|
245 | IF ((.NOT. ALLOCATED(lon_scat))) THEN |
---|
246 | ALLOCATE(lon_scat(iim,jjm+1), stat = error) |
---|
247 | IF (error /= 0) THEN |
---|
248 | abort_message='Pb allocation lon_scat' |
---|
249 | CALL abort_gcm(modname,abort_message,1) |
---|
250 | ENDIF |
---|
251 | ENDIF |
---|
252 | IF ((.NOT. ALLOCATED(lat_scat))) THEN |
---|
253 | ALLOCATE(lat_scat(iim,jjm+1), stat = error) |
---|
254 | IF (error /= 0) THEN |
---|
255 | abort_message='Pb allocation lat_scat' |
---|
256 | CALL abort_gcm(modname,abort_message,1) |
---|
257 | ENDIF |
---|
258 | ENDIF |
---|
259 | lon_scat = 0. |
---|
260 | lat_scat = 0. |
---|
261 | DO igrid = 1, knon |
---|
262 | index = knindex(igrid) |
---|
263 | lalo(igrid,2) = rlon(index) |
---|
264 | lalo(igrid,1) = rlat(index) |
---|
265 | ENDDO |
---|
266 | |
---|
267 | |
---|
268 | |
---|
269 | CALL Gather(rlon,rlon_g) |
---|
270 | CALL Gather(rlat,rlat_g) |
---|
271 | |
---|
272 | IF (is_mpi_root) THEN |
---|
273 | index = 1 |
---|
274 | DO jj = 2, jjm |
---|
275 | DO ij = 1, iim |
---|
276 | index = index + 1 |
---|
277 | lon_scat(ij,jj) = rlon_g(index) |
---|
278 | lat_scat(ij,jj) = rlat_g(index) |
---|
279 | ENDDO |
---|
280 | ENDDO |
---|
281 | lon_scat(:,1) = lon_scat(:,2) |
---|
282 | lat_scat(:,1) = rlat_g(1) |
---|
283 | lon_scat(:,jjm+1) = lon_scat(:,2) |
---|
284 | lat_scat(:,jjm+1) = rlat_g(klon_glo) |
---|
285 | ENDIF |
---|
286 | |
---|
287 | CALL bcast(lon_scat) |
---|
288 | CALL bcast(lat_scat) |
---|
289 | ! |
---|
290 | ! Allouer et initialiser le tableau des voisins et des fraction de continents |
---|
291 | ! |
---|
292 | IF ( (.NOT.ALLOCATED(neighbours))) THEN |
---|
293 | ALLOCATE(neighbours(knon,8), stat = error) |
---|
294 | IF (error /= 0) THEN |
---|
295 | abort_message='Pb allocation neighbours' |
---|
296 | CALL abort_gcm(modname,abort_message,1) |
---|
297 | ENDIF |
---|
298 | ENDIF |
---|
299 | neighbours = -1. |
---|
300 | IF (( .NOT. ALLOCATED(contfrac))) THEN |
---|
301 | ALLOCATE(contfrac(knon), stat = error) |
---|
302 | IF (error /= 0) THEN |
---|
303 | abort_message='Pb allocation contfrac' |
---|
304 | CALL abort_gcm(modname,abort_message,1) |
---|
305 | ENDIF |
---|
306 | ENDIF |
---|
307 | |
---|
308 | DO igrid = 1, knon |
---|
309 | ireal = knindex(igrid) |
---|
310 | contfrac(igrid) = pctsrf(ireal,is_ter) |
---|
311 | ENDDO |
---|
312 | |
---|
313 | |
---|
314 | CALL Init_neighbours(knon,neighbours,knindex,pctsrf(:,is_ter)) |
---|
315 | |
---|
316 | ! |
---|
317 | ! Allocation et calcul resolutions |
---|
318 | IF ( (.NOT.ALLOCATED(resolution))) THEN |
---|
319 | ALLOCATE(resolution(knon,2), stat = error) |
---|
320 | IF (error /= 0) THEN |
---|
321 | abort_message='Pb allocation resolution' |
---|
322 | CALL abort_gcm(modname,abort_message,1) |
---|
323 | ENDIF |
---|
324 | ENDIF |
---|
325 | DO igrid = 1, knon |
---|
326 | ij = knindex(igrid) |
---|
327 | resolution(igrid,1) = cuphy(ij) |
---|
328 | resolution(igrid,2) = cvphy(ij) |
---|
329 | ENDDO |
---|
330 | |
---|
331 | ALLOCATE(coastalflow(klon), stat = error) |
---|
332 | IF (error /= 0) THEN |
---|
333 | abort_message='Pb allocation coastalflow' |
---|
334 | CALL abort_gcm(modname,abort_message,1) |
---|
335 | ENDIF |
---|
336 | |
---|
337 | ALLOCATE(riverflow(klon), stat = error) |
---|
338 | IF (error /= 0) THEN |
---|
339 | abort_message='Pb allocation riverflow' |
---|
340 | CALL abort_gcm(modname,abort_message,1) |
---|
341 | ENDIF |
---|
342 | |
---|
343 | ENDIF ! (fin debut) |
---|
344 | |
---|
345 | ! |
---|
346 | ! Appel a la routine sols continentaux |
---|
347 | ! |
---|
348 | IF (lafin) lrestart_write = .TRUE. |
---|
349 | IF (check) WRITE(lunout,*)'lafin ',lafin,lrestart_write |
---|
350 | |
---|
351 | petA_orc(1:knon) = petBcoef(1:knon) * dtime |
---|
352 | petB_orc(1:knon) = petAcoef(1:knon) |
---|
353 | peqA_orc(1:knon) = peqBcoef(1:knon) * dtime |
---|
354 | peqB_orc(1:knon) = peqAcoef(1:knon) |
---|
355 | |
---|
356 | cdrag = 0. |
---|
357 | cdrag(1:knon) = tq_cdrag(1:knon) |
---|
358 | |
---|
359 | ! zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/287.05*temp_air(1:knon))*9.80665) |
---|
360 | zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/RD*temp_air(1:knon))*RG) |
---|
361 | |
---|
362 | |
---|
363 | ! PF et PASB |
---|
364 | ! where(cdrag > 0.01) |
---|
365 | ! cdrag = 0.01 |
---|
366 | ! endwhere |
---|
367 | ! write(*,*)'Cdrag = ',minval(cdrag),maxval(cdrag) |
---|
368 | |
---|
369 | |
---|
370 | IF (debut) THEN |
---|
371 | CALL Init_orchidee_index(knon,knindex,offset,ktindex) |
---|
372 | CALL Get_orchidee_communicator(orch_comm,orch_omp_size,orch_omp_rank) |
---|
373 | CALL Init_synchro_omp |
---|
374 | |
---|
375 | IF (knon > 0) THEN |
---|
376 | #ifdef CPP_VEGET |
---|
377 | CALL Init_intersurf(nbp_lon,nbp_lat,knon,ktindex,offset,orch_omp_size,orch_omp_rank,orch_comm) |
---|
378 | #endif |
---|
379 | ENDIF |
---|
380 | |
---|
381 | |
---|
382 | IF (knon > 0) THEN |
---|
383 | |
---|
384 | #ifdef CPP_VEGET |
---|
385 | CALL intersurf_main (itime+itau_phy-1, iim, jjm+1, knon, ktindex, dtime, & |
---|
386 | lrestart_read, lrestart_write, lalo, & |
---|
387 | contfrac, neighbours, resolution, date0, & |
---|
388 | zlev, u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, & |
---|
389 | cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, & |
---|
390 | precip_rain, precip_snow, lwdown, swnet, swdown, ps, & |
---|
391 | evap, fluxsens, fluxlat, coastalflow, riverflow, & |
---|
392 | tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, & |
---|
393 | lon_scat, lat_scat) |
---|
394 | #endif |
---|
395 | ENDIF |
---|
396 | |
---|
397 | CALL Synchro_omp |
---|
398 | |
---|
399 | albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2. |
---|
400 | |
---|
401 | ENDIF |
---|
402 | |
---|
403 | |
---|
404 | ! swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon)) |
---|
405 | swdown_vrai(1:knon) = swdown(1:knon) |
---|
406 | |
---|
407 | IF (knon > 0) THEN |
---|
408 | #ifdef CPP_VEGET |
---|
409 | CALL intersurf_main (itime+itau_phy, iim, jjm+1, knon, ktindex, dtime, & |
---|
410 | lrestart_read, lrestart_write, lalo, & |
---|
411 | contfrac, neighbours, resolution, date0, & |
---|
412 | zlev, u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), & |
---|
413 | cdrag(1:knon), petA_orc(1:knon), peqA_orc(1:knon), petB_orc(1:knon), peqB_orc(1:knon), & |
---|
414 | precip_rain(1:knon), precip_snow(1:knon), lwdown(1:knon), swnet(1:knon), swdown_vrai(1:knon), ps(1:knon), & |
---|
415 | evap(1:knon), fluxsens(1:knon), fluxlat(1:knon), coastalflow(1:knon), riverflow(1:knon), & |
---|
416 | tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0_new(1:knon), & |
---|
417 | lon_scat, lat_scat) |
---|
418 | #endif |
---|
419 | ENDIF |
---|
420 | |
---|
421 | CALL Synchro_omp |
---|
422 | |
---|
423 | albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2. |
---|
424 | |
---|
425 | !* Send to coupler |
---|
426 | ! |
---|
427 | IF (type_ocean=='couple') THEN |
---|
428 | CALL cpl_send_land_fields(itime, knon, knindex, & |
---|
429 | riverflow, coastalflow) |
---|
430 | ENDIF |
---|
431 | |
---|
432 | alb1_new(1:knon) = albedo_out(1:knon,1) |
---|
433 | alb2_new(1:knon) = albedo_out(1:knon,2) |
---|
434 | |
---|
435 | ! Convention orchidee: positif vers le haut |
---|
436 | fluxsens(1:knon) = -1. * fluxsens(1:knon) |
---|
437 | fluxlat(1:knon) = -1. * fluxlat(1:knon) |
---|
438 | |
---|
439 | ! evap = -1. * evap |
---|
440 | |
---|
441 | IF (debut) lrestart_read = .FALSE. |
---|
442 | |
---|
443 | IF (debut) CALL Finalize_surf_para |
---|
444 | |
---|
445 | END SUBROUTINE surf_land_orchidee |
---|
446 | ! |
---|
447 | !**************************************************************************************** |
---|
448 | ! |
---|
449 | SUBROUTINE Init_orchidee_index(knon,knindex,offset,ktindex) |
---|
450 | USE mod_surf_para |
---|
451 | USE mod_grid_phy_lmdz |
---|
452 | |
---|
453 | INTEGER,INTENT(IN) :: knon |
---|
454 | INTEGER,INTENT(IN) :: knindex(klon) |
---|
455 | INTEGER,INTENT(OUT) :: offset |
---|
456 | INTEGER,INTENT(OUT) :: ktindex(klon) |
---|
457 | |
---|
458 | INTEGER :: ktindex_glo(knon_glo) |
---|
459 | INTEGER :: offset_para(0:omp_size*mpi_size-1) |
---|
460 | INTEGER :: LastPoint |
---|
461 | INTEGER :: task |
---|
462 | |
---|
463 | ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1 |
---|
464 | |
---|
465 | CALL gather_surf(ktindex(1:knon),ktindex_glo) |
---|
466 | |
---|
467 | IF (is_mpi_root .AND. is_omp_root) THEN |
---|
468 | LastPoint=0 |
---|
469 | DO Task=0,mpi_size*omp_size-1 |
---|
470 | IF (knon_glo_para(Task)>0) THEN |
---|
471 | offset_para(task)= LastPoint-MOD(LastPoint,nbp_lon) |
---|
472 | LastPoint=ktindex_glo(knon_glo_end_para(task)) |
---|
473 | ENDIF |
---|
474 | ENDDO |
---|
475 | ENDIF |
---|
476 | |
---|
477 | CALL bcast(offset_para) |
---|
478 | |
---|
479 | offset=offset_para(omp_size*mpi_rank+omp_rank) |
---|
480 | |
---|
481 | ktindex(1:knon)=ktindex(1:knon)-offset |
---|
482 | |
---|
483 | END SUBROUTINE Init_orchidee_index |
---|
484 | |
---|
485 | ! |
---|
486 | !************************* *************************************************************** |
---|
487 | ! |
---|
488 | |
---|
489 | SUBROUTINE Get_orchidee_communicator(orch_comm,orch_omp_size,orch_omp_rank) |
---|
490 | USE mod_surf_para |
---|
491 | |
---|
492 | #ifdef CPP_MPI |
---|
493 | INCLUDE 'mpif.h' |
---|
494 | #endif |
---|
495 | |
---|
496 | INTEGER,INTENT(OUT) :: orch_comm |
---|
497 | INTEGER,INTENT(OUT) :: orch_omp_size |
---|
498 | INTEGER,INTENT(OUT) :: orch_omp_rank |
---|
499 | INTEGER :: color |
---|
500 | INTEGER :: i,ierr |
---|
501 | ! |
---|
502 | ! End definition |
---|
503 | !**************************************************************************************** |
---|
504 | |
---|
505 | |
---|
506 | IF (is_omp_root) THEN |
---|
507 | |
---|
508 | IF (knon_mpi==0) THEN |
---|
509 | color = 0 |
---|
510 | ELSE |
---|
511 | color = 1 |
---|
512 | ENDIF |
---|
513 | |
---|
514 | #ifdef CPP_MPI |
---|
515 | CALL MPI_COMM_SPLIT(COMM_LMDZ_PHY,color,mpi_rank,orch_comm,ierr) |
---|
516 | #endif |
---|
517 | |
---|
518 | ENDIF |
---|
519 | CALL bcast_omp(orch_comm) |
---|
520 | |
---|
521 | IF (knon_mpi /= 0) THEN |
---|
522 | orch_omp_size=0 |
---|
523 | DO i=0,omp_size-1 |
---|
524 | IF (knon_omp_para(i) /=0) THEN |
---|
525 | orch_omp_size=orch_omp_size+1 |
---|
526 | IF (i==omp_rank) orch_omp_rank=orch_omp_size-1 |
---|
527 | ENDIF |
---|
528 | ENDDO |
---|
529 | ENDIF |
---|
530 | |
---|
531 | |
---|
532 | END SUBROUTINE Get_orchidee_communicator |
---|
533 | ! |
---|
534 | !**************************************************************************************** |
---|
535 | ! |
---|
536 | |
---|
537 | SUBROUTINE Init_neighbours(knon,neighbours,knindex,pctsrf) |
---|
538 | USE mod_grid_phy_lmdz |
---|
539 | USE mod_surf_para |
---|
540 | INCLUDE "indicesol.h" |
---|
541 | |
---|
542 | #ifdef CPP_MPI |
---|
543 | INCLUDE 'mpif.h' |
---|
544 | #endif |
---|
545 | |
---|
546 | ! Input arguments |
---|
547 | !**************************************************************************************** |
---|
548 | INTEGER, INTENT(IN) :: knon |
---|
549 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
550 | REAL, DIMENSION(klon), INTENT(IN) :: pctsrf |
---|
551 | |
---|
552 | ! Output arguments |
---|
553 | !**************************************************************************************** |
---|
554 | INTEGER, DIMENSION(knon,8), INTENT(OUT) :: neighbours |
---|
555 | |
---|
556 | ! Local variables |
---|
557 | !**************************************************************************************** |
---|
558 | INTEGER :: i, igrid, jj, ij, iglob |
---|
559 | INTEGER :: ierr, ireal, index |
---|
560 | INTEGER, DIMENSION(8,3) :: off_ini |
---|
561 | INTEGER, DIMENSION(8) :: offset |
---|
562 | INTEGER, DIMENSION(nbp_lon,nbp_lat) :: correspond |
---|
563 | INTEGER, DIMENSION(knon_glo) :: ktindex_glo |
---|
564 | INTEGER, DIMENSION(knon_glo,8) :: neighbours_glo |
---|
565 | REAL, DIMENSION(klon_glo) :: pctsrf_glo |
---|
566 | INTEGER :: ktindex(klon) |
---|
567 | ! |
---|
568 | ! End definition |
---|
569 | !**************************************************************************************** |
---|
570 | |
---|
571 | ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1 |
---|
572 | |
---|
573 | CALL gather_surf(ktindex(1:knon),ktindex_glo) |
---|
574 | CALL gather(pctsrf,pctsrf_glo) |
---|
575 | |
---|
576 | IF (is_mpi_root .AND. is_omp_root) THEN |
---|
577 | neighbours_glo(:,:)=-1 |
---|
578 | ! Initialisation des offset |
---|
579 | ! |
---|
580 | ! offset bord ouest |
---|
581 | off_ini(1,1) = - nbp_lon ; off_ini(2,1) = - nbp_lon + 1 ; off_ini(3,1) = 1 |
---|
582 | off_ini(4,1) = nbp_lon + 1 ; off_ini(5,1) = nbp_lon ; off_ini(6,1) = 2 * nbp_lon - 1 |
---|
583 | off_ini(7,1) = nbp_lon -1 ; off_ini(8,1) = - 1 |
---|
584 | ! offset point normal |
---|
585 | off_ini(1,2) = - nbp_lon ; off_ini(2,2) = - nbp_lon + 1 ; off_ini(3,2) = 1 |
---|
586 | off_ini(4,2) = nbp_lon + 1 ; off_ini(5,2) = nbp_lon ; off_ini(6,2) = nbp_lon - 1 |
---|
587 | off_ini(7,2) = -1 ; off_ini(8,2) = - nbp_lon - 1 |
---|
588 | ! offset bord est |
---|
589 | off_ini(1,3) = - nbp_lon ; off_ini(2,3) = - 2 * nbp_lon + 1 ; off_ini(3,3) = - nbp_lon + 1 |
---|
590 | off_ini(4,3) = 1 ; off_ini(5,3) = nbp_lon ; off_ini(6,3) = nbp_lon - 1 |
---|
591 | off_ini(7,3) = -1 ; off_ini(8,3) = - nbp_lon - 1 |
---|
592 | ! |
---|
593 | ! |
---|
594 | ! Attention aux poles |
---|
595 | ! |
---|
596 | DO igrid = 1, knon_glo |
---|
597 | index = ktindex_glo(igrid) |
---|
598 | jj = INT((index - 1)/nbp_lon) + 1 |
---|
599 | ij = index - (jj - 1) * nbp_lon |
---|
600 | correspond(ij,jj) = igrid |
---|
601 | ENDDO |
---|
602 | |
---|
603 | DO igrid = 1, knon_glo |
---|
604 | iglob = ktindex_glo(igrid) |
---|
605 | |
---|
606 | IF (MOD(iglob, nbp_lon) == 1) THEN |
---|
607 | offset = off_ini(:,1) |
---|
608 | ELSE IF(MOD(iglob, nbp_lon) == 0) THEN |
---|
609 | offset = off_ini(:,3) |
---|
610 | ELSE |
---|
611 | offset = off_ini(:,2) |
---|
612 | ENDIF |
---|
613 | |
---|
614 | DO i = 1, 8 |
---|
615 | index = iglob + offset(i) |
---|
616 | ireal = (MIN(MAX(1, index - nbp_lon + 1), klon_glo)) |
---|
617 | IF (pctsrf_glo(ireal) > EPSFRA) THEN |
---|
618 | jj = INT((index - 1)/nbp_lon) + 1 |
---|
619 | ij = index - (jj - 1) * nbp_lon |
---|
620 | neighbours_glo(igrid, i) = correspond(ij, jj) |
---|
621 | ENDIF |
---|
622 | ENDDO |
---|
623 | ENDDO |
---|
624 | |
---|
625 | ENDIF |
---|
626 | |
---|
627 | DO i = 1, 8 |
---|
628 | CALL scatter_surf(neighbours_glo(:,i),neighbours(1:knon,i)) |
---|
629 | ENDDO |
---|
630 | END SUBROUTINE Init_neighbours |
---|
631 | |
---|
632 | ! |
---|
633 | !**************************************************************************************** |
---|
634 | ! |
---|
635 | #endif |
---|
636 | END MODULE surf_land_orchidee_mod |
---|