source: LMDZ4/trunk/libf/phytherm/mod_phys_lmdz_mpi_transfert.F90 @ 838

Last change on this file since 838 was 814, checked in by Laurent Fairhead, 17 years ago

Rajout de la physique utilisant les thermiques FH
LF

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