source: trunk/LMDZ.COMMON/libf/phy_common/mod_phys_lmdz_mpi_transfert.F90 @ 3554

Last change on this file since 3554 was 3011, checked in by emillour, 17 months ago

Common physics auxiliary routines:
Add possibility to broadcast 5D and 6D fields.
EM

File size: 48.5 KB
Line 
1!
2!$Id$
3!
4MODULE mod_phys_lmdz_mpi_transfert
5
6
7  INTERFACE bcast_mpi
8    MODULE PROCEDURE bcast_mpi_c,                                                     &
9                     bcast_mpi_i,bcast_mpi_i1,bcast_mpi_i2,bcast_mpi_i3,bcast_mpi_i4,bcast_mpi_i5,bcast_mpi_i6, &
10                     bcast_mpi_r,bcast_mpi_r1,bcast_mpi_r2,bcast_mpi_r3,bcast_mpi_r4,bcast_mpi_r5,bcast_mpi_r6, &
11                     bcast_mpi_l,bcast_mpi_l1,bcast_mpi_l2,bcast_mpi_l3,bcast_mpi_l4,bcast_mpi_l5,bcast_mpi_l6
12  END INTERFACE
13
14  INTERFACE scatter_mpi
15    MODULE PROCEDURE scatter_mpi_i,scatter_mpi_i1,scatter_mpi_i2,scatter_mpi_i3, &
16                     scatter_mpi_r,scatter_mpi_r1,scatter_mpi_r2,scatter_mpi_r3, &
17                     scatter_mpi_l,scatter_mpi_l1,scatter_mpi_l2,scatter_mpi_l3
18  END INTERFACE
19
20 
21  INTERFACE gather_mpi
22    MODULE PROCEDURE gather_mpi_i,gather_mpi_i1,gather_mpi_i2,gather_mpi_i3, &
23                     gather_mpi_r,gather_mpi_r1,gather_mpi_r2,gather_mpi_r3, &
24                     gather_mpi_l,gather_mpi_l1,gather_mpi_l2,gather_mpi_l3 
25  END INTERFACE
26 
27  INTERFACE scatter2D_mpi
28    MODULE PROCEDURE scatter2D_mpi_i,scatter2D_mpi_i1,scatter2D_mpi_i2,scatter2D_mpi_i3, &
29                     scatter2D_mpi_r,scatter2D_mpi_r1,scatter2D_mpi_r2,scatter2D_mpi_r3, &
30                     scatter2D_mpi_l,scatter2D_mpi_l1,scatter2D_mpi_l2,scatter2D_mpi_l3
31  END INTERFACE
32
33  INTERFACE gather2D_mpi
34    MODULE PROCEDURE gather2D_mpi_i,gather2D_mpi_i1,gather2D_mpi_i2,gather2D_mpi_i3, &
35                     gather2D_mpi_r,gather2D_mpi_r1,gather2D_mpi_r2,gather2D_mpi_r3, &
36                     gather2D_mpi_l,gather2D_mpi_l1,gather2D_mpi_l2,gather2D_mpi_l3
37  END INTERFACE
38 
39  INTERFACE reduce_sum_mpi
40    MODULE PROCEDURE reduce_sum_mpi_i,reduce_sum_mpi_i1,reduce_sum_mpi_i2,reduce_sum_mpi_i3,reduce_sum_mpi_i4, &
41                     reduce_sum_mpi_r,reduce_sum_mpi_r1,reduce_sum_mpi_r2,reduce_sum_mpi_r3,reduce_sum_mpi_r4
42  END INTERFACE
43
44 INTERFACE grid1dTo2d_mpi
45    MODULE PROCEDURE grid1dTo2d_mpi_i,grid1dTo2d_mpi_i1,grid1dTo2d_mpi_i2,grid1dTo2d_mpi_i3, &
46                     grid1dTo2d_mpi_r,grid1dTo2d_mpi_r1,grid1dTo2d_mpi_r2,grid1dTo2d_mpi_r3, &
47                     grid1dTo2d_mpi_l,grid1dTo2d_mpi_l1,grid1dTo2d_mpi_l2,grid1dTo2d_mpi_l3
48 END INTERFACE
49
50 INTERFACE grid2dTo1d_mpi
51    MODULE PROCEDURE grid2dTo1d_mpi_i,grid2dTo1d_mpi_i1,grid2dTo1d_mpi_i2,grid2dTo1d_mpi_i3, &
52                     grid2dTo1d_mpi_r,grid2dTo1d_mpi_r1,grid2dTo1d_mpi_r2,grid2dTo1d_mpi_r3, &
53                     grid2dTo1d_mpi_l,grid2dTo1d_mpi_l1,grid2dTo1d_mpi_l2,grid2dTo1d_mpi_l3
54 END INTERFACE
55   
56CONTAINS
57
58!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
59!! Definition des Broadcast --> 4D   !!
60!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
61
62!! -- Les chaine de charactère -- !!
63
64  SUBROUTINE bcast_mpi_c(var1)
65  IMPLICIT NONE
66    CHARACTER(LEN=*),INTENT(INOUT) :: Var1
67   
68    CALL bcast_mpi_cgen(Var1,len(Var1))
69
70  END SUBROUTINE bcast_mpi_c
71
72!! -- Les entiers -- !!
73 
74  SUBROUTINE bcast_mpi_i(var)
75  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
76  IMPLICIT NONE
77    INTEGER,INTENT(INOUT) :: Var
78   
79    INTEGER               :: var_tmp(1)
80   
81    IF (is_mpi_root) var_tmp(1)=var
82    CALL bcast_mpi_igen(Var_tmp,1)
83    var=var_tmp(1)
84   
85  END SUBROUTINE bcast_mpi_i
86
87  SUBROUTINE bcast_mpi_i1(var)
88  IMPLICIT NONE
89    INTEGER,INTENT(INOUT) :: Var(:)
90
91    CALL bcast_mpi_igen(Var,size(Var))
92   
93  END SUBROUTINE bcast_mpi_i1
94
95  SUBROUTINE bcast_mpi_i2(var)
96  IMPLICIT NONE
97    INTEGER,INTENT(INOUT) :: Var(:,:)
98   
99    CALL bcast_mpi_igen(Var,size(Var))
100 
101  END SUBROUTINE bcast_mpi_i2
102
103  SUBROUTINE bcast_mpi_i3(var)
104  IMPLICIT NONE
105    INTEGER,INTENT(INOUT) :: Var(:,:,:)
106   
107    CALL bcast_mpi_igen(Var,size(Var))
108
109  END SUBROUTINE bcast_mpi_i3
110
111  SUBROUTINE bcast_mpi_i4(var)
112  IMPLICIT NONE
113    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
114   
115    CALL bcast_mpi_igen(Var,size(Var))
116
117  END SUBROUTINE bcast_mpi_i4
118
119  SUBROUTINE bcast_mpi_i5(var)
120  IMPLICIT NONE
121    INTEGER,INTENT(INOUT) :: Var(:,:,:,:,:)
122   
123    CALL bcast_mpi_igen(Var,size(Var))
124
125  END SUBROUTINE bcast_mpi_i5
126
127  SUBROUTINE bcast_mpi_i6(var)
128  IMPLICIT NONE
129    INTEGER,INTENT(INOUT) :: Var(:,:,:,:,:,:)
130   
131    CALL bcast_mpi_igen(Var,size(Var))
132
133  END SUBROUTINE bcast_mpi_i6
134
135
136!! -- Les reels -- !!
137
138  SUBROUTINE bcast_mpi_r(var)
139  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
140  IMPLICIT NONE
141    REAL,INTENT(INOUT) :: Var
142    REAL               :: var_tmp(1)
143   
144    IF (is_mpi_root) var_tmp(1)=var
145    CALL bcast_mpi_rgen(Var_tmp,1)
146    var=var_tmp(1)   
147
148  END SUBROUTINE bcast_mpi_r
149
150  SUBROUTINE bcast_mpi_r1(var)
151  IMPLICIT NONE
152    REAL,INTENT(INOUT) :: Var(:)
153   
154    CALL bcast_mpi_rgen(Var,size(Var))
155
156  END SUBROUTINE bcast_mpi_r1
157
158  SUBROUTINE bcast_mpi_r2(var)
159  IMPLICIT NONE
160    REAL,INTENT(INOUT) :: Var(:,:)
161   
162    CALL bcast_mpi_rgen(Var,size(Var))
163
164  END SUBROUTINE bcast_mpi_r2
165
166  SUBROUTINE bcast_mpi_r3(var)
167  IMPLICIT NONE
168    REAL,INTENT(INOUT) :: Var(:,:,:)
169   
170    CALL bcast_mpi_rgen(Var,size(Var))
171
172  END SUBROUTINE bcast_mpi_r3
173
174  SUBROUTINE bcast_mpi_r4(var)
175  IMPLICIT NONE
176    REAL,INTENT(INOUT) :: Var(:,:,:,:)
177   
178    CALL bcast_mpi_rgen(Var,size(Var))
179
180  END SUBROUTINE bcast_mpi_r4
181 
182  SUBROUTINE bcast_mpi_r5(var)
183  IMPLICIT NONE
184    REAL,INTENT(INOUT) :: Var(:,:,:,:,:)
185   
186    CALL bcast_mpi_rgen(Var,size(Var))
187
188  END SUBROUTINE bcast_mpi_r5
189 
190  SUBROUTINE bcast_mpi_r6(var)
191  IMPLICIT NONE
192    REAL,INTENT(INOUT) :: Var(:,:,:,:,:,:)
193   
194    CALL bcast_mpi_rgen(Var,size(Var))
195
196  END SUBROUTINE bcast_mpi_r6
197 
198
199!! -- Les booleans -- !!
200
201  SUBROUTINE bcast_mpi_l(var)
202  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
203  IMPLICIT NONE
204    LOGICAL,INTENT(INOUT) :: Var
205    LOGICAL               :: var_tmp(1)
206   
207    IF (is_mpi_root) var_tmp(1)=var
208    CALL bcast_mpi_lgen(Var_tmp,1)
209    var=var_tmp(1)   
210
211  END SUBROUTINE bcast_mpi_l
212
213  SUBROUTINE bcast_mpi_l1(var)
214  IMPLICIT NONE
215    LOGICAL,INTENT(INOUT) :: Var(:)
216   
217    CALL bcast_mpi_lgen(Var,size(Var))
218
219  END SUBROUTINE bcast_mpi_l1
220
221  SUBROUTINE bcast_mpi_l2(var)
222  IMPLICIT NONE
223    LOGICAL,INTENT(INOUT) :: Var(:,:)
224   
225    CALL bcast_mpi_lgen(Var,size(Var))
226
227  END SUBROUTINE bcast_mpi_l2
228
229  SUBROUTINE bcast_mpi_l3(var)
230  IMPLICIT NONE
231    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
232   
233    CALL bcast_mpi_lgen(Var,size(Var))
234
235  END SUBROUTINE bcast_mpi_l3
236
237  SUBROUTINE bcast_mpi_l4(var)
238  IMPLICIT NONE
239    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
240   
241    CALL bcast_mpi_lgen(Var,size(Var))
242
243  END SUBROUTINE bcast_mpi_l4
244 
245  SUBROUTINE bcast_mpi_l5(var)
246  IMPLICIT NONE
247    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:,:)
248   
249    CALL bcast_mpi_lgen(Var,size(Var))
250
251  END SUBROUTINE bcast_mpi_l5
252
253  SUBROUTINE bcast_mpi_l6(var)
254  IMPLICIT NONE
255    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:,:,:)
256   
257    CALL bcast_mpi_lgen(Var,size(Var))
258
259  END SUBROUTINE bcast_mpi_l6
260 
261
262!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
263!! Definition des Scatter   --> 4D   !!
264!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
265
266  SUBROUTINE scatter_mpi_i(VarIn, VarOut)
267    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
268    IMPLICIT NONE
269 
270    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
271    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
272
273    CALL scatter_mpi_igen(VarIn,Varout,1)
274   
275  END SUBROUTINE scatter_mpi_i
276
277  SUBROUTINE scatter_mpi_i1(VarIn, VarOut)
278    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
279    IMPLICIT NONE
280 
281    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
282    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
283   
284    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2))
285   
286  END SUBROUTINE scatter_mpi_i1
287 
288  SUBROUTINE scatter_mpi_i2(VarIn, VarOut)
289    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
290    IMPLICIT NONE
291 
292    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
293    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
294   
295    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
296
297  END SUBROUTINE scatter_mpi_i2
298
299  SUBROUTINE scatter_mpi_i3(VarIn, VarOut)
300    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
301    IMPLICIT NONE
302 
303    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
304    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
305   
306    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
307 
308  END SUBROUTINE scatter_mpi_i3
309
310
311  SUBROUTINE scatter_mpi_r(VarIn, VarOut)
312    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
313    IMPLICIT NONE
314 
315    REAL,INTENT(IN),DIMENSION(:) :: VarIn
316    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
317   
318      CALL scatter_mpi_rgen(VarIn,Varout,1)
319 
320  END SUBROUTINE scatter_mpi_r
321
322  SUBROUTINE scatter_mpi_r1(VarIn, VarOut)
323  USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
324  IMPLICIT NONE
325 
326    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
327    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
328   
329      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2))
330 
331  END SUBROUTINE scatter_mpi_r1
332 
333  SUBROUTINE scatter_mpi_r2(VarIn, VarOut)
334    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
335    IMPLICIT NONE
336 
337    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
338    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
339   
340      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
341 
342  END SUBROUTINE scatter_mpi_r2
343
344  SUBROUTINE scatter_mpi_r3(VarIn, VarOut)
345    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
346    IMPLICIT NONE
347 
348    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
349    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
350   
351      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
352 
353  END SUBROUTINE scatter_mpi_r3
354
355
356  SUBROUTINE scatter_mpi_l(VarIn, VarOut)
357    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
358    IMPLICIT NONE
359 
360    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
361    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
362   
363      CALL scatter_mpi_lgen(VarIn,Varout,1)
364   
365  END SUBROUTINE scatter_mpi_l
366
367  SUBROUTINE scatter_mpi_l1(VarIn, VarOut)
368    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
369    IMPLICIT NONE
370 
371    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
372    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
373   
374      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2))
375 
376  END SUBROUTINE scatter_mpi_l1
377 
378  SUBROUTINE scatter_mpi_l2(VarIn, VarOut)
379    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
380    IMPLICIT NONE
381 
382    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
383    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
384   
385      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
386 
387  END SUBROUTINE scatter_mpi_l2
388
389  SUBROUTINE scatter_mpi_l3(VarIn, VarOut)
390    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
391    IMPLICIT NONE
392 
393    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
394    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
395   
396      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
397 
398  END SUBROUTINE scatter_mpi_l3 
399
400!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
401!! Definition des Gather   --> 4D   !!
402!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
403 
404!!!!! --> Les entiers
405
406  SUBROUTINE gather_mpi_i(VarIn, VarOut)
407    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
408    IMPLICIT NONE
409 
410    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
411    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
412   
413      CALL gather_mpi_igen(VarIn,VarOut,1)
414 
415  END SUBROUTINE gather_mpi_i
416 
417
418!!!!!
419
420  SUBROUTINE gather_mpi_i1(VarIn, VarOut)
421    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
422    IMPLICIT NONE
423 
424    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
425    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
426   
427      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2))
428 
429  END SUBROUTINE gather_mpi_i1
430
431!!!!!
432 
433  SUBROUTINE gather_mpi_i2(VarIn, VarOut)
434    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
435    IMPLICIT NONE
436 
437    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
438    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
439   
440      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
441 
442  END SUBROUTINE gather_mpi_i2
443
444!!!!!
445
446  SUBROUTINE gather_mpi_i3(VarIn, VarOut)
447    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
448    IMPLICIT NONE
449 
450    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
451    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
452   
453      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
454 
455  END SUBROUTINE gather_mpi_i3
456
457!!!!! --> Les reels
458
459  SUBROUTINE gather_mpi_r(VarIn, VarOut)
460    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
461    IMPLICIT NONE
462 
463    REAL,INTENT(IN),DIMENSION(:) :: VarIn
464    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
465   
466      CALL gather_mpi_rgen(VarIn,VarOut,1)
467 
468  END SUBROUTINE gather_mpi_r
469
470!!!!!
471
472  SUBROUTINE gather_mpi_r1(VarIn, VarOut)
473    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
474    IMPLICIT NONE
475 
476    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
477    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
478   
479      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2))
480 
481  END SUBROUTINE gather_mpi_r1
482
483!!!!!
484 
485  SUBROUTINE gather_mpi_r2(VarIn, VarOut)
486    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
487    IMPLICIT NONE
488 
489    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
490    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
491   
492      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
493 
494  END SUBROUTINE gather_mpi_r2
495
496!!!!!
497
498  SUBROUTINE gather_mpi_r3(VarIn, VarOut)
499    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
500    IMPLICIT NONE
501 
502    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
503    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
504   
505      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
506 
507  END SUBROUTINE gather_mpi_r3
508
509!!!!! --> Les booleen
510
511  SUBROUTINE gather_mpi_l(VarIn, VarOut)
512    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
513    IMPLICIT NONE
514 
515    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
516    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
517   
518      CALL gather_mpi_lgen(VarIn,VarOut,1)
519 
520  END SUBROUTINE gather_mpi_l
521
522!!!!!
523
524  SUBROUTINE gather_mpi_l1(VarIn, VarOut)
525    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
526    IMPLICIT NONE
527 
528    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
529    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
530   
531      CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2))
532 
533  END SUBROUTINE gather_mpi_l1
534
535!!!!!
536 
537  SUBROUTINE gather_mpi_l2(VarIn, VarOut)
538    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
539    IMPLICIT NONE
540 
541    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
542    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
543   
544      CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
545 
546  END SUBROUTINE gather_mpi_l2
547
548!!!!!
549
550  SUBROUTINE gather_mpi_l3(VarIn, VarOut)
551    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
552    IMPLICIT NONE
553 
554    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
555    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
556   
557    CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
558 
559  END SUBROUTINE gather_mpi_l3
560
561!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
562!! Definition des Scatter2D   --> 4D   !!
563!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
564
565  SUBROUTINE scatter2D_mpi_i(VarIn, VarOut)
566    USE mod_grid_phy_lmdz
567    IMPLICIT NONE
568 
569    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
570    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
571
572    INTEGER,DIMENSION(klon_glo) :: Var_tmp   
573   
574    CALL grid2dTo1d_glo(VarIn,Var_tmp)
575    CALL scatter_mpi(Var_tmp,VarOut)
576
577  END SUBROUTINE scatter2D_mpi_i
578
579  SUBROUTINE scatter2D_mpi_i1(VarIn, VarOut)
580    USE mod_grid_phy_lmdz
581    IMPLICIT NONE
582 
583    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
584    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
585    INTEGER,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
586
587    CALL grid2dTo1d_glo(VarIn,Var_tmp)
588    CALL scatter_mpi(Var_tmp,VarOut)
589
590  END SUBROUTINE scatter2D_mpi_i1
591
592  SUBROUTINE scatter2D_mpi_i2(VarIn, VarOut)
593    USE mod_grid_phy_lmdz
594    IMPLICIT NONE
595 
596    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
597    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
598
599    INTEGER,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
600
601    CALL grid2dTo1d_glo(VarIn,Var_tmp)
602    CALL scatter_mpi(Var_tmp,VarOut)
603
604  END SUBROUTINE scatter2D_mpi_i2
605 
606  SUBROUTINE scatter2D_mpi_i3(VarIn, VarOut)
607    USE mod_grid_phy_lmdz
608    IMPLICIT NONE
609 
610    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
611    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
612    INTEGER,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
613
614    CALL grid2dTo1d_glo(VarIn,Var_tmp)
615    CALL scatter_mpi(Var_tmp,VarOut)
616   
617  END SUBROUTINE scatter2D_mpi_i3
618
619
620
621  SUBROUTINE scatter2D_mpi_r(VarIn, VarOut)
622    USE mod_grid_phy_lmdz
623    IMPLICIT NONE
624 
625    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
626    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
627
628    REAL,DIMENSION(klon_glo) :: Var_tmp   
629   
630    CALL grid2dTo1d_glo(VarIn,Var_tmp)
631    CALL scatter_mpi(Var_tmp,VarOut)
632
633  END SUBROUTINE scatter2D_mpi_R
634
635
636  SUBROUTINE scatter2D_mpi_r1(VarIn, VarOut)
637    USE mod_grid_phy_lmdz
638    IMPLICIT NONE
639    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
640    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
641   
642    REAL,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
643   
644    CALL grid2dTo1d_glo(VarIn,Var_tmp)
645    CALL scatter_mpi(Var_tmp,VarOut)
646
647  END SUBROUTINE scatter2D_mpi_r1
648
649
650  SUBROUTINE scatter2D_mpi_r2(VarIn, VarOut)
651    USE mod_grid_phy_lmdz
652    IMPLICIT NONE
653 
654    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
655    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
656
657    REAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
658   
659    CALL grid2dTo1d_glo(VarIn,Var_tmp)
660    CALL scatter_mpi(Var_tmp,VarOut)
661
662  END SUBROUTINE scatter2D_mpi_r2
663 
664  SUBROUTINE scatter2D_mpi_r3(VarIn, VarOut)
665    USE mod_grid_phy_lmdz
666    IMPLICIT NONE
667 
668    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
669    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
670   
671    REAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
672
673    CALL grid2dTo1d_glo(VarIn,Var_tmp)
674    CALL scatter_mpi(Var_tmp,VarOut)
675 
676  END SUBROUTINE scatter2D_mpi_r3
677 
678 
679  SUBROUTINE scatter2D_mpi_l(VarIn, VarOut)
680    USE mod_grid_phy_lmdz
681    IMPLICIT NONE
682 
683    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
684    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
685
686    LOGICAL,DIMENSION(klon_glo) :: Var_tmp   
687   
688    CALL grid2dTo1d_glo(VarIn,Var_tmp)
689    CALL scatter_mpi(Var_tmp,VarOut)
690
691  END SUBROUTINE scatter2D_mpi_l
692
693
694  SUBROUTINE scatter2D_mpi_l1(VarIn, VarOut)
695    USE mod_grid_phy_lmdz
696    IMPLICIT NONE
697 
698    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
699    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
700   
701    LOGICAL,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
702
703    CALL grid2dTo1d_glo(VarIn,Var_tmp)
704    CALL scatter_mpi(Var_tmp,VarOut)
705 
706  END SUBROUTINE scatter2D_mpi_l1
707
708
709  SUBROUTINE scatter2D_mpi_l2(VarIn, VarOut)
710    USE mod_grid_phy_lmdz
711    IMPLICIT NONE
712 
713    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
714    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
715   
716    LOGICAL, DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
717 
718    CALL grid2dTo1d_glo(VarIn,Var_tmp)
719    CALL scatter_mpi(Var_tmp,VarOut)
720
721  END SUBROUTINE scatter2D_mpi_l2
722 
723  SUBROUTINE scatter2D_mpi_l3(VarIn, VarOut)
724    USE mod_grid_phy_lmdz
725    IMPLICIT NONE
726 
727    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
728    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
729   
730    LOGICAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
731
732    CALL grid2dTo1d_glo(VarIn,Var_tmp)
733    CALL scatter_mpi(Var_tmp,VarOut)
734 
735  END SUBROUTINE scatter2D_mpi_l3
736 
737 
738!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
739!! Definition des Gather2D   --> 4D   !!
740!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
741
742  SUBROUTINE gather2D_mpi_i(VarIn, VarOut)
743    USE mod_grid_phy_lmdz
744    IMPLICIT NONE
745 
746    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
747    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
748   
749    INTEGER,DIMENSION(klon_glo) :: Var_tmp
750   
751    CALL gather_mpi(VarIn,Var_tmp)
752    CALL grid1dTo2d_glo(Var_tmp,VarOut)
753
754  END SUBROUTINE gather2D_mpi_i
755
756  SUBROUTINE gather2D_mpi_i1(VarIn, VarOut)
757    USE mod_grid_phy_lmdz
758    IMPLICIT NONE
759 
760    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
761    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
762
763    INTEGER,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
764
765    CALL gather_mpi(VarIn,Var_tmp)
766    CALL grid1dTo2d_glo(Var_tmp,VarOut)
767
768  END SUBROUTINE gather2D_mpi_i1
769
770  SUBROUTINE gather2D_mpi_i2(VarIn, VarOut)
771    USE mod_grid_phy_lmdz
772    IMPLICIT NONE
773 
774    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
775    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
776
777    INTEGER,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
778   
779    CALL gather_mpi(VarIn,Var_tmp)
780    CALL grid1dTo2d_glo(Var_tmp,VarOut)
781
782  END SUBROUTINE gather2D_mpi_i2
783 
784  SUBROUTINE gather2D_mpi_i3(VarIn, VarOut)
785    USE mod_grid_phy_lmdz
786    IMPLICIT NONE
787 
788    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
789    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
790 
791    INTEGER,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
792   
793    CALL gather_mpi(VarIn,Var_tmp)
794    CALL grid1dTo2d_glo(Var_tmp,VarOut)
795
796  END SUBROUTINE gather2D_mpi_i3
797
798
799
800  SUBROUTINE gather2D_mpi_r(VarIn, VarOut)
801    USE mod_grid_phy_lmdz
802    IMPLICIT NONE
803 
804    REAL,INTENT(IN),DIMENSION(:) :: VarIn
805    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
806   
807    REAL,DIMENSION(klon_glo) :: Var_tmp
808   
809    CALL gather_mpi(VarIn,Var_tmp)
810    CALL grid1dTo2d_glo(Var_tmp,VarOut)
811
812  END SUBROUTINE gather2D_mpi_r
813
814  SUBROUTINE gather2D_mpi_r1(VarIn, VarOut)
815    USE mod_grid_phy_lmdz
816    IMPLICIT NONE
817 
818    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
819    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
820   
821    REAL,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
822
823    CALL gather_mpi(VarIn,Var_tmp)
824    CALL grid1dTo2d_glo(Var_tmp,VarOut)
825
826  END SUBROUTINE gather2D_mpi_r1
827
828  SUBROUTINE gather2D_mpi_r2(VarIn, VarOut)
829    USE mod_grid_phy_lmdz
830    IMPLICIT NONE
831 
832    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
833    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
834   
835    REAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
836
837    CALL gather_mpi(VarIn,Var_tmp)
838    CALL grid1dTo2d_glo(Var_tmp,VarOut)
839
840  END SUBROUTINE gather2D_mpi_r2
841 
842  SUBROUTINE gather2D_mpi_r3(VarIn, VarOut)
843    USE mod_grid_phy_lmdz
844    IMPLICIT NONE
845 
846    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
847    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
848   
849    REAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
850   
851    CALL gather_mpi(VarIn,Var_tmp)
852    CALL grid1dTo2d_glo(Var_tmp,VarOut)
853
854  END SUBROUTINE gather2D_mpi_r3
855
856 
857 
858  SUBROUTINE gather2D_mpi_l(VarIn, VarOut)
859    USE mod_grid_phy_lmdz
860    IMPLICIT NONE
861 
862    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
863    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
864   
865    LOGICAL,DIMENSION(klon_glo) :: Var_tmp
866   
867    CALL gather_mpi(VarIn,Var_tmp)
868    CALL grid1dTo2d_glo(Var_tmp,VarOut)
869
870  END SUBROUTINE gather2D_mpi_l
871
872  SUBROUTINE gather2D_mpi_l1(VarIn, VarOut)
873    USE mod_grid_phy_lmdz
874    IMPLICIT NONE
875 
876    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
877    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
878   
879    LOGICAL,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
880
881    CALL gather_mpi(VarIn,Var_tmp)
882    CALL grid1dTo2d_glo(Var_tmp,VarOut)
883
884  END SUBROUTINE gather2D_mpi_l1
885
886  SUBROUTINE gather2D_mpi_l2(VarIn, VarOut)
887    USE mod_grid_phy_lmdz
888    IMPLICIT NONE
889 
890    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
891    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
892   
893    LOGICAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
894
895    CALL gather_mpi(VarIn,Var_tmp)
896    CALL grid1dTo2d_glo(Var_tmp,VarOut)
897
898  END SUBROUTINE gather2D_mpi_l2
899 
900  SUBROUTINE gather2D_mpi_l3(VarIn, VarOut)
901    USE mod_grid_phy_lmdz
902    IMPLICIT NONE
903 
904    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
905    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
906   
907    LOGICAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
908   
909    CALL gather_mpi(VarIn,Var_tmp)
910    CALL grid1dTo2d_glo(Var_tmp,VarOut)
911
912  END SUBROUTINE gather2D_mpi_l3
913 
914 
915!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
916!! Definition des reduce_sum   --> 4D   !!
917!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
918
919  SUBROUTINE reduce_sum_mpi_i(VarIn, VarOut)
920    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
921    IMPLICIT NONE
922 
923    INTEGER,INTENT(IN)  :: VarIn
924    INTEGER,INTENT(OUT) :: VarOut
925    INTEGER             :: VarIn_tmp(1)
926    INTEGER             :: VarOut_tmp(1)
927   
928    VarIn_tmp(1)=VarIn   
929    CALL reduce_sum_mpi_igen(VarIn_tmp,Varout_tmp,1)
930    VarOut=VarOut_tmp(1)
931   
932  END SUBROUTINE reduce_sum_mpi_i
933
934  SUBROUTINE reduce_sum_mpi_i1(VarIn, VarOut)
935    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
936    IMPLICIT NONE
937 
938    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
939    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
940   
941    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
942 
943  END SUBROUTINE reduce_sum_mpi_i1
944
945  SUBROUTINE reduce_sum_mpi_i2(VarIn, VarOut)
946    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
947    IMPLICIT NONE
948 
949    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
950    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
951   
952    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
953 
954  END SUBROUTINE reduce_sum_mpi_i2
955
956  SUBROUTINE reduce_sum_mpi_i3(VarIn, VarOut)
957    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
958    IMPLICIT NONE
959 
960    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
961    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
962   
963    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
964 
965  END SUBROUTINE reduce_sum_mpi_i3
966
967  SUBROUTINE reduce_sum_mpi_i4(VarIn, VarOut)
968    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
969    IMPLICIT NONE
970 
971    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
972    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
973   
974    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
975 
976  END SUBROUTINE reduce_sum_mpi_i4                 
977 
978 
979  SUBROUTINE reduce_sum_mpi_r(VarIn, VarOut)
980    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
981    IMPLICIT NONE
982 
983    REAL,INTENT(IN)  :: VarIn
984    REAL,INTENT(OUT) :: VarOut
985    REAL             :: VarIn_tmp(1)
986    REAL             :: VarOut_tmp(1)
987   
988    VarIn_tmp(1)=VarIn   
989    CALL reduce_sum_mpi_rgen(VarIn_tmp,Varout_tmp,1)
990    VarOut=VarOut_tmp(1)
991 
992  END SUBROUTINE reduce_sum_mpi_r
993
994  SUBROUTINE reduce_sum_mpi_r1(VarIn, VarOut)
995    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
996    IMPLICIT NONE
997 
998    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
999    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
1000   
1001    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
1002     
1003  END SUBROUTINE reduce_sum_mpi_r1
1004
1005  SUBROUTINE reduce_sum_mpi_r2(VarIn, VarOut)
1006    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
1007    IMPLICIT NONE
1008 
1009    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
1010    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
1011   
1012    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
1013 
1014  END SUBROUTINE reduce_sum_mpi_r2
1015
1016  SUBROUTINE reduce_sum_mpi_r3(VarIn, VarOut)
1017    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
1018    IMPLICIT NONE
1019 
1020    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
1021    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
1022   
1023    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
1024 
1025  END SUBROUTINE reduce_sum_mpi_r3
1026
1027  SUBROUTINE reduce_sum_mpi_r4(VarIn, VarOut)
1028    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
1029    IMPLICIT NONE
1030 
1031    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
1032    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
1033   
1034    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
1035 
1036  END SUBROUTINE reduce_sum_mpi_r4
1037 
1038
1039
1040!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1041!! SUBROUTINE grid1dTo2d  !! 
1042!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1043
1044
1045  SUBROUTINE grid1dTo2d_mpi_i(VarIn,VarOut) 
1046  IMPLICIT NONE 
1047    INTEGER,INTENT(IN),DIMENSION(:)     :: VarIn
1048    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
1049   
1050    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,1)
1051 
1052  END SUBROUTINE grid1dTo2d_mpi_i
1053 
1054
1055  SUBROUTINE grid1dTo2d_mpi_i1(VarIn,VarOut) 
1056  IMPLICIT NONE 
1057    INTEGER,INTENT(IN),DIMENSION(:,:)     :: VarIn
1058    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
1059   
1060    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2))
1061 
1062  END SUBROUTINE grid1dTo2d_mpi_i1
1063
1064  SUBROUTINE grid1dTo2d_mpi_i2(VarIn,VarOut) 
1065  IMPLICIT NONE 
1066    INTEGER,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
1067    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
1068   
1069    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
1070 
1071  END SUBROUTINE grid1dTo2d_mpi_i2
1072 
1073  SUBROUTINE grid1dTo2d_mpi_i3(VarIn,VarOut) 
1074  IMPLICIT NONE 
1075    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
1076    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
1077   
1078    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
1079 
1080  END SUBROUTINE grid1dTo2d_mpi_i3
1081
1082
1083  SUBROUTINE grid1dTo2d_mpi_r(VarIn,VarOut) 
1084  IMPLICIT NONE 
1085    REAL,INTENT(IN),DIMENSION(:)     :: VarIn
1086    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
1087   
1088    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,1)
1089 
1090  END SUBROUTINE grid1dTo2d_mpi_r
1091 
1092
1093  SUBROUTINE grid1dTo2d_mpi_r1(VarIn,VarOut) 
1094  IMPLICIT NONE 
1095    REAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
1096    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
1097   
1098    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2))
1099 
1100  END SUBROUTINE grid1dTo2d_mpi_r1
1101
1102  SUBROUTINE grid1dTo2d_mpi_r2(VarIn,VarOut) 
1103  IMPLICIT NONE 
1104    REAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
1105    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
1106   
1107    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
1108 
1109  END SUBROUTINE grid1dTo2d_mpi_r2
1110 
1111  SUBROUTINE grid1dTo2d_mpi_r3(VarIn,VarOut) 
1112  IMPLICIT NONE 
1113    REAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
1114    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
1115   
1116    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
1117 
1118  END SUBROUTINE grid1dTo2d_mpi_r3
1119 
1120 
1121 
1122  SUBROUTINE grid1dTo2d_mpi_l(VarIn,VarOut) 
1123  IMPLICIT NONE 
1124    LOGICAL,INTENT(IN),DIMENSION(:)     :: VarIn
1125    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
1126   
1127    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,1)
1128 
1129  END SUBROUTINE grid1dTo2d_mpi_l
1130 
1131
1132  SUBROUTINE grid1dTo2d_mpi_l1(VarIn,VarOut) 
1133  IMPLICIT NONE 
1134    LOGICAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
1135    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
1136   
1137    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2))
1138 
1139  END SUBROUTINE grid1dTo2d_mpi_l1
1140
1141  SUBROUTINE grid1dTo2d_mpi_l2(VarIn,VarOut) 
1142  IMPLICIT NONE 
1143    LOGICAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
1144    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
1145   
1146    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
1147 
1148  END SUBROUTINE grid1dTo2d_mpi_l2
1149 
1150  SUBROUTINE grid1dTo2d_mpi_l3(VarIn,VarOut) 
1151  IMPLICIT NONE 
1152    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
1153    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
1154   
1155    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
1156 
1157  END SUBROUTINE grid1dTo2d_mpi_l3
1158
1159
1160  SUBROUTINE grid2dTo1d_mpi_i(VarIn,VarOut) 
1161  IMPLICIT NONE 
1162    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
1163    INTEGER,INTENT(OUT),DIMENSION(:)  :: VarOut
1164   
1165    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,1)
1166 
1167  END SUBROUTINE grid2dTo1d_mpi_i
1168 
1169
1170  SUBROUTINE grid2dTo1d_mpi_i1(VarIn,VarOut) 
1171  IMPLICIT NONE 
1172    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
1173    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
1174   
1175    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3))
1176 
1177  END SUBROUTINE grid2dTo1d_mpi_i1
1178
1179  SUBROUTINE grid2dTo1d_mpi_i2(VarIn,VarOut) 
1180  IMPLICIT NONE 
1181    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
1182    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
1183   
1184    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
1185 
1186  END SUBROUTINE grid2dTo1d_mpi_i2
1187 
1188  SUBROUTINE grid2dTo1d_mpi_i3(VarIn,VarOut) 
1189  IMPLICIT NONE 
1190    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
1191    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
1192   
1193    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
1194 
1195  END SUBROUTINE grid2dTo1d_mpi_i3
1196 
1197
1198
1199
1200  SUBROUTINE grid2dTo1d_mpi_r(VarIn,VarOut) 
1201  IMPLICIT NONE 
1202    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
1203    REAL,INTENT(OUT),DIMENSION(:)  :: VarOut
1204   
1205    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,1)
1206 
1207  END SUBROUTINE grid2dTo1d_mpi_r
1208 
1209
1210  SUBROUTINE grid2dTo1d_mpi_r1(VarIn,VarOut) 
1211  IMPLICIT NONE 
1212    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
1213    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
1214   
1215    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3))
1216 
1217  END SUBROUTINE grid2dTo1d_mpi_r1
1218
1219  SUBROUTINE grid2dTo1d_mpi_r2(VarIn,VarOut) 
1220  IMPLICIT NONE 
1221    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
1222    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
1223   
1224    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
1225 
1226  END SUBROUTINE grid2dTo1d_mpi_r2
1227 
1228  SUBROUTINE grid2dTo1d_mpi_r3(VarIn,VarOut) 
1229  IMPLICIT NONE 
1230    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
1231    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
1232   
1233    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
1234 
1235  END SUBROUTINE grid2dTo1d_mpi_r3
1236
1237
1238
1239  SUBROUTINE grid2dTo1d_mpi_l(VarIn,VarOut) 
1240  IMPLICIT NONE 
1241    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
1242    LOGICAL,INTENT(OUT),DIMENSION(:)  :: VarOut
1243   
1244    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,1)
1245 
1246  END SUBROUTINE grid2dTo1d_mpi_l
1247 
1248
1249  SUBROUTINE grid2dTo1d_mpi_l1(VarIn,VarOut) 
1250  IMPLICIT NONE 
1251    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
1252    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
1253   
1254    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3))
1255 
1256  END SUBROUTINE grid2dTo1d_mpi_l1
1257
1258
1259
1260  SUBROUTINE grid2dTo1d_mpi_l2(VarIn,VarOut) 
1261  IMPLICIT NONE 
1262    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
1263    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
1264   
1265    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
1266 
1267  END SUBROUTINE grid2dTo1d_mpi_l2
1268
1269 
1270  SUBROUTINE grid2dTo1d_mpi_l3(VarIn,VarOut) 
1271  IMPLICIT NONE 
1272    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
1273    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
1274   
1275    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
1276 
1277  END SUBROUTINE grid2dTo1d_mpi_l3
1278
1279               
1280
1281
1282
1283!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1284!! DEFINITION DES FONCTIONS DE TRANSFERT GENERIQUES !
1285!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1286
1287  SUBROUTINE bcast_mpi_cgen(var,nb)
1288    USE mod_phys_lmdz_mpi_data
1289    IMPLICIT NONE
1290   
1291    CHARACTER(LEN=*),INTENT(INOUT) :: Var
1292    INTEGER,INTENT(IN) :: nb
1293   
1294#ifdef CPP_MPI
1295    INCLUDE 'mpif.h'
1296#endif
1297    INTEGER :: ierr
1298
1299    IF (.not.is_using_mpi) RETURN
1300   
1301#ifdef CPP_MPI
1302    CALL MPI_BCAST(Var,nb,MPI_CHARACTER,mpi_master,COMM_LMDZ_PHY,ierr)
1303#endif
1304       
1305  END SUBROUTINE bcast_mpi_cgen
1306
1307
1308     
1309  SUBROUTINE bcast_mpi_igen(var,nb)
1310    USE mod_phys_lmdz_mpi_data
1311    IMPLICIT NONE
1312   
1313    INTEGER,INTENT(IN) :: nb
1314    INTEGER,DIMENSION(nb),INTENT(INOUT) :: Var
1315   
1316#ifdef CPP_MPI
1317    INCLUDE 'mpif.h'
1318#endif
1319    INTEGER :: ierr
1320
1321    IF (.not.is_using_mpi) RETURN
1322
1323#ifdef CPP_MPI
1324    CALL MPI_BCAST(Var,nb,MPI_INTEGER,mpi_master,COMM_LMDZ_PHY,ierr)
1325#endif
1326       
1327  END SUBROUTINE bcast_mpi_igen
1328
1329
1330
1331 
1332  SUBROUTINE bcast_mpi_rgen(var,nb)
1333    USE mod_phys_lmdz_mpi_data
1334    IMPLICIT NONE
1335   
1336    INTEGER,INTENT(IN) :: nb
1337    REAL,DIMENSION(nb),INTENT(INOUT) :: Var
1338   
1339#ifdef CPP_MPI
1340    INCLUDE 'mpif.h'
1341#endif
1342    INTEGER :: ierr
1343
1344    IF (.not.is_using_mpi) RETURN
1345
1346#ifdef CPP_MPI
1347    CALL MPI_BCAST(Var,nb,MPI_REAL_LMDZ,mpi_master,COMM_LMDZ_PHY,ierr)
1348#endif
1349   
1350  END SUBROUTINE bcast_mpi_rgen
1351 
1352
1353
1354
1355  SUBROUTINE bcast_mpi_lgen(var,nb)
1356    USE mod_phys_lmdz_mpi_data
1357    IMPLICIT NONE
1358   
1359    INTEGER,INTENT(IN) :: nb
1360    LOGICAL,DIMENSION(nb),INTENT(INOUT) :: Var
1361   
1362#ifdef CPP_MPI
1363    INCLUDE 'mpif.h'
1364#endif
1365    INTEGER :: ierr
1366
1367    IF (.not.is_using_mpi) RETURN
1368
1369#ifdef CPP_MPI
1370    CALL MPI_BCAST(Var,nb,MPI_LOGICAL,mpi_master,COMM_LMDZ_PHY,ierr)
1371#endif
1372
1373  END SUBROUTINE bcast_mpi_lgen
1374
1375 
1376
1377  SUBROUTINE scatter_mpi_igen(VarIn, VarOut, dimsize)
1378    USE mod_phys_lmdz_mpi_data
1379    USE mod_grid_phy_lmdz
1380    IMPLICIT NONE
1381 
1382    INTEGER,INTENT(IN) :: dimsize
1383    INTEGER,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
1384    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1385 
1386#ifdef CPP_MPI
1387    INCLUDE 'mpif.h'
1388#endif
1389    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1390    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1391    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
1392    INTEGER :: nb,i,index,rank
1393    INTEGER :: ierr
1394
1395
1396    IF (.not.is_using_mpi) THEN
1397      VarOut(:,:)=VarIn(:,:)
1398      RETURN
1399    ENDIF
1400
1401   
1402    IF (is_mpi_root) THEN
1403      Index=1
1404      DO rank=0,mpi_size-1
1405        nb=klon_mpi_para_nb(rank)
1406        displs(rank)=Index-1
1407        counts(rank)=nb*dimsize
1408        DO i=1,dimsize
1409          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
1410          Index=Index+nb
1411        ENDDO
1412      ENDDO
1413    ENDIF
1414     
1415#ifdef CPP_MPI
1416    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_INTEGER,VarOut,klon_mpi*dimsize,   &
1417                      MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
1418#endif
1419
1420  END SUBROUTINE scatter_mpi_igen
1421
1422  SUBROUTINE scatter_mpi_rgen(VarIn, VarOut, dimsize)
1423    USE mod_phys_lmdz_mpi_data
1424    USE mod_grid_phy_lmdz
1425    IMPLICIT NONE
1426 
1427    INTEGER,INTENT(IN) :: dimsize
1428    REAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
1429    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1430 
1431#ifdef CPP_MPI
1432    INCLUDE 'mpif.h'
1433#endif
1434
1435    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1436    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1437    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1438    INTEGER :: nb,i,index,rank
1439    INTEGER :: ierr
1440
1441    IF (.not.is_using_mpi) THEN
1442      VarOut(:,:)=VarIn(:,:)
1443      RETURN
1444    ENDIF
1445   
1446    IF (is_mpi_root) THEN
1447      Index=1
1448      DO rank=0,mpi_size-1
1449        nb=klon_mpi_para_nb(rank)
1450        displs(rank)=Index-1
1451        counts(rank)=nb*dimsize
1452        DO i=1,dimsize
1453          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
1454          Index=Index+nb
1455        ENDDO
1456      ENDDO
1457    ENDIF
1458     
1459#ifdef CPP_MPI
1460    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_REAL_LMDZ,VarOut,klon_mpi*dimsize,   &
1461                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
1462
1463#endif
1464
1465  END SUBROUTINE scatter_mpi_rgen
1466
1467 
1468  SUBROUTINE scatter_mpi_lgen(VarIn, VarOut, dimsize)
1469    USE mod_phys_lmdz_mpi_data
1470    USE mod_grid_phy_lmdz
1471    IMPLICIT NONE
1472 
1473    INTEGER,INTENT(IN) :: dimsize
1474    LOGICAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
1475    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1476 
1477#ifdef CPP_MPI
1478    INCLUDE 'mpif.h'
1479#endif
1480
1481    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1482    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1483    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1484    INTEGER :: nb,i,index,rank
1485    INTEGER :: ierr
1486
1487    IF (.not.is_using_mpi) THEN
1488      VarOut(:,:)=VarIn(:,:)
1489      RETURN
1490    ENDIF
1491   
1492    IF (is_mpi_root) THEN
1493      Index=1
1494      DO rank=0,mpi_size-1
1495        nb=klon_mpi_para_nb(rank)
1496        displs(rank)=Index-1
1497        counts(rank)=nb*dimsize
1498        DO i=1,dimsize
1499          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
1500          Index=Index+nb
1501        ENDDO
1502      ENDDO
1503    ENDIF
1504     
1505#ifdef CPP_MPI
1506    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_LOGICAL,VarOut,klon_mpi*dimsize,   &
1507                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
1508#endif
1509
1510  END SUBROUTINE scatter_mpi_lgen 
1511
1512
1513
1514
1515  SUBROUTINE gather_mpi_igen(VarIn, VarOut, dimsize)
1516    USE mod_phys_lmdz_mpi_data
1517    USE mod_grid_phy_lmdz
1518    IMPLICIT NONE
1519 
1520#ifdef CPP_MPI
1521    INCLUDE 'mpif.h'
1522#endif
1523   
1524    INTEGER,INTENT(IN) :: dimsize
1525    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1526    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
1527 
1528    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1529    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1530    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
1531    INTEGER :: nb,i,index,rank
1532    INTEGER :: ierr
1533
1534    IF (.not.is_using_mpi) THEN
1535      VarOut(:,:)=VarIn(:,:)
1536      RETURN
1537    ENDIF
1538
1539    IF (is_mpi_root) THEN
1540      Index=1
1541      DO rank=0,mpi_size-1
1542        nb=klon_mpi_para_nb(rank)
1543        displs(rank)=Index-1
1544        counts(rank)=nb*dimsize
1545        Index=Index+nb*dimsize
1546      ENDDO
1547     
1548    ENDIF
1549   
1550#ifdef CPP_MPI
1551    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_INTEGER,VarTmp,counts,displs,   &
1552                     MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
1553#endif
1554
1555                         
1556    IF (is_mpi_root) THEN
1557      Index=1
1558      DO rank=0,mpi_size-1
1559        nb=klon_mpi_para_nb(rank)
1560        DO i=1,dimsize
1561          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
1562          Index=Index+nb
1563        ENDDO
1564      ENDDO
1565    ENDIF
1566
1567  END SUBROUTINE gather_mpi_igen 
1568
1569  SUBROUTINE gather_mpi_rgen(VarIn, VarOut, dimsize)
1570    USE mod_phys_lmdz_mpi_data
1571    USE mod_grid_phy_lmdz
1572    IMPLICIT NONE
1573 
1574#ifdef CPP_MPI
1575    INCLUDE 'mpif.h'
1576#endif
1577   
1578    INTEGER,INTENT(IN) :: dimsize
1579    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1580    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
1581 
1582    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1583    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1584    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1585    INTEGER :: nb,i,index,rank
1586    INTEGER :: ierr
1587
1588    IF (is_mpi_root) THEN
1589      Index=1
1590      DO rank=0,mpi_size-1
1591        nb=klon_mpi_para_nb(rank)
1592        displs(rank)=Index-1
1593        counts(rank)=nb*dimsize
1594        Index=Index+nb*dimsize
1595      ENDDO
1596    ENDIF
1597   
1598    IF (.not.is_using_mpi) THEN
1599      VarOut(:,:)=VarIn(:,:)
1600      RETURN
1601    ENDIF
1602
1603#ifdef CPP_MPI
1604    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_REAL_LMDZ,VarTmp,counts,displs,   &
1605                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
1606#endif
1607                         
1608    IF (is_mpi_root) THEN
1609      Index=1
1610      DO rank=0,mpi_size-1
1611        nb=klon_mpi_para_nb(rank)
1612        DO i=1,dimsize
1613          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
1614          Index=Index+nb
1615        ENDDO
1616      ENDDO
1617    ENDIF
1618
1619  END SUBROUTINE gather_mpi_rgen 
1620
1621  SUBROUTINE gather_mpi_lgen(VarIn, VarOut, dimsize)
1622    USE mod_phys_lmdz_mpi_data
1623    USE mod_grid_phy_lmdz
1624    IMPLICIT NONE
1625 
1626    INTEGER,INTENT(IN) :: dimsize
1627    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1628    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
1629 
1630#ifdef CPP_MPI
1631    INCLUDE 'mpif.h'
1632#endif
1633
1634    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1635    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1636    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1637    INTEGER :: nb,i,index,rank
1638    INTEGER :: ierr
1639   
1640    IF (.not.is_using_mpi) THEN
1641      VarOut(:,:)=VarIn(:,:)
1642      RETURN
1643    ENDIF
1644
1645    IF (is_mpi_root) THEN
1646      Index=1
1647      DO rank=0,mpi_size-1
1648        nb=klon_mpi_para_nb(rank)
1649        displs(rank)=Index-1
1650        counts(rank)=nb*dimsize
1651        Index=Index+nb*dimsize
1652      ENDDO
1653    ENDIF
1654   
1655
1656#ifdef CPP_MPI
1657    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_LOGICAL,VarTmp,counts,displs,   &
1658                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
1659#endif
1660                         
1661    IF (is_mpi_root) THEN
1662      Index=1
1663      DO rank=0,mpi_size-1
1664        nb=klon_mpi_para_nb(rank)
1665        DO i=1,dimsize
1666          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
1667          Index=Index+nb
1668        ENDDO
1669      ENDDO
1670    ENDIF
1671
1672  END SUBROUTINE gather_mpi_lgen
1673 
1674
1675
1676  SUBROUTINE reduce_sum_mpi_igen(VarIn,VarOut,nb)
1677    USE mod_phys_lmdz_mpi_data
1678    USE mod_grid_phy_lmdz
1679    IMPLICIT NONE
1680   
1681#ifdef CPP_MPI
1682    INCLUDE 'mpif.h'
1683#endif
1684   
1685    INTEGER,INTENT(IN) :: nb
1686    INTEGER,DIMENSION(nb),INTENT(IN) :: VarIn
1687    INTEGER,DIMENSION(nb),INTENT(OUT) :: VarOut   
1688    INTEGER :: ierr
1689   
1690    IF (.not.is_using_mpi) THEN
1691      VarOut(:)=VarIn(:)
1692      RETURN
1693    ENDIF
1694
1695
1696#ifdef CPP_MPI
1697    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
1698#endif
1699           
1700  END SUBROUTINE reduce_sum_mpi_igen
1701 
1702  SUBROUTINE reduce_sum_mpi_rgen(VarIn,VarOut,nb)
1703    USE mod_phys_lmdz_mpi_data
1704    USE mod_grid_phy_lmdz
1705
1706    IMPLICIT NONE
1707
1708#ifdef CPP_MPI
1709    INCLUDE 'mpif.h'
1710#endif
1711   
1712    INTEGER,INTENT(IN) :: nb
1713    REAL,DIMENSION(nb),INTENT(IN) :: VarIn
1714    REAL,DIMENSION(nb),INTENT(OUT) :: VarOut   
1715    INTEGER :: ierr
1716 
1717    IF (.not.is_using_mpi) THEN
1718      VarOut(:)=VarIn(:)
1719      RETURN
1720    ENDIF
1721   
1722#ifdef CPP_MPI
1723    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
1724#endif
1725       
1726  END SUBROUTINE reduce_sum_mpi_rgen
1727
1728
1729
1730  SUBROUTINE grid1dTo2d_mpi_igen(VarIn,VarOut,dimsize)
1731    USE mod_phys_lmdz_mpi_data
1732    USE mod_grid_phy_lmdz
1733    IMPLICIT NONE
1734   
1735    INTEGER,INTENT(IN) :: dimsize
1736    INTEGER,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
1737    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
1738    INTEGER :: i,ij,Offset
1739
1740   
1741    VarOut(1:nbp_lon,:)=0
1742    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
1743   
1744    offset=ii_begin
1745    IF (is_north_pole_dyn) Offset=nbp_lon
1746   
1747   
1748    DO i=1,dimsize
1749      DO ij=1,klon_mpi
1750        VarOut(ij+offset-1,i)=VarIn(ij,i)
1751      ENDDO
1752    ENDDO
1753   
1754   
1755    IF (is_north_pole_dyn) THEN
1756      DO i=1,dimsize
1757        DO ij=1,nbp_lon
1758         VarOut(ij,i)=VarIn(1,i)
1759        ENDDO
1760      ENDDO
1761    ENDIF
1762   
1763    IF (is_south_pole_dyn) THEN
1764      DO i=1,dimsize
1765        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
1766         VarOut(ij,i)=VarIn(klon_mpi,i)
1767        ENDDO
1768      ENDDO
1769    ENDIF
1770
1771  END SUBROUTINE grid1dTo2d_mpi_igen   
1772
1773
1774  SUBROUTINE grid1dTo2d_mpi_rgen(VarIn,VarOut,dimsize)
1775    USE mod_phys_lmdz_mpi_data
1776    USE mod_grid_phy_lmdz
1777    IMPLICIT NONE
1778   
1779    INTEGER,INTENT(IN) :: dimsize
1780    REAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
1781    REAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
1782    INTEGER :: i,ij,Offset
1783
1784   
1785    VarOut(1:nbp_lon,:)=0
1786    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
1787   
1788    offset=ii_begin
1789    IF (is_north_pole_dyn) Offset=nbp_lon
1790   
1791   
1792    DO i=1,dimsize
1793      DO ij=1,klon_mpi
1794        VarOut(ij+offset-1,i)=VarIn(ij,i)
1795      ENDDO
1796    ENDDO
1797   
1798   
1799    IF (is_north_pole_dyn) THEN
1800      DO i=1,dimsize
1801        DO ij=1,nbp_lon
1802         VarOut(ij,i)=VarIn(1,i)
1803        ENDDO
1804      ENDDO
1805    ENDIF
1806   
1807    IF (is_south_pole_dyn) THEN
1808      DO i=1,dimsize
1809        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
1810         VarOut(ij,i)=VarIn(klon_mpi,i)
1811        ENDDO
1812      ENDDO
1813    ENDIF
1814
1815   END SUBROUTINE grid1dTo2d_mpi_rgen   
1816
1817
1818
1819  SUBROUTINE grid1dTo2d_mpi_lgen(VarIn,VarOut,dimsize)
1820    USE mod_phys_lmdz_mpi_data
1821    USE mod_grid_phy_lmdz
1822    IMPLICIT NONE
1823   
1824    INTEGER,INTENT(IN) :: dimsize
1825    LOGICAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
1826    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
1827    INTEGER :: i,ij,Offset
1828
1829   
1830    VarOut(1:nbp_lon,:)=.FALSE.
1831    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=.FALSE.
1832   
1833    offset=ii_begin
1834    IF (is_north_pole_dyn) Offset=nbp_lon
1835   
1836   
1837    DO i=1,dimsize
1838      DO ij=1,klon_mpi
1839        VarOut(ij+offset-1,i)=VarIn(ij,i)
1840      ENDDO
1841    ENDDO
1842   
1843   
1844    IF (is_north_pole_dyn) THEN
1845      DO i=1,dimsize
1846        DO ij=1,nbp_lon
1847         VarOut(ij,i)=VarIn(1,i)
1848        ENDDO
1849      ENDDO
1850    ENDIF
1851   
1852    IF (is_south_pole_dyn) THEN
1853      DO i=1,dimsize
1854        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
1855         VarOut(ij,i)=VarIn(klon_mpi,i)
1856        ENDDO
1857      ENDDO
1858    ENDIF
1859
1860   END SUBROUTINE grid1dTo2d_mpi_lgen   
1861
1862 
1863
1864
1865  SUBROUTINE grid2dTo1d_mpi_igen(VarIn,VarOut,dimsize)
1866    USE mod_phys_lmdz_mpi_data
1867    USE mod_grid_phy_lmdz
1868    IMPLICIT NONE
1869   
1870    INTEGER,INTENT(IN) :: dimsize
1871    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
1872    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
1873    INTEGER :: i,ij,offset
1874
1875    offset=ii_begin
1876    IF (is_north_pole_dyn) offset=nbp_lon
1877
1878    DO i=1,dimsize
1879      DO ij=1,klon_mpi
1880        VarOut(ij,i)=VarIn(ij+offset-1,i)
1881      ENDDO
1882    ENDDO
1883
1884    IF (is_north_pole_dyn) THEN
1885      DO i=1,dimsize
1886        VarOut(1,i)=VarIn(1,i)
1887      ENDDO
1888    ENDIF
1889   
1890   
1891  END SUBROUTINE grid2dTo1d_mpi_igen   
1892
1893
1894
1895  SUBROUTINE grid2dTo1d_mpi_rgen(VarIn,VarOut,dimsize)
1896    USE mod_phys_lmdz_mpi_data
1897    USE mod_grid_phy_lmdz
1898    IMPLICIT NONE
1899   
1900    INTEGER,INTENT(IN) :: dimsize
1901    REAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
1902    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
1903    INTEGER :: i,ij,offset
1904
1905    offset=ii_begin
1906    IF (is_north_pole_dyn) offset=nbp_lon
1907
1908    DO i=1,dimsize
1909      DO ij=1,klon_mpi
1910        VarOut(ij,i)=VarIn(ij+offset-1,i)
1911      ENDDO
1912    ENDDO
1913
1914    IF (is_north_pole_dyn) THEN
1915      DO i=1,dimsize
1916         VarOut(1,i)=VarIn(1,i)
1917      ENDDO
1918    ENDIF
1919   
1920   
1921  END SUBROUTINE grid2dTo1d_mpi_rgen   
1922 
1923
1924  SUBROUTINE grid2dTo1d_mpi_lgen(VarIn,VarOut,dimsize)
1925    USE mod_phys_lmdz_mpi_data
1926    USE mod_grid_phy_lmdz
1927    IMPLICIT NONE
1928   
1929    INTEGER,INTENT(IN) :: dimsize
1930    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
1931    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
1932    INTEGER :: i,ij,offset
1933
1934    offset=ii_begin
1935    IF (is_north_pole_dyn) offset=nbp_lon
1936
1937    DO i=1,dimsize
1938      DO ij=1,klon_mpi
1939        VarOut(ij,i)=VarIn(ij+offset-1,i)
1940      ENDDO
1941    ENDDO
1942
1943    IF (is_north_pole_dyn) THEN
1944      DO i=1,dimsize
1945        VarOut(1,i)=VarIn(1,i)
1946      ENDDO
1947    ENDIF
1948   
1949   
1950  END SUBROUTINE grid2dTo1d_mpi_lgen   
1951
1952END MODULE mod_phys_lmdz_mpi_transfert
1953
Note: See TracBrowser for help on using the repository browser.