source: LMDZ6/trunk/libf/phy_common/mod_phys_lmdz_omp_transfert.F90 @ 4013

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

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

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.0 KB
Line 
1!
2!$Header$
3!
4MODULE mod_phys_lmdz_omp_transfert
5
6  PRIVATE
7 
8  INTEGER,PARAMETER :: grow_factor=1.5
9  INTEGER,PARAMETER :: size_min=1024
10 
11  CHARACTER(LEN=size_min),SAVE            :: buffer_c
12!  INTEGER,SAVE                            :: size_c=0
13  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:)   :: buffer_i
14  INTEGER,SAVE                            :: size_i=0
15  REAL,SAVE,ALLOCATABLE,DIMENSION(:)      :: buffer_r
16  INTEGER,SAVE                            :: size_r=0
17  LOGICAL,SAVE,ALLOCATABLE,DIMENSION(:)   :: buffer_l
18  INTEGER,SAVE                            :: size_l=0
19
20
21 
22 
23  INTERFACE bcast_omp
24    MODULE PROCEDURE bcast_omp_c,                                                     &
25                     bcast_omp_i,bcast_omp_i1,bcast_omp_i2,bcast_omp_i3,bcast_omp_i4, &
26                     bcast_omp_r,bcast_omp_r1,bcast_omp_r2,bcast_omp_r3,bcast_omp_r4, &
27                     bcast_omp_l,bcast_omp_l1,bcast_omp_l2,bcast_omp_l3,bcast_omp_l4
28  END INTERFACE
29
30  INTERFACE scatter_omp
31    MODULE PROCEDURE scatter_omp_i,scatter_omp_i1,scatter_omp_i2,scatter_omp_i3, &
32                     scatter_omp_r,scatter_omp_r1,scatter_omp_r2,scatter_omp_r3, &
33                     scatter_omp_l,scatter_omp_l1,scatter_omp_l2,scatter_omp_l3
34  END INTERFACE
35
36 
37  INTERFACE gather_omp
38    MODULE PROCEDURE gather_omp_i,gather_omp_i1,gather_omp_i2,gather_omp_i3, &
39                     gather_omp_r,gather_omp_r1,gather_omp_r2,gather_omp_r3, &
40                     gather_omp_l,gather_omp_l1,gather_omp_l2,gather_omp_l3 
41  END INTERFACE
42 
43 
44  INTERFACE reduce_sum_omp
45    MODULE PROCEDURE reduce_sum_omp_i,reduce_sum_omp_i1,reduce_sum_omp_i2,reduce_sum_omp_i3,reduce_sum_omp_i4, &
46                     reduce_sum_omp_r,reduce_sum_omp_r1,reduce_sum_omp_r2,reduce_sum_omp_r3,reduce_sum_omp_r4
47  END INTERFACE
48
49  INTERFACE reduce_min_omp
50    MODULE PROCEDURE reduce_min_omp_i,reduce_min_omp_i1,reduce_min_omp_i2,reduce_min_omp_i3,reduce_min_omp_i4, &
51                     reduce_min_omp_r,reduce_min_omp_r1,reduce_min_omp_r2,reduce_min_omp_r3,reduce_min_omp_r4
52  END INTERFACE
53
54
55  PUBLIC bcast_omp,scatter_omp,gather_omp,reduce_sum_omp, reduce_min_omp, omp_barrier
56
57CONTAINS
58
59  SUBROUTINE omp_barrier
60  IMPLICIT NONE
61
62!$OMP BARRIER
63
64  END SUBROUTINE omp_barrier
65 
66  SUBROUTINE check_buffer_i(buff_size)
67  IMPLICIT NONE
68  INTEGER :: buff_size
69
70!$OMP BARRIER
71!$OMP MASTER
72    IF (buff_size>size_i) THEN
73      IF (ALLOCATED(buffer_i)) DEALLOCATE(buffer_i)
74      size_i=MAX(size_min,INT(grow_factor*buff_size))
75      ALLOCATE(buffer_i(size_i))
76    ENDIF
77!$OMP END MASTER
78!$OMP BARRIER
79 
80  END SUBROUTINE check_buffer_i
81 
82  SUBROUTINE check_buffer_r(buff_size)
83  IMPLICIT NONE
84  INTEGER :: buff_size
85
86!$OMP BARRIER
87!$OMP MASTER
88    IF (buff_size>size_r) THEN
89      IF (ALLOCATED(buffer_r)) DEALLOCATE(buffer_r)
90      size_r=MAX(size_min,INT(grow_factor*buff_size))
91      ALLOCATE(buffer_r(size_r))
92    ENDIF
93!$OMP END MASTER
94!$OMP BARRIER
95 
96  END SUBROUTINE check_buffer_r
97 
98  SUBROUTINE check_buffer_l(buff_size)
99  IMPLICIT NONE
100  INTEGER :: buff_size
101
102!$OMP BARRIER
103!$OMP MASTER
104    IF (buff_size>size_l) THEN
105      IF (ALLOCATED(buffer_l)) DEALLOCATE(buffer_l)
106      size_l=MAX(size_min,INT(grow_factor*buff_size))
107      ALLOCATE(buffer_l(size_l))
108    ENDIF
109!$OMP END MASTER
110!$OMP BARRIER
111 
112  END SUBROUTINE check_buffer_l
113   
114!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
115!! Definition des Broadcast --> 4D   !!
116!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
117
118!! -- Les chaine de charactère -- !!
119
120  SUBROUTINE bcast_omp_c(var)
121  IMPLICIT NONE
122    CHARACTER(LEN=*),INTENT(INOUT) :: Var
123   
124    CALL bcast_omp_cgen(Var,len(Var),buffer_c)
125   
126  END SUBROUTINE bcast_omp_c
127
128!! -- Les entiers -- !!
129 
130  SUBROUTINE bcast_omp_i(var)
131  IMPLICIT NONE
132    INTEGER,INTENT(INOUT) :: Var
133    INTEGER :: Var_tmp(1)
134   
135    Var_tmp(1)=Var
136    CALL check_buffer_i(1)
137    CALL bcast_omp_igen(Var_tmp,1,buffer_i)
138    Var=Var_tmp(1)
139
140  END SUBROUTINE bcast_omp_i
141
142
143  SUBROUTINE bcast_omp_i1(var)
144  IMPLICIT NONE
145    INTEGER,INTENT(INOUT) :: Var(:)
146   
147    CALL check_buffer_i(size(Var))
148    CALL bcast_omp_igen(Var,size(Var),buffer_i)
149
150  END SUBROUTINE bcast_omp_i1
151
152
153  SUBROUTINE bcast_omp_i2(var)
154  IMPLICIT NONE
155    INTEGER,INTENT(INOUT) :: Var(:,:)
156   
157    CALL check_buffer_i(size(Var))
158    CALL bcast_omp_igen(Var,size(Var),buffer_i)
159
160  END SUBROUTINE bcast_omp_i2
161
162
163  SUBROUTINE bcast_omp_i3(var)
164  IMPLICIT NONE
165    INTEGER,INTENT(INOUT) :: Var(:,:,:)
166
167    CALL check_buffer_i(size(Var))
168    CALL bcast_omp_igen(Var,size(Var),buffer_i)
169
170  END SUBROUTINE bcast_omp_i3
171
172
173  SUBROUTINE bcast_omp_i4(var)
174  IMPLICIT NONE
175    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
176   
177    CALL check_buffer_i(size(Var))
178    CALL bcast_omp_igen(Var,size(Var),buffer_i)
179
180  END SUBROUTINE bcast_omp_i4
181
182
183!! -- Les reels -- !!
184
185  SUBROUTINE bcast_omp_r(var)
186  IMPLICIT NONE
187    REAL,INTENT(INOUT) :: Var
188    REAL :: Var_tmp(1)
189   
190    Var_tmp(1)=Var
191    CALL check_buffer_r(1)
192    CALL bcast_omp_rgen(Var_tmp,1,buffer_r)
193    Var=Var_tmp(1)
194
195  END SUBROUTINE bcast_omp_r
196
197
198  SUBROUTINE bcast_omp_r1(var)
199  IMPLICIT NONE
200    REAL,INTENT(INOUT) :: Var(:)
201   
202    CALL check_buffer_r(size(Var))
203    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
204
205  END SUBROUTINE bcast_omp_r1
206
207
208  SUBROUTINE bcast_omp_r2(var)
209  IMPLICIT NONE
210    REAL,INTENT(INOUT) :: Var(:,:)
211   
212    CALL check_buffer_r(size(Var))
213    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
214
215  END SUBROUTINE bcast_omp_r2
216
217
218  SUBROUTINE bcast_omp_r3(var)
219  IMPLICIT NONE
220    REAL,INTENT(INOUT) :: Var(:,:,:)
221
222    CALL check_buffer_r(size(Var))
223    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
224
225  END SUBROUTINE bcast_omp_r3
226
227
228  SUBROUTINE bcast_omp_r4(var)
229  IMPLICIT NONE
230    REAL,INTENT(INOUT) :: Var(:,:,:,:)
231   
232    CALL check_buffer_r(size(Var))
233    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
234
235  END SUBROUTINE bcast_omp_r4
236
237 
238!! -- Les booleans -- !!
239
240  SUBROUTINE bcast_omp_l(var)
241  IMPLICIT NONE
242    LOGICAL,INTENT(INOUT) :: Var
243    LOGICAL :: Var_tmp(1)
244   
245    Var_tmp(1)=Var
246    CALL check_buffer_l(1)
247    CALL bcast_omp_lgen(Var_tmp,1,buffer_l)
248    Var=Var_tmp(1)
249
250  END SUBROUTINE bcast_omp_l
251
252
253  SUBROUTINE bcast_omp_l1(var)
254  IMPLICIT NONE
255    LOGICAL,INTENT(INOUT) :: Var(:)
256   
257    CALL check_buffer_l(size(Var))
258    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
259
260  END SUBROUTINE bcast_omp_l1
261
262
263  SUBROUTINE bcast_omp_l2(var)
264  IMPLICIT NONE
265    LOGICAL,INTENT(INOUT) :: Var(:,:)
266   
267    CALL check_buffer_l(size(Var))
268    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
269
270  END SUBROUTINE bcast_omp_l2
271
272
273  SUBROUTINE bcast_omp_l3(var)
274  IMPLICIT NONE
275    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
276
277    CALL check_buffer_l(size(Var))
278    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
279
280  END SUBROUTINE bcast_omp_l3
281
282
283  SUBROUTINE bcast_omp_l4(var)
284  IMPLICIT NONE
285    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
286   
287    CALL check_buffer_l(size(Var))
288    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
289
290  END SUBROUTINE bcast_omp_l4
291
292
293
294!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
295!! Definition des Scatter   --> 4D   !!
296!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
297
298  SUBROUTINE scatter_omp_i(VarIn, VarOut)
299    IMPLICIT NONE
300 
301    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
302    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
303
304    CALL Check_buffer_i(size(VarIn))   
305    CALL scatter_omp_igen(VarIn,Varout,1,buffer_i)
306   
307  END SUBROUTINE scatter_omp_i
308
309
310  SUBROUTINE scatter_omp_i1(VarIn, VarOut)
311    IMPLICIT NONE
312 
313    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
314    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
315
316    CALL Check_buffer_i(size(VarIn))   
317    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2),buffer_i)
318   
319  END SUBROUTINE scatter_omp_i1
320 
321 
322  SUBROUTINE scatter_omp_i2(VarIn, VarOut)
323    IMPLICIT NONE
324 
325    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
326    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
327   
328    CALL Check_buffer_i(size(VarIn))   
329    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_i)
330
331  END SUBROUTINE scatter_omp_i2
332
333
334  SUBROUTINE scatter_omp_i3(VarIn, VarOut)
335    IMPLICIT NONE
336 
337    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
338    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
339   
340    CALL Check_buffer_i(size(VarIn))   
341    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_i)
342 
343  END SUBROUTINE scatter_omp_i3
344
345
346
347
348  SUBROUTINE scatter_omp_r(VarIn, VarOut)
349    IMPLICIT NONE
350 
351    REAL,INTENT(IN),DIMENSION(:) :: VarIn
352    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
353
354    CALL Check_buffer_r(size(VarIn))   
355    CALL scatter_omp_rgen(VarIn,Varout,1,buffer_r)
356   
357  END SUBROUTINE scatter_omp_r
358
359
360  SUBROUTINE scatter_omp_r1(VarIn, VarOut)
361    IMPLICIT NONE
362 
363    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
364    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
365   
366    CALL Check_buffer_r(size(VarIn))   
367    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2),buffer_r)
368       
369  END SUBROUTINE scatter_omp_r1
370 
371 
372  SUBROUTINE scatter_omp_r2(VarIn, VarOut)
373    IMPLICIT NONE
374 
375    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
376    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
377   
378    CALL Check_buffer_r(size(VarIn))   
379    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_r)
380
381  END SUBROUTINE scatter_omp_r2
382
383
384  SUBROUTINE scatter_omp_r3(VarIn, VarOut)
385    IMPLICIT NONE
386 
387    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
388    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
389   
390    CALL Check_buffer_r(size(VarIn))   
391    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_r)
392 
393  END SUBROUTINE scatter_omp_r3
394 
395
396
397  SUBROUTINE scatter_omp_l(VarIn, VarOut)
398    IMPLICIT NONE
399 
400    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
401    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
402
403    CALL Check_buffer_l(size(VarIn))   
404    CALL scatter_omp_lgen(VarIn,Varout,1,buffer_l)
405   
406  END SUBROUTINE scatter_omp_l
407
408
409  SUBROUTINE scatter_omp_l1(VarIn, VarOut)
410    IMPLICIT NONE
411 
412    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
413    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
414   
415    CALL Check_buffer_l(size(VarIn))   
416    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2),buffer_l)
417   
418  END SUBROUTINE scatter_omp_l1
419 
420 
421  SUBROUTINE scatter_omp_l2(VarIn, VarOut)
422    IMPLICIT NONE
423 
424    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
425    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
426   
427    CALL Check_buffer_l(size(VarIn))   
428    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_l)
429
430  END SUBROUTINE scatter_omp_l2
431
432
433  SUBROUTINE scatter_omp_l3(VarIn, VarOut)
434    IMPLICIT NONE
435 
436    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
437    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
438   
439    CALL Check_buffer_l(size(VarIn))   
440    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_l)
441 
442  END SUBROUTINE scatter_omp_l3 
443 
444
445  SUBROUTINE gather_omp_i(VarIn, VarOut)
446    IMPLICIT NONE
447 
448    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
449    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
450
451    CALL Check_buffer_i(size(VarOut))   
452    CALL gather_omp_igen(VarIn,Varout,1,buffer_i)
453   
454  END SUBROUTINE gather_omp_i
455
456
457  SUBROUTINE gather_omp_i1(VarIn, VarOut)
458    IMPLICIT NONE
459 
460    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
461    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
462   
463    CALL Check_buffer_i(size(VarOut))   
464    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2),buffer_i)
465   
466  END SUBROUTINE gather_omp_i1
467
468
469  SUBROUTINE gather_omp_i2(VarIn, VarOut)
470    IMPLICIT NONE
471 
472    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
473    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
474   
475    CALL Check_buffer_i(size(VarOut))   
476    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_i)
477         
478  END SUBROUTINE gather_omp_i2
479 
480
481  SUBROUTINE gather_omp_i3(VarIn, VarOut)
482    IMPLICIT NONE
483 
484    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
485    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
486   
487    CALL Check_buffer_i(size(VarOut))   
488    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_i)
489   
490  END SUBROUTINE gather_omp_i3
491
492
493
494  SUBROUTINE gather_omp_r(VarIn, VarOut)
495    IMPLICIT NONE
496 
497    REAL,INTENT(IN),DIMENSION(:) :: VarIn
498    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
499
500    CALL Check_buffer_r(size(VarOut))   
501    CALL gather_omp_rgen(VarIn,Varout,1,buffer_r)
502   
503  END SUBROUTINE gather_omp_r
504
505
506  SUBROUTINE gather_omp_r1(VarIn, VarOut)
507    IMPLICIT NONE
508 
509    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
510    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
511
512    CALL Check_buffer_r(size(VarOut))   
513    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2),buffer_r)
514       
515  END SUBROUTINE gather_omp_r1
516
517
518  SUBROUTINE gather_omp_r2(VarIn, VarOut)
519    IMPLICIT NONE
520 
521    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
522    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
523   
524    CALL Check_buffer_r(size(VarOut))   
525    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_r)
526   
527  END SUBROUTINE gather_omp_r2
528 
529
530  SUBROUTINE gather_omp_r3(VarIn, VarOut)
531    IMPLICIT NONE
532 
533    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
534    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
535
536    CALL Check_buffer_r(size(VarOut))       
537    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_r)
538   
539  END SUBROUTINE gather_omp_r3
540
541
542  SUBROUTINE gather_omp_l(VarIn, VarOut)
543    IMPLICIT NONE
544 
545    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
546    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
547
548    CALL Check_buffer_l(size(VarOut))   
549    CALL gather_omp_lgen(VarIn,Varout,1,buffer_l)
550   
551  END SUBROUTINE gather_omp_l
552
553
554  SUBROUTINE gather_omp_l1(VarIn, VarOut)
555    IMPLICIT NONE
556 
557    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
558    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
559   
560    CALL Check_buffer_l(size(VarOut))   
561    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2),buffer_l)
562   
563  END SUBROUTINE gather_omp_l1
564
565
566  SUBROUTINE gather_omp_l2(VarIn, VarOut)
567    IMPLICIT NONE
568 
569    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
570    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
571   
572    CALL Check_buffer_l(size(VarOut))   
573    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_l)
574   
575  END SUBROUTINE gather_omp_l2
576 
577
578  SUBROUTINE gather_omp_l3(VarIn, VarOut)
579    IMPLICIT NONE
580 
581    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
582    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
583   
584    CALL Check_buffer_l(size(VarOut))   
585    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_l)
586   
587  END SUBROUTINE gather_omp_l3
588
589
590
591
592  SUBROUTINE reduce_sum_omp_i(VarIn, VarOut)
593    IMPLICIT NONE
594 
595    INTEGER,INTENT(IN)  :: VarIn
596    INTEGER,INTENT(OUT) :: VarOut
597    INTEGER             :: VarIn_tmp(1)
598    INTEGER             :: VarOut_tmp(1)
599   
600    VarIn_tmp(1)=VarIn
601    CALL Check_buffer_i(1)   
602    CALL reduce_sum_omp_igen(VarIn_tmp,Varout_tmp,1,buffer_i)
603    VarOut=VarOut_tmp(1)
604   
605  END SUBROUTINE reduce_sum_omp_i
606
607  SUBROUTINE reduce_sum_omp_i1(VarIn, VarOut)
608    IMPLICIT NONE
609 
610    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
611    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
612   
613    CALL Check_buffer_i(size(VarIn))   
614    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
615   
616  END SUBROUTINE reduce_sum_omp_i1
617 
618 
619  SUBROUTINE reduce_sum_omp_i2(VarIn, VarOut)
620    IMPLICIT NONE
621 
622    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
623    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
624
625    CALL Check_buffer_i(size(VarIn))   
626    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
627 
628  END SUBROUTINE reduce_sum_omp_i2
629
630
631  SUBROUTINE reduce_sum_omp_i3(VarIn, VarOut)
632    IMPLICIT NONE
633 
634    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
635    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
636   
637    CALL Check_buffer_i(size(VarIn))   
638    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
639 
640  END SUBROUTINE reduce_sum_omp_i3
641
642
643  SUBROUTINE reduce_sum_omp_i4(VarIn, VarOut)
644    IMPLICIT NONE
645
646    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
647    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
648 
649    CALL Check_buffer_i(size(VarIn))   
650    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
651 
652  END SUBROUTINE reduce_sum_omp_i4
653
654
655  SUBROUTINE reduce_sum_omp_r(VarIn, VarOut)
656    IMPLICIT NONE
657 
658    REAL,INTENT(IN)  :: VarIn
659    REAL,INTENT(OUT) :: VarOut
660    REAL             :: VarIn_tmp(1)
661    REAL             :: VarOut_tmp(1)
662   
663    VarIn_tmp(1)=VarIn
664    CALL Check_buffer_r(1)   
665    CALL reduce_sum_omp_rgen(VarIn_tmp,Varout_tmp,1,buffer_r)
666    VarOut=VarOut_tmp(1)
667 
668  END SUBROUTINE reduce_sum_omp_r
669
670  SUBROUTINE reduce_sum_omp_r1(VarIn, VarOut)
671    IMPLICIT NONE
672 
673    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
674    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
675   
676    CALL Check_buffer_r(size(VarIn))   
677    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
678   
679  END SUBROUTINE reduce_sum_omp_r1
680 
681 
682  SUBROUTINE reduce_sum_omp_r2(VarIn, VarOut)
683    IMPLICIT NONE
684 
685    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
686    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
687   
688    CALL Check_buffer_r(size(VarIn))   
689    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
690 
691  END SUBROUTINE reduce_sum_omp_r2
692
693
694  SUBROUTINE reduce_sum_omp_r3(VarIn, VarOut)
695    IMPLICIT NONE
696 
697    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
698    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
699   
700    CALL Check_buffer_r(size(VarIn))   
701    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
702 
703  END SUBROUTINE reduce_sum_omp_r3
704
705
706  SUBROUTINE reduce_sum_omp_r4(VarIn, VarOut)
707    IMPLICIT NONE
708
709    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
710    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
711 
712    CALL Check_buffer_r(size(VarIn))   
713    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
714 
715  END SUBROUTINE reduce_sum_omp_r4
716
717
718
719  SUBROUTINE reduce_min_omp_i(VarIn, VarOut)
720    IMPLICIT NONE
721 
722    INTEGER,INTENT(IN)  :: VarIn
723    INTEGER,INTENT(OUT) :: VarOut
724    INTEGER             :: VarIn_tmp(1)
725    INTEGER             :: VarOut_tmp(1)
726   
727    VarIn_tmp(1)=VarIn
728    CALL Check_buffer_i(1)   
729    CALL reduce_min_omp_igen(VarIn_tmp,Varout_tmp,1,buffer_i)
730    VarOut=VarOut_tmp(1)
731   
732  END SUBROUTINE reduce_min_omp_i
733
734  SUBROUTINE reduce_min_omp_i1(VarIn, VarOut)
735    IMPLICIT NONE
736 
737    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
738    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
739   
740    CALL Check_buffer_i(size(VarIn))   
741    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
742   
743  END SUBROUTINE reduce_min_omp_i1
744 
745 
746  SUBROUTINE reduce_min_omp_i2(VarIn, VarOut)
747    IMPLICIT NONE
748 
749    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
750    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
751
752    CALL Check_buffer_i(size(VarIn))   
753    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
754 
755  END SUBROUTINE reduce_min_omp_i2
756
757
758  SUBROUTINE reduce_min_omp_i3(VarIn, VarOut)
759    IMPLICIT NONE
760 
761    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
762    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
763   
764    CALL Check_buffer_i(size(VarIn))   
765    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
766 
767  END SUBROUTINE reduce_min_omp_i3
768
769
770  SUBROUTINE reduce_min_omp_i4(VarIn, VarOut)
771    IMPLICIT NONE
772
773    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
774    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
775 
776    CALL Check_buffer_i(size(VarIn))   
777    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
778 
779  END SUBROUTINE reduce_min_omp_i4
780
781
782  SUBROUTINE reduce_min_omp_r(VarIn, VarOut)
783    IMPLICIT NONE
784 
785    REAL,INTENT(IN)  :: VarIn
786    REAL,INTENT(OUT) :: VarOut
787    REAL             :: VarIn_tmp(1)
788    REAL             :: VarOut_tmp(1)
789   
790    VarIn_tmp(1)=VarIn
791    CALL Check_buffer_r(1)   
792    CALL reduce_min_omp_rgen(VarIn_tmp,Varout_tmp,1,buffer_r)
793    VarOut=VarOut_tmp(1)
794 
795  END SUBROUTINE reduce_min_omp_r
796
797  SUBROUTINE reduce_min_omp_r1(VarIn, VarOut)
798    IMPLICIT NONE
799 
800    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
801    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
802   
803    CALL Check_buffer_r(size(VarIn))   
804    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
805   
806  END SUBROUTINE reduce_min_omp_r1
807 
808 
809  SUBROUTINE reduce_min_omp_r2(VarIn, VarOut)
810    IMPLICIT NONE
811 
812    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
813    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
814   
815    CALL Check_buffer_r(size(VarIn))   
816    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
817 
818  END SUBROUTINE reduce_min_omp_r2
819
820
821  SUBROUTINE reduce_min_omp_r3(VarIn, VarOut)
822    IMPLICIT NONE
823 
824    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
825    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
826   
827    CALL Check_buffer_r(size(VarIn))   
828    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
829 
830  END SUBROUTINE reduce_min_omp_r3
831
832
833  SUBROUTINE reduce_min_omp_r4(VarIn, VarOut)
834    IMPLICIT NONE
835
836    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
837    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
838 
839    CALL Check_buffer_r(size(VarIn))   
840    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
841 
842  END SUBROUTINE reduce_min_omp_r4
843
844
845
846
847!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
848!    LES ROUTINES GENERIQUES    !
849!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
850
851  SUBROUTINE bcast_omp_cgen(Var,Nb,Buff)
852  IMPLICIT NONE
853   
854    CHARACTER(LEN=*),INTENT(INOUT) :: Var
855    CHARACTER(LEN=*),INTENT(INOUT) :: Buff
856    INTEGER,INTENT(IN) :: Nb
857   
858    INTEGER :: i
859 
860  !$OMP MASTER
861      Buff=Var
862  !$OMP END MASTER
863  !$OMP BARRIER
864
865    DO i=1,Nb
866      Var=Buff
867    ENDDO
868  !$OMP BARRIER     
869 
870  END SUBROUTINE bcast_omp_cgen
871
872
873     
874  SUBROUTINE bcast_omp_igen(Var,Nb,Buff)
875  IMPLICIT NONE
876   
877    INTEGER,INTENT(IN) :: Nb
878    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Var
879    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Buff
880
881    INTEGER :: i
882   
883  !$OMP MASTER
884    DO i=1,Nb
885      Buff(i)=Var(i)
886    ENDDO
887  !$OMP END MASTER
888  !$OMP BARRIER
889
890    DO i=1,Nb
891      Var(i)=Buff(i)
892    ENDDO
893  !$OMP BARRIER       
894
895  END SUBROUTINE bcast_omp_igen
896
897
898  SUBROUTINE bcast_omp_rgen(Var,Nb,Buff)
899  IMPLICIT NONE
900   
901    INTEGER,INTENT(IN) :: Nb
902    REAL,DIMENSION(Nb),INTENT(INOUT) :: Var
903    REAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
904
905    INTEGER :: i
906   
907  !$OMP MASTER
908    DO i=1,Nb
909      Buff(i)=Var(i)
910    ENDDO
911  !$OMP END MASTER
912  !$OMP BARRIER
913
914    DO i=1,Nb
915      Var(i)=Buff(i)
916    ENDDO
917  !$OMP BARRIER       
918
919  END SUBROUTINE bcast_omp_rgen
920
921  SUBROUTINE bcast_omp_lgen(Var,Nb,Buff)
922  IMPLICIT NONE
923   
924    INTEGER,INTENT(IN) :: Nb
925    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Var
926    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
927 
928    INTEGER :: i
929   
930  !$OMP MASTER
931    DO i=1,Nb
932      Buff(i)=Var(i)
933    ENDDO
934  !$OMP END MASTER
935  !$OMP BARRIER
936
937    DO i=1,Nb
938      Var(i)=Buff(i)
939    ENDDO
940  !$OMP BARRIER       
941
942  END SUBROUTINE bcast_omp_lgen
943
944
945  SUBROUTINE scatter_omp_igen(VarIn,VarOut,dimsize,Buff)
946    USE mod_phys_lmdz_omp_data
947    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
948    IMPLICIT NONE
949
950    INTEGER,INTENT(IN) :: dimsize
951    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
952    INTEGER,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
953    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
954
955    INTEGER :: i,ij
956   
957  !$OMP MASTER
958    DO i=1,dimsize
959      DO ij=1,klon_mpi
960        Buff(ij,i)=VarIn(ij,i)
961      ENDDO
962    ENDDO 
963  !$OMP END MASTER
964  !$OMP BARRIER
965 
966    DO i=1,dimsize
967      DO ij=1,klon_omp
968        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
969      ENDDO
970    ENDDO
971  !$OMP BARRIER 
972 
973  END SUBROUTINE scatter_omp_igen
974
975
976  SUBROUTINE scatter_omp_rgen(VarIn,VarOut,dimsize,Buff)
977  USE mod_phys_lmdz_omp_data
978  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
979  IMPLICIT NONE
980
981    INTEGER,INTENT(IN) :: dimsize
982    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
983    REAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
984    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
985
986    INTEGER :: i,ij
987   
988  !$OMP MASTER
989    DO i=1,dimsize
990      DO ij=1,klon_mpi
991        Buff(ij,i)=VarIn(ij,i)
992      ENDDO
993    ENDDO 
994  !$OMP END MASTER
995  !$OMP BARRIER
996
997    DO i=1,dimsize
998      DO ij=1,klon_omp
999        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
1000      ENDDO
1001    ENDDO
1002  !$OMP BARRIER 
1003
1004  END SUBROUTINE scatter_omp_rgen
1005
1006
1007  SUBROUTINE scatter_omp_lgen(VarIn,VarOut,dimsize,Buff)
1008  USE mod_phys_lmdz_omp_data
1009  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1010  IMPLICIT NONE
1011
1012    INTEGER,INTENT(IN) :: dimsize
1013    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1014    LOGICAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
1015    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1016
1017    INTEGER :: i,ij
1018   
1019 !$OMP MASTER
1020    DO i=1,dimsize
1021      DO ij=1,klon_mpi
1022        Buff(ij,i)=VarIn(ij,i)
1023      ENDDO
1024    ENDDO 
1025  !$OMP END MASTER
1026  !$OMP BARRIER
1027
1028    DO i=1,dimsize
1029      DO ij=1,klon_omp
1030        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
1031      ENDDO
1032    ENDDO
1033  !$OMP BARRIER 
1034
1035  END SUBROUTINE scatter_omp_lgen
1036
1037
1038
1039
1040
1041  SUBROUTINE gather_omp_igen(VarIn,VarOut,dimsize,Buff)
1042  USE mod_phys_lmdz_omp_data
1043  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1044  IMPLICIT NONE
1045
1046    INTEGER,INTENT(IN) :: dimsize
1047    INTEGER,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
1048    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1049    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1050
1051    INTEGER :: i,ij
1052   
1053    DO i=1,dimsize
1054      DO ij=1,klon_omp
1055        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
1056      ENDDO
1057    ENDDO
1058  !$OMP BARRIER 
1059 
1060 
1061  !$OMP MASTER
1062    DO i=1,dimsize
1063      DO ij=1,klon_mpi
1064        VarOut(ij,i)=Buff(ij,i)
1065      ENDDO
1066    ENDDO 
1067  !$OMP END MASTER
1068  !$OMP BARRIER
1069
1070  END SUBROUTINE gather_omp_igen
1071
1072
1073  SUBROUTINE gather_omp_rgen(VarIn,VarOut,dimsize,Buff)
1074  USE mod_phys_lmdz_omp_data
1075  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1076  IMPLICIT NONE
1077
1078    INTEGER,INTENT(IN) :: dimsize
1079    REAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
1080    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1081    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1082
1083    INTEGER :: i,ij
1084   
1085    DO i=1,dimsize
1086      DO ij=1,klon_omp
1087        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
1088      ENDDO
1089    ENDDO
1090  !$OMP BARRIER 
1091
1092
1093  !$OMP MASTER
1094    DO i=1,dimsize
1095      DO ij=1,klon_mpi
1096        VarOut(ij,i)=Buff(ij,i)
1097      ENDDO
1098    ENDDO 
1099  !$OMP END MASTER
1100  !$OMP BARRIER
1101
1102  END SUBROUTINE gather_omp_rgen
1103
1104
1105  SUBROUTINE gather_omp_lgen(VarIn,VarOut,dimsize,Buff)
1106  USE mod_phys_lmdz_omp_data
1107  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1108  IMPLICIT NONE
1109
1110    INTEGER,INTENT(IN) :: dimsize
1111    LOGICAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
1112    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1113    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1114
1115    INTEGER :: i,ij
1116   
1117    DO i=1,dimsize
1118      DO ij=1,klon_omp
1119        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
1120      ENDDO
1121    ENDDO
1122  !$OMP BARRIER 
1123
1124
1125  !$OMP MASTER
1126    DO i=1,dimsize
1127      DO ij=1,klon_mpi
1128        VarOut(ij,i)=Buff(ij,i)
1129      ENDDO
1130    ENDDO 
1131  !$OMP END MASTER
1132  !$OMP BARRIER
1133
1134  END SUBROUTINE gather_omp_lgen
1135
1136
1137  SUBROUTINE reduce_sum_omp_igen(VarIn,VarOut,dimsize,Buff)
1138  IMPLICIT NONE
1139
1140    INTEGER,INTENT(IN) :: dimsize
1141    INTEGER,INTENT(IN),DIMENSION(dimsize) :: VarIn
1142    INTEGER,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1143    INTEGER,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1144
1145    INTEGER :: i
1146
1147  !$OMP MASTER
1148    Buff(:)=0
1149  !$OMP END MASTER
1150  !$OMP BARRIER
1151 
1152  !$OMP CRITICAL     
1153    DO i=1,dimsize
1154      Buff(i)=Buff(i)+VarIn(i)
1155    ENDDO
1156  !$OMP END CRITICAL
1157  !$OMP BARRIER 
1158 
1159  !$OMP MASTER
1160    DO i=1,dimsize
1161      VarOut(i)=Buff(i)
1162    ENDDO
1163  !$OMP END MASTER
1164  !$OMP BARRIER
1165 
1166  END SUBROUTINE reduce_sum_omp_igen
1167
1168  SUBROUTINE reduce_sum_omp_rgen(VarIn,VarOut,dimsize,Buff)
1169  IMPLICIT NONE
1170
1171    INTEGER,INTENT(IN) :: dimsize
1172    REAL,INTENT(IN),DIMENSION(dimsize) :: VarIn
1173    REAL,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1174    REAL,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1175
1176    INTEGER :: i
1177
1178  !$OMP MASTER
1179    Buff(:)=0
1180  !$OMP END MASTER
1181  !$OMP BARRIER
1182 
1183  !$OMP CRITICAL     
1184    DO i=1,dimsize
1185      Buff(i)=Buff(i)+VarIn(i)
1186    ENDDO
1187  !$OMP END CRITICAL
1188  !$OMP BARRIER 
1189 
1190  !$OMP MASTER
1191    DO i=1,dimsize
1192      VarOut(i)=Buff(i)
1193    ENDDO
1194  !$OMP END MASTER
1195  !$OMP BARRIER
1196 
1197  END SUBROUTINE reduce_sum_omp_rgen
1198
1199
1200  SUBROUTINE reduce_min_omp_igen(VarIn,VarOut,dimsize,Buff)
1201  IMPLICIT NONE
1202
1203    INTEGER,INTENT(IN) :: dimsize
1204    INTEGER,INTENT(IN),DIMENSION(dimsize) :: VarIn
1205    INTEGER,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1206    INTEGER,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1207
1208    INTEGER :: i
1209    INTEGER :: var
1210
1211  !$OMP MASTER
1212    Buff(:)=HUGE(var)
1213  !$OMP END MASTER
1214  !$OMP BARRIER
1215 
1216  !$OMP CRITICAL     
1217    DO i=1,dimsize
1218      Buff(i)=MIN(Buff(i),VarIn(i))
1219    ENDDO
1220  !$OMP END CRITICAL
1221  !$OMP BARRIER 
1222 
1223  !$OMP MASTER
1224    DO i=1,dimsize
1225      VarOut(i)=Buff(i)
1226    ENDDO
1227  !$OMP END MASTER
1228  !$OMP BARRIER
1229 
1230  END SUBROUTINE reduce_min_omp_igen
1231
1232  SUBROUTINE reduce_min_omp_rgen(VarIn,VarOut,dimsize,Buff)
1233  IMPLICIT NONE
1234
1235    INTEGER,INTENT(IN) :: dimsize
1236    REAL,INTENT(IN),DIMENSION(dimsize) :: VarIn
1237    REAL,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1238    REAL,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1239
1240    INTEGER :: i
1241    REAL :: var
1242
1243  !$OMP MASTER
1244    Buff(:)=HUGE(var)
1245  !$OMP END MASTER
1246  !$OMP BARRIER
1247 
1248  !$OMP CRITICAL     
1249    DO i=1,dimsize
1250      Buff(i)=MIN(Buff(i),VarIn(i))
1251    ENDDO
1252  !$OMP END CRITICAL
1253  !$OMP BARRIER 
1254 
1255  !$OMP MASTER
1256    DO i=1,dimsize
1257      VarOut(i)=Buff(i)
1258    ENDDO
1259  !$OMP END MASTER
1260  !$OMP BARRIER
1261 
1262  END SUBROUTINE reduce_min_omp_rgen
1263
1264
1265END MODULE mod_phys_lmdz_omp_transfert
Note: See TracBrowser for help on using the repository browser.