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

Last change on this file since 5251 was 4600, checked in by yann meurdesoif, 17 months ago

Suppress CPP_MPI key usage in source code. MPI wrappers is used to supress missing symbol if the mpi library is not linked

YM

  • 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: 51.6 KB
Line 
1!
2!$Id: mod_phys_lmdz_mpi_transfert.F90 4600 2023-06-30 18:18:43Z abarral $
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    USE lmdz_mpi
1370    IMPLICIT NONE
1371   
1372    CHARACTER(LEN=*),INTENT(INOUT) :: Var
1373    INTEGER,INTENT(IN) :: nb
1374   
1375    INTEGER :: ierr
1376
1377    IF (.not.is_using_mpi) RETURN
1378   
1379    CALL MPI_BCAST(Var,nb,MPI_CHARACTER,mpi_master,COMM_LMDZ_PHY,ierr)
1380       
1381  END SUBROUTINE bcast_mpi_cgen
1382
1383
1384     
1385  SUBROUTINE bcast_mpi_igen(var,nb)
1386    USE mod_phys_lmdz_mpi_data
1387    USE lmdz_mpi
1388    IMPLICIT NONE
1389   
1390    INTEGER,INTENT(IN) :: nb
1391    INTEGER,DIMENSION(nb),INTENT(INOUT) :: Var
1392   
1393    INTEGER :: ierr
1394
1395    IF (.not.is_using_mpi) RETURN
1396
1397    CALL MPI_BCAST(Var,nb,MPI_INTEGER,mpi_master,COMM_LMDZ_PHY,ierr)
1398       
1399  END SUBROUTINE bcast_mpi_igen
1400
1401
1402
1403 
1404  SUBROUTINE bcast_mpi_rgen(var,nb)
1405    USE mod_phys_lmdz_mpi_data
1406    USE lmdz_mpi
1407    IMPLICIT NONE
1408   
1409    INTEGER,INTENT(IN) :: nb
1410    REAL,DIMENSION(nb),INTENT(INOUT) :: Var
1411   
1412    INTEGER :: ierr
1413
1414    IF (.not.is_using_mpi) RETURN
1415
1416    CALL MPI_BCAST(Var,nb,MPI_REAL_LMDZ,mpi_master,COMM_LMDZ_PHY,ierr)
1417   
1418  END SUBROUTINE bcast_mpi_rgen
1419 
1420
1421
1422
1423  SUBROUTINE bcast_mpi_lgen(var,nb)
1424    USE mod_phys_lmdz_mpi_data
1425    USE lmdz_mpi
1426    IMPLICIT NONE
1427   
1428    INTEGER,INTENT(IN) :: nb
1429    LOGICAL,DIMENSION(nb),INTENT(INOUT) :: Var
1430   
1431    INTEGER :: ierr
1432
1433    IF (.not.is_using_mpi) RETURN
1434
1435    CALL MPI_BCAST(Var,nb,MPI_LOGICAL,mpi_master,COMM_LMDZ_PHY,ierr)
1436
1437  END SUBROUTINE bcast_mpi_lgen
1438
1439 
1440
1441  SUBROUTINE scatter_mpi_igen(VarIn, VarOut, dimsize)
1442    USE mod_phys_lmdz_mpi_data
1443    USE mod_grid_phy_lmdz
1444    USE lmdz_mpi
1445    IMPLICIT NONE
1446 
1447    INTEGER,INTENT(IN) :: dimsize
1448    INTEGER,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
1449    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1450 
1451    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1452    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1453    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
1454    INTEGER :: nb,i,index,rank
1455    INTEGER :: ierr
1456
1457
1458    IF (.not.is_using_mpi) THEN
1459      VarOut(:,:)=VarIn(:,:)
1460      RETURN
1461    ENDIF
1462
1463   
1464    IF (is_mpi_root) THEN
1465      Index=1
1466      DO rank=0,mpi_size-1
1467        nb=klon_mpi_para_nb(rank)
1468        displs(rank)=Index-1
1469        counts(rank)=nb*dimsize
1470        DO i=1,dimsize
1471          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
1472          Index=Index+nb
1473        ENDDO
1474      ENDDO
1475    ENDIF
1476     
1477    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_INTEGER,VarOut,klon_mpi*dimsize,   &
1478                      MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
1479
1480  END SUBROUTINE scatter_mpi_igen
1481
1482  SUBROUTINE scatter_mpi_rgen(VarIn, VarOut, dimsize)
1483    USE mod_phys_lmdz_mpi_data
1484    USE mod_grid_phy_lmdz
1485    USE lmdz_mpi
1486    IMPLICIT NONE
1487 
1488    INTEGER,INTENT(IN) :: dimsize
1489    REAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
1490    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1491
1492    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1493    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1494    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1495    INTEGER :: nb,i,index,rank
1496    INTEGER :: ierr
1497
1498    IF (.not.is_using_mpi) THEN
1499      VarOut(:,:)=VarIn(:,:)
1500      RETURN
1501    ENDIF
1502   
1503    IF (is_mpi_root) THEN
1504      Index=1
1505      DO rank=0,mpi_size-1
1506        nb=klon_mpi_para_nb(rank)
1507        displs(rank)=Index-1
1508        counts(rank)=nb*dimsize
1509        DO i=1,dimsize
1510          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
1511          Index=Index+nb
1512        ENDDO
1513      ENDDO
1514    ENDIF
1515     
1516    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_REAL_LMDZ,VarOut,klon_mpi*dimsize,   &
1517                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
1518
1519  END SUBROUTINE scatter_mpi_rgen
1520
1521 
1522  SUBROUTINE scatter_mpi_lgen(VarIn, VarOut, dimsize)
1523    USE mod_phys_lmdz_mpi_data
1524    USE mod_grid_phy_lmdz
1525    USE lmdz_mpi
1526    IMPLICIT NONE
1527 
1528    INTEGER,INTENT(IN) :: dimsize
1529    LOGICAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
1530    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1531 
1532
1533    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1534    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1535    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1536    INTEGER :: nb,i,index,rank
1537    INTEGER :: ierr
1538
1539    IF (.not.is_using_mpi) THEN
1540      VarOut(:,:)=VarIn(:,:)
1541      RETURN
1542    ENDIF
1543   
1544    IF (is_mpi_root) THEN
1545      Index=1
1546      DO rank=0,mpi_size-1
1547        nb=klon_mpi_para_nb(rank)
1548        displs(rank)=Index-1
1549        counts(rank)=nb*dimsize
1550        DO i=1,dimsize
1551          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
1552          Index=Index+nb
1553        ENDDO
1554      ENDDO
1555    ENDIF
1556     
1557    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_LOGICAL,VarOut,klon_mpi*dimsize,   &
1558                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
1559
1560  END SUBROUTINE scatter_mpi_lgen 
1561
1562
1563
1564
1565  SUBROUTINE gather_mpi_igen(VarIn, VarOut, dimsize)
1566    USE mod_phys_lmdz_mpi_data
1567    USE mod_grid_phy_lmdz
1568    USE lmdz_mpi
1569    IMPLICIT NONE
1570 
1571    INTEGER,INTENT(IN) :: dimsize
1572    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1573    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
1574 
1575    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1576    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1577    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
1578    INTEGER :: nb,i,index,rank
1579    INTEGER :: ierr
1580
1581    IF (.not.is_using_mpi) THEN
1582      VarOut(:,:)=VarIn(:,:)
1583      RETURN
1584    ENDIF
1585
1586    IF (is_mpi_root) THEN
1587      Index=1
1588      DO rank=0,mpi_size-1
1589        nb=klon_mpi_para_nb(rank)
1590        displs(rank)=Index-1
1591        counts(rank)=nb*dimsize
1592        Index=Index+nb*dimsize
1593      ENDDO
1594     
1595    ENDIF
1596   
1597    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_INTEGER,VarTmp,counts,displs,   &
1598                     MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
1599
1600                         
1601    IF (is_mpi_root) THEN
1602      Index=1
1603      DO rank=0,mpi_size-1
1604        nb=klon_mpi_para_nb(rank)
1605        DO i=1,dimsize
1606          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
1607          Index=Index+nb
1608        ENDDO
1609      ENDDO
1610    ENDIF
1611
1612  END SUBROUTINE gather_mpi_igen 
1613
1614  SUBROUTINE gather_mpi_rgen(VarIn, VarOut, dimsize)
1615    USE mod_phys_lmdz_mpi_data
1616    USE mod_grid_phy_lmdz
1617    USE lmdz_mpi
1618    IMPLICIT NONE
1619 
1620    INTEGER,INTENT(IN) :: dimsize
1621    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1622    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
1623 
1624    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1625    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1626    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1627    INTEGER :: nb,i,index,rank
1628    INTEGER :: ierr
1629
1630    IF (is_mpi_root) THEN
1631      Index=1
1632      DO rank=0,mpi_size-1
1633        nb=klon_mpi_para_nb(rank)
1634        displs(rank)=Index-1
1635        counts(rank)=nb*dimsize
1636        Index=Index+nb*dimsize
1637      ENDDO
1638    ENDIF
1639   
1640    IF (.not.is_using_mpi) THEN
1641      VarOut(:,:)=VarIn(:,:)
1642      RETURN
1643    ENDIF
1644
1645    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_REAL_LMDZ,VarTmp,counts,displs,   &
1646                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
1647                         
1648    IF (is_mpi_root) THEN
1649      Index=1
1650      DO rank=0,mpi_size-1
1651        nb=klon_mpi_para_nb(rank)
1652        DO i=1,dimsize
1653          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
1654          Index=Index+nb
1655        ENDDO
1656      ENDDO
1657    ENDIF
1658
1659  END SUBROUTINE gather_mpi_rgen 
1660
1661  SUBROUTINE gather_mpi_lgen(VarIn, VarOut, dimsize)
1662    USE mod_phys_lmdz_mpi_data
1663    USE mod_grid_phy_lmdz
1664    USE lmdz_mpi
1665    IMPLICIT NONE
1666 
1667    INTEGER,INTENT(IN) :: dimsize
1668    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1669    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
1670
1671    INTEGER,DIMENSION(0:mpi_size-1) :: displs
1672    INTEGER,DIMENSION(0:mpi_size-1) :: counts
1673    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
1674    INTEGER :: nb,i,index,rank
1675    INTEGER :: ierr
1676   
1677    IF (.not.is_using_mpi) THEN
1678      VarOut(:,:)=VarIn(:,:)
1679      RETURN
1680    ENDIF
1681
1682    IF (is_mpi_root) THEN
1683      Index=1
1684      DO rank=0,mpi_size-1
1685        nb=klon_mpi_para_nb(rank)
1686        displs(rank)=Index-1
1687        counts(rank)=nb*dimsize
1688        Index=Index+nb*dimsize
1689      ENDDO
1690    ENDIF
1691   
1692
1693    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_LOGICAL,VarTmp,counts,displs,   &
1694                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
1695                         
1696    IF (is_mpi_root) THEN
1697      Index=1
1698      DO rank=0,mpi_size-1
1699        nb=klon_mpi_para_nb(rank)
1700        DO i=1,dimsize
1701          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
1702          Index=Index+nb
1703        ENDDO
1704      ENDDO
1705    ENDIF
1706
1707  END SUBROUTINE gather_mpi_lgen
1708 
1709
1710
1711  SUBROUTINE reduce_sum_mpi_igen(VarIn,VarOut,nb)
1712    USE mod_phys_lmdz_mpi_data
1713    USE mod_grid_phy_lmdz
1714    USE lmdz_mpi
1715    IMPLICIT NONE
1716   
1717    INTEGER,INTENT(IN) :: nb
1718    INTEGER,DIMENSION(nb),INTENT(IN) :: VarIn
1719    INTEGER,DIMENSION(nb),INTENT(OUT) :: VarOut   
1720    INTEGER :: ierr
1721   
1722    IF (.not.is_using_mpi) THEN
1723      VarOut(:)=VarIn(:)
1724      RETURN
1725    ENDIF
1726
1727
1728    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
1729           
1730  END SUBROUTINE reduce_sum_mpi_igen
1731 
1732  SUBROUTINE reduce_sum_mpi_rgen(VarIn,VarOut,nb)
1733    USE mod_phys_lmdz_mpi_data
1734    USE mod_grid_phy_lmdz
1735    USE lmdz_mpi
1736    IMPLICIT NONE
1737
1738    INTEGER,INTENT(IN) :: nb
1739    REAL,DIMENSION(nb),INTENT(IN) :: VarIn
1740    REAL,DIMENSION(nb),INTENT(OUT) :: VarOut   
1741    INTEGER :: ierr
1742 
1743    IF (.not.is_using_mpi) THEN
1744      VarOut(:)=VarIn(:)
1745      RETURN
1746    ENDIF
1747   
1748    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
1749       
1750  END SUBROUTINE reduce_sum_mpi_rgen
1751
1752
1753
1754  SUBROUTINE reduce_min_mpi_igen(VarIn,VarOut,nb)
1755    USE mod_phys_lmdz_mpi_data
1756    USE mod_grid_phy_lmdz
1757    USE lmdz_mpi
1758    IMPLICIT NONE
1759   
1760    INTEGER,INTENT(IN) :: nb
1761    INTEGER,DIMENSION(nb),INTENT(IN) :: VarIn
1762    INTEGER,DIMENSION(nb),INTENT(OUT) :: VarOut   
1763    INTEGER :: ierr
1764   
1765    IF (.not.is_using_mpi) THEN
1766      VarOut(:)=VarIn(:)
1767      RETURN
1768    ENDIF
1769
1770
1771    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_MIN,mpi_master,COMM_LMDZ_PHY,ierr)
1772           
1773  END SUBROUTINE reduce_min_mpi_igen
1774 
1775  SUBROUTINE reduce_min_mpi_rgen(VarIn,VarOut,nb)
1776    USE mod_phys_lmdz_mpi_data
1777    USE mod_grid_phy_lmdz
1778    USE lmdz_mpi
1779
1780    IMPLICIT NONE
1781
1782    INTEGER,INTENT(IN) :: nb
1783    REAL,DIMENSION(nb),INTENT(IN) :: VarIn
1784    REAL,DIMENSION(nb),INTENT(OUT) :: VarOut   
1785    INTEGER :: ierr
1786 
1787    IF (.not.is_using_mpi) THEN
1788      VarOut(:)=VarIn(:)
1789      RETURN
1790    ENDIF
1791   
1792    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_MIN,mpi_master,COMM_LMDZ_PHY,ierr)
1793       
1794  END SUBROUTINE reduce_min_mpi_rgen
1795
1796
1797
1798
1799
1800
1801
1802  SUBROUTINE grid1dTo2d_mpi_igen(VarIn,VarOut,dimsize)
1803    USE mod_phys_lmdz_mpi_data
1804    USE mod_grid_phy_lmdz
1805    IMPLICIT NONE
1806   
1807    INTEGER,INTENT(IN) :: dimsize
1808    INTEGER,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
1809    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
1810    INTEGER :: i,ij,Offset
1811
1812   
1813    VarOut(1:nbp_lon,:)=0
1814    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
1815   
1816    offset=ii_begin
1817    IF (is_north_pole_dyn) Offset=nbp_lon
1818   
1819   
1820    DO i=1,dimsize
1821      DO ij=1,klon_mpi
1822        VarOut(ij+offset-1,i)=VarIn(ij,i)
1823      ENDDO
1824    ENDDO
1825   
1826   
1827    IF (is_north_pole_dyn) THEN
1828      DO i=1,dimsize
1829        DO ij=1,nbp_lon
1830         VarOut(ij,i)=VarIn(1,i)
1831        ENDDO
1832      ENDDO
1833    ENDIF
1834   
1835    IF (is_south_pole_dyn) THEN
1836      DO i=1,dimsize
1837        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
1838         VarOut(ij,i)=VarIn(klon_mpi,i)
1839        ENDDO
1840      ENDDO
1841    ENDIF
1842
1843  END SUBROUTINE grid1dTo2d_mpi_igen   
1844
1845
1846  SUBROUTINE grid1dTo2d_mpi_rgen(VarIn,VarOut,dimsize)
1847    USE mod_phys_lmdz_mpi_data
1848    USE mod_grid_phy_lmdz
1849    IMPLICIT NONE
1850   
1851    INTEGER,INTENT(IN) :: dimsize
1852    REAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
1853    REAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
1854    INTEGER :: i,ij,Offset
1855
1856   
1857    VarOut(1:nbp_lon,:)=0
1858    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
1859   
1860    offset=ii_begin
1861    IF (is_north_pole_dyn) Offset=nbp_lon
1862   
1863   
1864    DO i=1,dimsize
1865      DO ij=1,klon_mpi
1866        VarOut(ij+offset-1,i)=VarIn(ij,i)
1867      ENDDO
1868    ENDDO
1869   
1870   
1871    IF (is_north_pole_dyn) THEN
1872      DO i=1,dimsize
1873        DO ij=1,nbp_lon
1874         VarOut(ij,i)=VarIn(1,i)
1875        ENDDO
1876      ENDDO
1877    ENDIF
1878   
1879    IF (is_south_pole_dyn) THEN
1880      DO i=1,dimsize
1881        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
1882         VarOut(ij,i)=VarIn(klon_mpi,i)
1883        ENDDO
1884      ENDDO
1885    ENDIF
1886
1887   END SUBROUTINE grid1dTo2d_mpi_rgen   
1888
1889
1890
1891  SUBROUTINE grid1dTo2d_mpi_lgen(VarIn,VarOut,dimsize)
1892    USE mod_phys_lmdz_mpi_data
1893    USE mod_grid_phy_lmdz
1894    IMPLICIT NONE
1895   
1896    INTEGER,INTENT(IN) :: dimsize
1897    LOGICAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
1898    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
1899    INTEGER :: i,ij,Offset
1900
1901   
1902    VarOut(1:nbp_lon,:)=.FALSE.
1903    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=.FALSE.
1904   
1905    offset=ii_begin
1906    IF (is_north_pole_dyn) Offset=nbp_lon
1907   
1908   
1909    DO i=1,dimsize
1910      DO ij=1,klon_mpi
1911        VarOut(ij+offset-1,i)=VarIn(ij,i)
1912      ENDDO
1913    ENDDO
1914   
1915   
1916    IF (is_north_pole_dyn) THEN
1917      DO i=1,dimsize
1918        DO ij=1,nbp_lon
1919         VarOut(ij,i)=VarIn(1,i)
1920        ENDDO
1921      ENDDO
1922    ENDIF
1923   
1924    IF (is_south_pole_dyn) THEN
1925      DO i=1,dimsize
1926        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
1927         VarOut(ij,i)=VarIn(klon_mpi,i)
1928        ENDDO
1929      ENDDO
1930    ENDIF
1931
1932   END SUBROUTINE grid1dTo2d_mpi_lgen   
1933
1934 
1935
1936
1937  SUBROUTINE grid2dTo1d_mpi_igen(VarIn,VarOut,dimsize)
1938    USE mod_phys_lmdz_mpi_data
1939    USE mod_grid_phy_lmdz
1940    IMPLICIT NONE
1941   
1942    INTEGER,INTENT(IN) :: dimsize
1943    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
1944    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
1945    INTEGER :: i,ij,offset
1946
1947    offset=ii_begin
1948    IF (is_north_pole_dyn) offset=nbp_lon
1949
1950    DO i=1,dimsize
1951      DO ij=1,klon_mpi
1952        VarOut(ij,i)=VarIn(ij+offset-1,i)
1953      ENDDO
1954    ENDDO
1955
1956    IF (is_north_pole_dyn) THEN
1957      DO i=1,dimsize
1958        VarOut(1,i)=VarIn(1,i)
1959      ENDDO
1960    ENDIF
1961   
1962   
1963  END SUBROUTINE grid2dTo1d_mpi_igen   
1964
1965
1966
1967  SUBROUTINE grid2dTo1d_mpi_rgen(VarIn,VarOut,dimsize)
1968    USE mod_phys_lmdz_mpi_data
1969    USE mod_grid_phy_lmdz
1970    IMPLICIT NONE
1971   
1972    INTEGER,INTENT(IN) :: dimsize
1973    REAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
1974    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
1975    INTEGER :: i,ij,offset
1976
1977    offset=ii_begin
1978    IF (is_north_pole_dyn) offset=nbp_lon
1979
1980    DO i=1,dimsize
1981      DO ij=1,klon_mpi
1982        VarOut(ij,i)=VarIn(ij+offset-1,i)
1983      ENDDO
1984    ENDDO
1985
1986    IF (is_north_pole_dyn) THEN
1987      DO i=1,dimsize
1988         VarOut(1,i)=VarIn(1,i)
1989      ENDDO
1990    ENDIF
1991   
1992   
1993  END SUBROUTINE grid2dTo1d_mpi_rgen   
1994 
1995
1996  SUBROUTINE grid2dTo1d_mpi_lgen(VarIn,VarOut,dimsize)
1997    USE mod_phys_lmdz_mpi_data
1998    USE mod_grid_phy_lmdz
1999    IMPLICIT NONE
2000   
2001    INTEGER,INTENT(IN) :: dimsize
2002    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
2003    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
2004    INTEGER :: i,ij,offset
2005
2006    offset=ii_begin
2007    IF (is_north_pole_dyn) offset=nbp_lon
2008
2009    DO i=1,dimsize
2010      DO ij=1,klon_mpi
2011        VarOut(ij,i)=VarIn(ij+offset-1,i)
2012      ENDDO
2013    ENDDO
2014
2015    IF (is_north_pole_dyn) THEN
2016      DO i=1,dimsize
2017        VarOut(1,i)=VarIn(1,i)
2018      ENDDO
2019    ENDIF
2020   
2021   
2022  END SUBROUTINE grid2dTo1d_mpi_lgen   
2023
2024END MODULE mod_phys_lmdz_mpi_transfert
2025
Note: See TracBrowser for help on using the repository browser.