1 | ! |
---|
2 | ! $Header$ |
---|
3 | ! |
---|
4 | MODULE surf_land_orchidee_noopenmp_mod |
---|
5 | ! |
---|
6 | ! This module is compiled only if CPP key ORCHIDEE_NOOPENMP is defined. |
---|
7 | ! This module should be used with ORCHIDEE sequentiel or parallele MPI version |
---|
8 | ! (not MPI-OpenMP mixte) until revision 1077 in the ORCHIDEE trunk. |
---|
9 | |
---|
10 | #ifdef ORCHIDEE_NOOPENMP |
---|
11 | ! |
---|
12 | ! This module controles the interface towards the model ORCHIDEE |
---|
13 | ! |
---|
14 | ! Subroutines in this module : surf_land_orchidee |
---|
15 | ! Init_orchidee_index |
---|
16 | ! Get_orchidee_communicator |
---|
17 | ! Init_neighbours |
---|
18 | USE dimphy |
---|
19 | #ifdef CPP_VEGET |
---|
20 | USE intersurf ! module d'ORCHIDEE |
---|
21 | #endif |
---|
22 | USE cpl_mod, ONLY : cpl_send_land_fields |
---|
23 | USE surface_data, ONLY : type_ocean |
---|
24 | USE geometry_mod, ONLY : dx, dy |
---|
25 | USE mod_grid_phy_lmdz |
---|
26 | USE mod_phys_lmdz_para |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | |
---|
30 | PRIVATE |
---|
31 | PUBLIC :: surf_land_orchidee |
---|
32 | |
---|
33 | CONTAINS |
---|
34 | ! |
---|
35 | !**************************************************************************************** |
---|
36 | ! |
---|
37 | SUBROUTINE surf_land_orchidee(itime, dtime, date0, knon, & |
---|
38 | knindex, rlon, rlat, yrmu0, pctsrf, & |
---|
39 | debut, lafin, & |
---|
40 | plev, u1_lay, v1_lay, gustiness, temp_air, spechum, epot_air, ccanopy, & |
---|
41 | tq_cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, & |
---|
42 | precip_rain, precip_snow, lwdown, swnet, swdown, & |
---|
43 | ps, q2m, t2m, & |
---|
44 | evap, fluxsens, fluxlat, & |
---|
45 | tsol_rad, tsurf_new, alb1_new, alb2_new, & |
---|
46 | emis_new, z0_new, z0h_new, qsurf, & |
---|
47 | veget, lai, height) |
---|
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 | ! z0h_new surface roughness, it is the same as z0_new |
---|
99 | ! qsurf air moisture at surface |
---|
100 | ! |
---|
101 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_land_inst, fco2_lu_inst |
---|
102 | USE indice_sol_mod |
---|
103 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat |
---|
104 | USE print_control_mod, ONLY: lunout |
---|
105 | #ifdef CPP_VEGET |
---|
106 | USE time_phylmdz_mod, ONLY: itau_phy |
---|
107 | #endif |
---|
108 | IMPLICIT NONE |
---|
109 | |
---|
110 | INCLUDE "YOMCST.h" |
---|
111 | INCLUDE "dimpft.h" |
---|
112 | ! |
---|
113 | ! Parametres d'entree |
---|
114 | !**************************************************************************************** |
---|
115 | INTEGER, INTENT(IN) :: itime |
---|
116 | REAL, INTENT(IN) :: dtime |
---|
117 | REAL, INTENT(IN) :: date0 |
---|
118 | INTEGER, INTENT(IN) :: knon |
---|
119 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
120 | LOGICAL, INTENT(IN) :: debut, lafin |
---|
121 | REAL, DIMENSION(klon,nbsrf), INTENT(IN) :: pctsrf |
---|
122 | REAL, DIMENSION(klon), INTENT(IN) :: rlon, rlat |
---|
123 | REAL, DIMENSION(klon), INTENT(IN) :: yrmu0 |
---|
124 | REAL, DIMENSION(klon), INTENT(IN) :: plev |
---|
125 | REAL, DIMENSION(klon), INTENT(IN) :: u1_lay, v1_lay, gustiness |
---|
126 | REAL, DIMENSION(klon), INTENT(IN) :: temp_air, spechum |
---|
127 | REAL, DIMENSION(klon), INTENT(IN) :: epot_air, ccanopy |
---|
128 | REAL, DIMENSION(klon), INTENT(IN) :: tq_cdrag |
---|
129 | REAL, DIMENSION(klon), INTENT(IN) :: petAcoef, peqAcoef |
---|
130 | REAL, DIMENSION(klon), INTENT(IN) :: petBcoef, peqBcoef |
---|
131 | REAL, DIMENSION(klon), INTENT(IN) :: precip_rain, precip_snow |
---|
132 | REAL, DIMENSION(klon), INTENT(IN) :: lwdown, swnet, swdown, ps |
---|
133 | REAL, DIMENSION(klon), INTENT(IN) :: q2m, t2m |
---|
134 | |
---|
135 | ! Parametres de sortie |
---|
136 | !**************************************************************************************** |
---|
137 | REAL, DIMENSION(klon), INTENT(OUT) :: evap, fluxsens, fluxlat, qsurf |
---|
138 | REAL, DIMENSION(klon), INTENT(OUT) :: tsol_rad, tsurf_new |
---|
139 | REAL, DIMENSION(klon), INTENT(OUT) :: alb1_new, alb2_new |
---|
140 | REAL, DIMENSION(klon), INTENT(OUT) :: emis_new, z0_new, z0h_new |
---|
141 | REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: veget ! dummy variables |
---|
142 | REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: lai ! dummy variables |
---|
143 | REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: height! dummy variables |
---|
144 | |
---|
145 | ! Local |
---|
146 | !**************************************************************************************** |
---|
147 | INTEGER :: ij, jj, igrid, ireal, index |
---|
148 | INTEGER :: error |
---|
149 | INTEGER, SAVE :: nb_fields_cpl ! number of fields for the climate-carbon coupling (between ATM and ORCHIDEE). |
---|
150 | !$OMP THREADPRIVATE(nb_fields_cpl) |
---|
151 | REAL, SAVE, ALLOCATABLE, DIMENSION(:,:) :: fields_cpl ! Fluxes for the climate-carbon coupling |
---|
152 | !$OMP THREADPRIVATE(fields_cpl) |
---|
153 | REAL, DIMENSION(klon) :: swdown_vrai |
---|
154 | CHARACTER (len = 20) :: modname = 'surf_land_orchidee' |
---|
155 | CHARACTER (len = 80) :: abort_message |
---|
156 | LOGICAL,SAVE :: check = .FALSE. |
---|
157 | !$OMP THREADPRIVATE(check) |
---|
158 | |
---|
159 | ! type de couplage dans sechiba |
---|
160 | ! character (len=10) :: coupling = 'implicit' |
---|
161 | ! drapeaux controlant les appels dans SECHIBA |
---|
162 | ! type(control_type), save :: control_in |
---|
163 | ! Preserved albedo |
---|
164 | REAL, ALLOCATABLE, DIMENSION(:), SAVE :: albedo_keep, zlev |
---|
165 | !$OMP THREADPRIVATE(albedo_keep,zlev) |
---|
166 | ! coordonnees geographiques |
---|
167 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: lalo |
---|
168 | !$OMP THREADPRIVATE(lalo) |
---|
169 | ! pts voisins |
---|
170 | INTEGER,ALLOCATABLE, DIMENSION(:,:), SAVE :: neighbours |
---|
171 | !$OMP THREADPRIVATE(neighbours) |
---|
172 | ! fractions continents |
---|
173 | REAL,ALLOCATABLE, DIMENSION(:), SAVE :: contfrac |
---|
174 | !$OMP THREADPRIVATE(contfrac) |
---|
175 | ! resolution de la grille |
---|
176 | REAL, ALLOCATABLE, DIMENSION (:,:), SAVE :: resolution |
---|
177 | !$OMP THREADPRIVATE(resolution) |
---|
178 | |
---|
179 | REAL, ALLOCATABLE, DIMENSION (:,:), SAVE :: lon_scat, lat_scat |
---|
180 | !$OMP THREADPRIVATE(lon_scat,lat_scat) |
---|
181 | |
---|
182 | LOGICAL, SAVE :: lrestart_read = .TRUE. |
---|
183 | !$OMP THREADPRIVATE(lrestart_read) |
---|
184 | LOGICAL, SAVE :: lrestart_write = .FALSE. |
---|
185 | !$OMP THREADPRIVATE(lrestart_write) |
---|
186 | |
---|
187 | REAL, DIMENSION(knon,2) :: albedo_out |
---|
188 | !$OMP THREADPRIVATE(albedo_out) |
---|
189 | |
---|
190 | ! Pb de nomenclature |
---|
191 | REAL, DIMENSION(klon) :: petA_orc, peqA_orc |
---|
192 | REAL, DIMENSION(klon) :: petB_orc, peqB_orc |
---|
193 | ! Pb de correspondances de grilles |
---|
194 | INTEGER, DIMENSION(:), SAVE, ALLOCATABLE :: ig, jg |
---|
195 | !$OMP THREADPRIVATE(ig,jg) |
---|
196 | INTEGER :: indi, indj |
---|
197 | INTEGER, SAVE, ALLOCATABLE,DIMENSION(:) :: ktindex |
---|
198 | !$OMP THREADPRIVATE(ktindex) |
---|
199 | |
---|
200 | ! Essai cdrag |
---|
201 | REAL, DIMENSION(klon) :: cdrag |
---|
202 | INTEGER,SAVE :: offset |
---|
203 | !$OMP THREADPRIVATE(offset) |
---|
204 | |
---|
205 | REAL, DIMENSION(klon_glo) :: rlon_g,rlat_g |
---|
206 | INTEGER, SAVE :: orch_comm |
---|
207 | !$OMP THREADPRIVATE(orch_comm) |
---|
208 | |
---|
209 | REAL, ALLOCATABLE, DIMENSION(:), SAVE :: coastalflow |
---|
210 | !$OMP THREADPRIVATE(coastalflow) |
---|
211 | REAL, ALLOCATABLE, DIMENSION(:), SAVE :: riverflow |
---|
212 | !$OMP THREADPRIVATE(riverflow) |
---|
213 | ! |
---|
214 | ! Fin definition |
---|
215 | !**************************************************************************************** |
---|
216 | #ifdef CPP_VEGET |
---|
217 | |
---|
218 | IF (check) WRITE(lunout,*)'Entree ', modname |
---|
219 | |
---|
220 | ! Initialisation |
---|
221 | |
---|
222 | IF (debut) THEN |
---|
223 | ! Test de coherence |
---|
224 | #ifndef ORCH_NEW |
---|
225 | ! Compilation avec orchidee nouvelle version necessaire avec carbon_cycle_cpl=y |
---|
226 | IF (carbon_cycle_cpl) THEN |
---|
227 | abort_message='You must define preprossing key ORCH_NEW when running carbon_cycle_cpl=y' |
---|
228 | CALL abort_physic(modname,abort_message,1) |
---|
229 | END IF |
---|
230 | #endif |
---|
231 | ALLOCATE(ktindex(knon)) |
---|
232 | IF ( .NOT. ALLOCATED(albedo_keep)) THEN |
---|
233 | ALLOCATE(albedo_keep(klon)) |
---|
234 | ALLOCATE(zlev(knon)) |
---|
235 | ENDIF |
---|
236 | ! Pb de correspondances de grilles |
---|
237 | ALLOCATE(ig(klon)) |
---|
238 | ALLOCATE(jg(klon)) |
---|
239 | ig(1) = 1 |
---|
240 | jg(1) = 1 |
---|
241 | indi = 0 |
---|
242 | indj = 2 |
---|
243 | DO igrid = 2, klon - 1 |
---|
244 | indi = indi + 1 |
---|
245 | IF ( indi > nbp_lon) THEN |
---|
246 | indi = 1 |
---|
247 | indj = indj + 1 |
---|
248 | ENDIF |
---|
249 | ig(igrid) = indi |
---|
250 | jg(igrid) = indj |
---|
251 | ENDDO |
---|
252 | ig(klon) = 1 |
---|
253 | jg(klon) = nbp_lat |
---|
254 | |
---|
255 | IF ((.NOT. ALLOCATED(lalo))) THEN |
---|
256 | ALLOCATE(lalo(knon,2), stat = error) |
---|
257 | IF (error /= 0) THEN |
---|
258 | abort_message='Pb allocation lalo' |
---|
259 | CALL abort_physic(modname,abort_message,1) |
---|
260 | ENDIF |
---|
261 | ENDIF |
---|
262 | IF ((.NOT. ALLOCATED(lon_scat))) THEN |
---|
263 | ALLOCATE(lon_scat(nbp_lon,nbp_lat), stat = error) |
---|
264 | IF (error /= 0) THEN |
---|
265 | abort_message='Pb allocation lon_scat' |
---|
266 | CALL abort_physic(modname,abort_message,1) |
---|
267 | ENDIF |
---|
268 | ENDIF |
---|
269 | IF ((.NOT. ALLOCATED(lat_scat))) THEN |
---|
270 | ALLOCATE(lat_scat(nbp_lon,nbp_lat), stat = error) |
---|
271 | IF (error /= 0) THEN |
---|
272 | abort_message='Pb allocation lat_scat' |
---|
273 | CALL abort_physic(modname,abort_message,1) |
---|
274 | ENDIF |
---|
275 | ENDIF |
---|
276 | lon_scat = 0. |
---|
277 | lat_scat = 0. |
---|
278 | DO igrid = 1, knon |
---|
279 | index = knindex(igrid) |
---|
280 | lalo(igrid,2) = rlon(index) |
---|
281 | lalo(igrid,1) = rlat(index) |
---|
282 | ENDDO |
---|
283 | |
---|
284 | |
---|
285 | |
---|
286 | CALL Gather(rlon,rlon_g) |
---|
287 | CALL Gather(rlat,rlat_g) |
---|
288 | |
---|
289 | IF (is_mpi_root) THEN |
---|
290 | index = 1 |
---|
291 | DO jj = 2, nbp_lat-1 |
---|
292 | DO ij = 1, nbp_lon |
---|
293 | index = index + 1 |
---|
294 | lon_scat(ij,jj) = rlon_g(index) |
---|
295 | lat_scat(ij,jj) = rlat_g(index) |
---|
296 | ENDDO |
---|
297 | ENDDO |
---|
298 | lon_scat(:,1) = lon_scat(:,2) |
---|
299 | lat_scat(:,1) = rlat_g(1) |
---|
300 | lon_scat(:,nbp_lat) = lon_scat(:,2) |
---|
301 | lat_scat(:,nbp_lat) = rlat_g(klon_glo) |
---|
302 | ENDIF |
---|
303 | |
---|
304 | CALL bcast(lon_scat) |
---|
305 | CALL bcast(lat_scat) |
---|
306 | |
---|
307 | ! |
---|
308 | ! Allouer et initialiser le tableau des voisins et des fraction de continents |
---|
309 | ! |
---|
310 | IF ( (.NOT.ALLOCATED(neighbours))) THEN |
---|
311 | ALLOCATE(neighbours(knon,8), stat = error) |
---|
312 | IF (error /= 0) THEN |
---|
313 | abort_message='Pb allocation neighbours' |
---|
314 | CALL abort_physic(modname,abort_message,1) |
---|
315 | ENDIF |
---|
316 | ENDIF |
---|
317 | neighbours = -1. |
---|
318 | IF (( .NOT. ALLOCATED(contfrac))) THEN |
---|
319 | ALLOCATE(contfrac(knon), stat = error) |
---|
320 | IF (error /= 0) THEN |
---|
321 | abort_message='Pb allocation contfrac' |
---|
322 | CALL abort_physic(modname,abort_message,1) |
---|
323 | ENDIF |
---|
324 | ENDIF |
---|
325 | |
---|
326 | DO igrid = 1, knon |
---|
327 | ireal = knindex(igrid) |
---|
328 | contfrac(igrid) = pctsrf(ireal,is_ter) |
---|
329 | ENDDO |
---|
330 | |
---|
331 | |
---|
332 | CALL Init_neighbours(knon,neighbours,knindex,pctsrf(:,is_ter)) |
---|
333 | |
---|
334 | ! |
---|
335 | ! Allocation et calcul resolutions |
---|
336 | IF ( (.NOT.ALLOCATED(resolution))) THEN |
---|
337 | ALLOCATE(resolution(knon,2), stat = error) |
---|
338 | IF (error /= 0) THEN |
---|
339 | abort_message='Pb allocation resolution' |
---|
340 | CALL abort_physic(modname,abort_message,1) |
---|
341 | ENDIF |
---|
342 | ENDIF |
---|
343 | DO igrid = 1, knon |
---|
344 | ij = knindex(igrid) |
---|
345 | resolution(igrid,1) = dx(ij) |
---|
346 | resolution(igrid,2) = dy(ij) |
---|
347 | ENDDO |
---|
348 | |
---|
349 | ALLOCATE(coastalflow(klon), stat = error) |
---|
350 | IF (error /= 0) THEN |
---|
351 | abort_message='Pb allocation coastalflow' |
---|
352 | CALL abort_physic(modname,abort_message,1) |
---|
353 | ENDIF |
---|
354 | |
---|
355 | ALLOCATE(riverflow(klon), stat = error) |
---|
356 | IF (error /= 0) THEN |
---|
357 | abort_message='Pb allocation riverflow' |
---|
358 | CALL abort_physic(modname,abort_message,1) |
---|
359 | ENDIF |
---|
360 | |
---|
361 | ! |
---|
362 | ! Allocate variables needed for carbon_cycle_mod |
---|
363 | IF ( carbon_cycle_cpl ) THEN |
---|
364 | nb_fields_cpl=2 |
---|
365 | ELSE |
---|
366 | nb_fields_cpl=1 |
---|
367 | END IF |
---|
368 | |
---|
369 | |
---|
370 | IF (carbon_cycle_cpl) THEN |
---|
371 | ALLOCATE(fco2_land_inst(klon),stat=error) |
---|
372 | IF (error /= 0) CALL abort_physic(modname,'Pb in allocation fco2_land_inst',1) |
---|
373 | |
---|
374 | ALLOCATE(fco2_lu_inst(klon),stat=error) |
---|
375 | IF(error /=0) CALL abort_physic(modname,'Pb in allocation fco2_lu_inst',1) |
---|
376 | END IF |
---|
377 | |
---|
378 | ALLOCATE(fields_cpl(klon,nb_fields_cpl), stat = error) |
---|
379 | IF (error /= 0) CALL abort_physic(modname,'Pb in allocation fields_cpl',1) |
---|
380 | |
---|
381 | ENDIF ! (fin debut) |
---|
382 | |
---|
383 | ! |
---|
384 | ! Appel a la routine sols continentaux |
---|
385 | ! |
---|
386 | IF (lafin) lrestart_write = .TRUE. |
---|
387 | IF (check) WRITE(lunout,*)'lafin ',lafin,lrestart_write |
---|
388 | |
---|
389 | petA_orc(1:knon) = petBcoef(1:knon) * dtime |
---|
390 | petB_orc(1:knon) = petAcoef(1:knon) |
---|
391 | peqA_orc(1:knon) = peqBcoef(1:knon) * dtime |
---|
392 | peqB_orc(1:knon) = peqAcoef(1:knon) |
---|
393 | |
---|
394 | cdrag = 0. |
---|
395 | cdrag(1:knon) = tq_cdrag(1:knon) |
---|
396 | |
---|
397 | ! zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/287.05*temp_air(1:knon))*9.80665) |
---|
398 | zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/RD*temp_air(1:knon))*RG) |
---|
399 | |
---|
400 | |
---|
401 | ! PF et PASB |
---|
402 | ! where(cdrag > 0.01) |
---|
403 | ! cdrag = 0.01 |
---|
404 | ! endwhere |
---|
405 | ! write(*,*)'Cdrag = ',minval(cdrag),maxval(cdrag) |
---|
406 | |
---|
407 | ! |
---|
408 | ! Init Orchidee |
---|
409 | ! |
---|
410 | ! if (pole_nord) then |
---|
411 | ! offset=0 |
---|
412 | ! ktindex(:)=ktindex(:)+nbp_lon-1 |
---|
413 | ! else |
---|
414 | ! offset = klon_mpi_begin-1+nbp_lon-1 |
---|
415 | ! ktindex(:)=ktindex(:)+MOD(offset,nbp_lon) |
---|
416 | ! offset=offset-MOD(offset,nbp_lon) |
---|
417 | ! endif |
---|
418 | |
---|
419 | IF (debut) THEN |
---|
420 | CALL Get_orchidee_communicator(knon,orch_comm) |
---|
421 | IF (knon /=0) THEN |
---|
422 | CALL Init_orchidee_index(knon,orch_comm,knindex,offset,ktindex) |
---|
423 | |
---|
424 | IF (.NOT. using_mpi) THEN |
---|
425 | ! Interface for ORCHIDEE compiled in sequential mode(without preprocessing flag CPP_MPI) |
---|
426 | CALL intersurf_main (itime+itau_phy-1, nbp_lon, nbp_lat, knon, ktindex, dtime, & |
---|
427 | lrestart_read, lrestart_write, lalo, & |
---|
428 | contfrac, neighbours, resolution, date0, & |
---|
429 | zlev, u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, & |
---|
430 | cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, & |
---|
431 | precip_rain, precip_snow, lwdown, swnet, swdown, ps, & |
---|
432 | evap, fluxsens, fluxlat, coastalflow, riverflow, & |
---|
433 | tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, & |
---|
434 | lon_scat, lat_scat, q2m, t2m & |
---|
435 | #ifdef ORCH_NEW |
---|
436 | , nb_fields_cpl, fields_cpl) |
---|
437 | #else |
---|
438 | ) |
---|
439 | #endif |
---|
440 | |
---|
441 | ELSE |
---|
442 | ! Interface for ORCHIDEE version 1.9 or later(1.9.2, 1.9.3, 1.9.4, 1.9.5) compiled in parallel mode(with preprocessing flag CPP_MPI) |
---|
443 | CALL intersurf_main (itime+itau_phy-1, nbp_lon, nbp_lat, offset, knon, ktindex, & |
---|
444 | orch_comm, dtime, lrestart_read, lrestart_write, lalo, & |
---|
445 | contfrac, neighbours, resolution, date0, & |
---|
446 | zlev, u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), & |
---|
447 | cdrag(1:knon), petA_orc(1:knon), peqA_orc(1:knon), petB_orc(1:knon), peqB_orc(1:knon), & |
---|
448 | precip_rain(1:knon), precip_snow(1:knon), lwdown(1:knon), swnet(1:knon), swdown(1:knon), ps(1:knon), & |
---|
449 | evap(1:knon), fluxsens(1:knon), fluxlat(1:knon), coastalflow(1:knon), riverflow(1:knon), & |
---|
450 | tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0_new(1:knon), & |
---|
451 | lon_scat, lat_scat, q2m, t2m & |
---|
452 | #ifdef ORCH_NEW |
---|
453 | , nb_fields_cpl, fields_cpl(1:knon,:)) |
---|
454 | #else |
---|
455 | ) |
---|
456 | #endif |
---|
457 | ENDIF |
---|
458 | ENDIF |
---|
459 | |
---|
460 | albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2. |
---|
461 | |
---|
462 | ENDIF |
---|
463 | |
---|
464 | ! swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon)) |
---|
465 | swdown_vrai(1:knon) = swdown(1:knon) |
---|
466 | |
---|
467 | IF (knon /=0) THEN |
---|
468 | IF (.NOT. using_mpi) THEN |
---|
469 | ! Interface for ORCHIDEE compiled in sequential mode(without preprocessing flag CPP_MPI) |
---|
470 | CALL intersurf_main (itime+itau_phy, nbp_lon, nbp_lat, knon, ktindex, dtime, & |
---|
471 | lrestart_read, lrestart_write, lalo, & |
---|
472 | contfrac, neighbours, resolution, date0, & |
---|
473 | zlev, u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, & |
---|
474 | cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, & |
---|
475 | precip_rain, precip_snow, lwdown, swnet, swdown_vrai, ps, & |
---|
476 | evap, fluxsens, fluxlat, coastalflow, riverflow, & |
---|
477 | tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, & |
---|
478 | lon_scat, lat_scat, q2m, t2m & |
---|
479 | #ifdef ORCH_NEW |
---|
480 | , nb_fields_cpl, fields_cpl) |
---|
481 | #else |
---|
482 | ) |
---|
483 | #endif |
---|
484 | ELSE |
---|
485 | ! Interface for ORCHIDEE version 1.9 or later compiled in parallel mode(with preprocessing flag CPP_MPI) |
---|
486 | CALL intersurf_main (itime+itau_phy, nbp_lon, nbp_lat,offset, knon, ktindex, & |
---|
487 | orch_comm,dtime, lrestart_read, lrestart_write, lalo, & |
---|
488 | contfrac, neighbours, resolution, date0, & |
---|
489 | zlev, u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), & |
---|
490 | cdrag(1:knon), petA_orc(1:knon), peqA_orc(1:knon), petB_orc(1:knon), peqB_orc(1:knon), & |
---|
491 | precip_rain(1:knon), precip_snow(1:knon), lwdown(1:knon), swnet(1:knon), swdown_vrai(1:knon), ps(1:knon), & |
---|
492 | evap(1:knon), fluxsens(1:knon), fluxlat(1:knon), coastalflow(1:knon), riverflow(1:knon), & |
---|
493 | tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0_new(1:knon), & |
---|
494 | lon_scat, lat_scat, q2m, t2m & |
---|
495 | #ifdef ORCH_NEW |
---|
496 | , nb_fields_cpl, fields_cpl(1:knon,:)) |
---|
497 | #else |
---|
498 | ) |
---|
499 | #endif |
---|
500 | ENDIF |
---|
501 | ENDIF |
---|
502 | |
---|
503 | albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2. |
---|
504 | |
---|
505 | ! ORCHIDEE only gives one value for z0_new. Copy it into z0h_new. |
---|
506 | z0h_new(:)=z0_new(:) |
---|
507 | |
---|
508 | !* Send to coupler |
---|
509 | ! |
---|
510 | IF (type_ocean=='couple') THEN |
---|
511 | CALL cpl_send_land_fields(itime, knon, knindex, & |
---|
512 | riverflow, coastalflow) |
---|
513 | ENDIF |
---|
514 | |
---|
515 | alb1_new(1:knon) = albedo_out(1:knon,1) |
---|
516 | alb2_new(1:knon) = albedo_out(1:knon,2) |
---|
517 | |
---|
518 | ! Convention orchidee: positif vers le haut |
---|
519 | fluxsens(1:knon) = -1. * fluxsens(1:knon) |
---|
520 | fluxlat(1:knon) = -1. * fluxlat(1:knon) |
---|
521 | |
---|
522 | ! evap = -1. * evap |
---|
523 | |
---|
524 | IF (debut) lrestart_read = .FALSE. |
---|
525 | |
---|
526 | ! Decompress variables for the module carbon_cycle_mod |
---|
527 | IF (carbon_cycle_cpl) THEN |
---|
528 | fco2_land_inst(:)=0. |
---|
529 | fco2_lu_inst(:)=0. |
---|
530 | |
---|
531 | DO igrid = 1, knon |
---|
532 | ireal = knindex(igrid) |
---|
533 | fco2_land_inst(ireal) = fields_cpl(igrid,1) |
---|
534 | fco2_lu_inst(ireal) = fields_cpl(igrid,2) |
---|
535 | END DO |
---|
536 | END IF |
---|
537 | |
---|
538 | #endif |
---|
539 | END SUBROUTINE surf_land_orchidee |
---|
540 | ! |
---|
541 | !**************************************************************************************** |
---|
542 | ! |
---|
543 | SUBROUTINE Init_orchidee_index(knon,orch_comm,knindex,offset,ktindex) |
---|
544 | |
---|
545 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat |
---|
546 | USE lmdz_mpi |
---|
547 | |
---|
548 | ! Input arguments |
---|
549 | !**************************************************************************************** |
---|
550 | INTEGER, INTENT(IN) :: knon |
---|
551 | INTEGER, INTENT(IN) :: orch_comm |
---|
552 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
553 | |
---|
554 | ! Output arguments |
---|
555 | !**************************************************************************************** |
---|
556 | INTEGER, INTENT(OUT) :: offset |
---|
557 | INTEGER, DIMENSION(knon), INTENT(OUT) :: ktindex |
---|
558 | |
---|
559 | ! Local varables |
---|
560 | !**************************************************************************************** |
---|
561 | INTEGER, DIMENSION(MPI_STATUS_SIZE) :: status |
---|
562 | |
---|
563 | INTEGER :: MyLastPoint |
---|
564 | INTEGER :: LastPoint |
---|
565 | INTEGER :: mpi_rank_orch |
---|
566 | INTEGER :: mpi_size_orch |
---|
567 | INTEGER :: ierr |
---|
568 | ! |
---|
569 | ! End definition |
---|
570 | !**************************************************************************************** |
---|
571 | |
---|
572 | MyLastPoint=klon_mpi_begin-1+knindex(knon)+nbp_lon-1 |
---|
573 | |
---|
574 | IF (is_parallel) THEN |
---|
575 | CALL MPI_COMM_SIZE(orch_comm,mpi_size_orch,ierr) |
---|
576 | CALL MPI_COMM_RANK(orch_comm,mpi_rank_orch,ierr) |
---|
577 | ELSE |
---|
578 | mpi_rank_orch=0 |
---|
579 | mpi_size_orch=1 |
---|
580 | ENDIF |
---|
581 | |
---|
582 | IF (is_parallel) THEN |
---|
583 | IF (mpi_rank_orch /= 0) THEN |
---|
584 | CALL MPI_RECV(LastPoint,1,MPI_INTEGER,mpi_rank_orch-1,1234,orch_comm,status,ierr) |
---|
585 | ENDIF |
---|
586 | |
---|
587 | IF (mpi_rank_orch /= mpi_size_orch-1) THEN |
---|
588 | CALL MPI_SEND(MyLastPoint,1,MPI_INTEGER,mpi_rank_orch+1,1234,orch_comm,ierr) |
---|
589 | ENDIF |
---|
590 | ENDIF |
---|
591 | |
---|
592 | IF (mpi_rank_orch == 0) THEN |
---|
593 | offset=0 |
---|
594 | ELSE |
---|
595 | offset=LastPoint-MOD(LastPoint,nbp_lon) |
---|
596 | ENDIF |
---|
597 | |
---|
598 | ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin+nbp_lon-1)-offset-1 |
---|
599 | |
---|
600 | |
---|
601 | END SUBROUTINE Init_orchidee_index |
---|
602 | ! |
---|
603 | !**************************************************************************************** |
---|
604 | ! |
---|
605 | SUBROUTINE Get_orchidee_communicator(knon,orch_comm) |
---|
606 | USE lmdz_mpi |
---|
607 | |
---|
608 | INTEGER,INTENT(IN) :: knon |
---|
609 | INTEGER,INTENT(OUT) :: orch_comm |
---|
610 | |
---|
611 | INTEGER :: color |
---|
612 | INTEGER :: ierr |
---|
613 | ! |
---|
614 | ! End definition |
---|
615 | !**************************************************************************************** |
---|
616 | |
---|
617 | IF (knon==0) THEN |
---|
618 | color = 0 |
---|
619 | ELSE |
---|
620 | color = 1 |
---|
621 | ENDIF |
---|
622 | |
---|
623 | CALL MPI_COMM_SPLIT(COMM_LMDZ_PHY,color,mpi_rank,orch_comm,ierr) |
---|
624 | |
---|
625 | END SUBROUTINE Get_orchidee_communicator |
---|
626 | ! |
---|
627 | !**************************************************************************************** |
---|
628 | ! |
---|
629 | SUBROUTINE Init_neighbours(knon,neighbours,ktindex,pctsrf) |
---|
630 | |
---|
631 | USE indice_sol_mod |
---|
632 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat |
---|
633 | USE lmdz_mpi |
---|
634 | |
---|
635 | ! Input arguments |
---|
636 | !**************************************************************************************** |
---|
637 | INTEGER, INTENT(IN) :: knon |
---|
638 | INTEGER, DIMENSION(klon), INTENT(IN) :: ktindex |
---|
639 | REAL, DIMENSION(klon), INTENT(IN) :: pctsrf |
---|
640 | |
---|
641 | ! Output arguments |
---|
642 | !**************************************************************************************** |
---|
643 | INTEGER, DIMENSION(knon,8), INTENT(OUT) :: neighbours |
---|
644 | |
---|
645 | ! Local variables |
---|
646 | !**************************************************************************************** |
---|
647 | INTEGER :: knon_g |
---|
648 | INTEGER :: i, igrid, jj, ij, iglob |
---|
649 | INTEGER :: ierr, ireal, index |
---|
650 | INTEGER :: var_tmp |
---|
651 | INTEGER, DIMENSION(0:mpi_size-1) :: knon_nb |
---|
652 | INTEGER, DIMENSION(0:mpi_size-1) :: displs |
---|
653 | INTEGER, DIMENSION(8,3) :: off_ini |
---|
654 | INTEGER, DIMENSION(8) :: offset |
---|
655 | INTEGER, DIMENSION(knon) :: ktindex_p |
---|
656 | INTEGER, DIMENSION(nbp_lon,nbp_lat) :: correspond |
---|
657 | INTEGER, ALLOCATABLE, DIMENSION(:) :: ktindex_g |
---|
658 | INTEGER, ALLOCATABLE, DIMENSION(:,:) :: neighbours_g |
---|
659 | REAL, DIMENSION(klon_glo) :: pctsrf_g |
---|
660 | |
---|
661 | ! |
---|
662 | ! End definition |
---|
663 | !**************************************************************************************** |
---|
664 | |
---|
665 | IF (is_sequential) THEN |
---|
666 | knon_nb(:)=knon |
---|
667 | ELSE |
---|
668 | CALL MPI_GATHER(knon,1,MPI_INTEGER,knon_nb,1,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr) |
---|
669 | ENDIF |
---|
670 | |
---|
671 | IF (is_mpi_root) THEN |
---|
672 | knon_g=SUM(knon_nb(:)) |
---|
673 | ALLOCATE(ktindex_g(knon_g)) |
---|
674 | ALLOCATE(neighbours_g(knon_g,8)) |
---|
675 | neighbours_g(:,:)=-1 |
---|
676 | displs(0)=0 |
---|
677 | DO i=1,mpi_size-1 |
---|
678 | displs(i)=displs(i-1)+knon_nb(i-1) |
---|
679 | ENDDO |
---|
680 | ELSE |
---|
681 | ALLOCATE(ktindex_g(1)) |
---|
682 | ALLOCATE(neighbours_g(1,8)) |
---|
683 | ENDIF |
---|
684 | |
---|
685 | ktindex_p(1:knon)=ktindex(1:knon)+klon_mpi_begin-1+nbp_lon-1 |
---|
686 | |
---|
687 | IF (is_sequential) THEN |
---|
688 | ktindex_g(:)=ktindex_p(:) |
---|
689 | ELSE |
---|
690 | CALL MPI_GATHERV(ktindex_p,knon,MPI_INTEGER,ktindex_g,knon_nb,& |
---|
691 | displs,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr) |
---|
692 | ENDIF |
---|
693 | |
---|
694 | CALL Gather(pctsrf,pctsrf_g) |
---|
695 | |
---|
696 | IF (is_mpi_root) THEN |
---|
697 | ! Initialisation des offset |
---|
698 | ! |
---|
699 | ! offset bord ouest |
---|
700 | off_ini(1,1) = - nbp_lon ; off_ini(2,1) = - nbp_lon + 1; off_ini(3,1) = 1 |
---|
701 | off_ini(4,1) = nbp_lon + 1; off_ini(5,1) = nbp_lon ; off_ini(6,1) = 2 * nbp_lon - 1 |
---|
702 | off_ini(7,1) = nbp_lon -1 ; off_ini(8,1) = - 1 |
---|
703 | ! offset point normal |
---|
704 | off_ini(1,2) = - nbp_lon ; off_ini(2,2) = - nbp_lon + 1; off_ini(3,2) = 1 |
---|
705 | off_ini(4,2) = nbp_lon + 1; off_ini(5,2) = nbp_lon ; off_ini(6,2) = nbp_lon - 1 |
---|
706 | off_ini(7,2) = -1 ; off_ini(8,2) = - nbp_lon - 1 |
---|
707 | ! offset bord est |
---|
708 | off_ini(1,3) = - nbp_lon; off_ini(2,3) = - 2 * nbp_lon + 1; off_ini(3,3) = - nbp_lon + 1 |
---|
709 | off_ini(4,3) = 1 ; off_ini(5,3) = nbp_lon ; off_ini(6,3) = nbp_lon - 1 |
---|
710 | off_ini(7,3) = -1 ; off_ini(8,3) = - nbp_lon - 1 |
---|
711 | ! |
---|
712 | ! |
---|
713 | ! Attention aux poles |
---|
714 | ! |
---|
715 | DO igrid = 1, knon_g |
---|
716 | index = ktindex_g(igrid) |
---|
717 | jj = INT((index - 1)/nbp_lon) + 1 |
---|
718 | ij = index - (jj - 1) * nbp_lon |
---|
719 | correspond(ij,jj) = igrid |
---|
720 | ENDDO |
---|
721 | |
---|
722 | DO igrid = 1, knon_g |
---|
723 | iglob = ktindex_g(igrid) |
---|
724 | IF (MOD(iglob, nbp_lon) == 1) THEN |
---|
725 | offset = off_ini(:,1) |
---|
726 | ELSE IF(MOD(iglob, nbp_lon) == 0) THEN |
---|
727 | offset = off_ini(:,3) |
---|
728 | ELSE |
---|
729 | offset = off_ini(:,2) |
---|
730 | ENDIF |
---|
731 | DO i = 1, 8 |
---|
732 | index = iglob + offset(i) |
---|
733 | ireal = (MIN(MAX(1, index - nbp_lon + 1), klon_glo)) |
---|
734 | IF (pctsrf_g(ireal) > EPSFRA) THEN |
---|
735 | jj = INT((index - 1)/nbp_lon) + 1 |
---|
736 | ij = index - (jj - 1) * nbp_lon |
---|
737 | neighbours_g(igrid, i) = correspond(ij, jj) |
---|
738 | ENDIF |
---|
739 | ENDDO |
---|
740 | ENDDO |
---|
741 | |
---|
742 | ENDIF |
---|
743 | |
---|
744 | DO i=1,8 |
---|
745 | IF (is_sequential) THEN |
---|
746 | neighbours(:,i)=neighbours_g(:,i) |
---|
747 | ELSE |
---|
748 | IF (knon > 0) THEN |
---|
749 | ! knon>0, scattter global field neighbours_g from master process to local process |
---|
750 | CALL MPI_SCATTERV(neighbours_g(:,i),knon_nb,displs,MPI_INTEGER,neighbours(:,i),knon,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr) |
---|
751 | ELSE |
---|
752 | ! knon=0, no need to save the field for this process |
---|
753 | CALL MPI_SCATTERV(neighbours_g(:,i),knon_nb,displs,MPI_INTEGER,var_tmp,knon,MPI_INTEGER,0,COMM_LMDZ_PHY,ierr) |
---|
754 | END IF |
---|
755 | ENDIF |
---|
756 | ENDDO |
---|
757 | |
---|
758 | END SUBROUTINE Init_neighbours |
---|
759 | ! |
---|
760 | !**************************************************************************************** |
---|
761 | ! |
---|
762 | |
---|
763 | #endif |
---|
764 | END MODULE surf_land_orchidee_noopenmp_mod |
---|