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