source: LMDZ6/trunk/libf/phy_common/mod_phys_lmdz_mpi_transfert.F90 @ 3741

Last change on this file since 3741 was 3465, checked in by Laurent Fairhead, 6 years ago

Further modifications for DYNAMICO/LMDZ convergence. These are based
on Yann's LMDZ6_V2 sources. Compiles on irene and converges with revision 3459
in a bucket configuration
YM/LF

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