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

Last change on this file since 4691 was 4103, checked in by Laurent Fairhead, 3 years ago

Inclusion of some corrections and optimisations for XIOS done by
Arnaud Durocher during his TGCC mission.
Included here are r3703, r3704, r3750, r3751, r3752 from his
LMDZ6/branches/Optimisation_LMDZ branch

  • 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: 28.7 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 gather_omp_rgen(VarIn,Varout,1)
501   
502  END SUBROUTINE gather_omp_r
503
504
505  SUBROUTINE gather_omp_r1(VarIn, VarOut)
506    IMPLICIT NONE
507 
508    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
509    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
510 
511    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2))
512       
513  END SUBROUTINE gather_omp_r1
514
515
516  SUBROUTINE gather_omp_r2(VarIn, VarOut)
517    IMPLICIT NONE
518 
519    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
520    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
521 
522    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3))
523   
524  END SUBROUTINE gather_omp_r2
525 
526
527  SUBROUTINE gather_omp_r3(VarIn, VarOut)
528    IMPLICIT NONE
529 
530    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
531    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
532     
533    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
534   
535  END SUBROUTINE gather_omp_r3
536
537
538  SUBROUTINE gather_omp_l(VarIn, VarOut)
539    IMPLICIT NONE
540 
541    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
542    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
543
544    CALL Check_buffer_l(size(VarOut))   
545    CALL gather_omp_lgen(VarIn,Varout,1,buffer_l)
546   
547  END SUBROUTINE gather_omp_l
548
549
550  SUBROUTINE gather_omp_l1(VarIn, VarOut)
551    IMPLICIT NONE
552 
553    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
554    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
555   
556    CALL Check_buffer_l(size(VarOut))   
557    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2),buffer_l)
558   
559  END SUBROUTINE gather_omp_l1
560
561
562  SUBROUTINE gather_omp_l2(VarIn, VarOut)
563    IMPLICIT NONE
564 
565    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
566    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
567   
568    CALL Check_buffer_l(size(VarOut))   
569    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_l)
570   
571  END SUBROUTINE gather_omp_l2
572 
573
574  SUBROUTINE gather_omp_l3(VarIn, VarOut)
575    IMPLICIT NONE
576 
577    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
578    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
579   
580    CALL Check_buffer_l(size(VarOut))   
581    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_l)
582   
583  END SUBROUTINE gather_omp_l3
584
585
586
587
588  SUBROUTINE reduce_sum_omp_i(VarIn, VarOut)
589    IMPLICIT NONE
590 
591    INTEGER,INTENT(IN)  :: VarIn
592    INTEGER,INTENT(OUT) :: VarOut
593    INTEGER             :: VarIn_tmp(1)
594    INTEGER             :: VarOut_tmp(1)
595   
596    VarIn_tmp(1)=VarIn
597    CALL Check_buffer_i(1)   
598    CALL reduce_sum_omp_igen(VarIn_tmp,Varout_tmp,1,buffer_i)
599    VarOut=VarOut_tmp(1)
600   
601  END SUBROUTINE reduce_sum_omp_i
602
603  SUBROUTINE reduce_sum_omp_i1(VarIn, VarOut)
604    IMPLICIT NONE
605 
606    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
607    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
608   
609    CALL Check_buffer_i(size(VarIn))   
610    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
611   
612  END SUBROUTINE reduce_sum_omp_i1
613 
614 
615  SUBROUTINE reduce_sum_omp_i2(VarIn, VarOut)
616    IMPLICIT NONE
617 
618    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
619    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
620
621    CALL Check_buffer_i(size(VarIn))   
622    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
623 
624  END SUBROUTINE reduce_sum_omp_i2
625
626
627  SUBROUTINE reduce_sum_omp_i3(VarIn, VarOut)
628    IMPLICIT NONE
629 
630    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
631    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
632   
633    CALL Check_buffer_i(size(VarIn))   
634    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
635 
636  END SUBROUTINE reduce_sum_omp_i3
637
638
639  SUBROUTINE reduce_sum_omp_i4(VarIn, VarOut)
640    IMPLICIT NONE
641
642    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
643    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
644 
645    CALL Check_buffer_i(size(VarIn))   
646    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
647 
648  END SUBROUTINE reduce_sum_omp_i4
649
650
651  SUBROUTINE reduce_sum_omp_r(VarIn, VarOut)
652    IMPLICIT NONE
653 
654    REAL,INTENT(IN)  :: VarIn
655    REAL,INTENT(OUT) :: VarOut
656    REAL             :: VarIn_tmp(1)
657    REAL             :: VarOut_tmp(1)
658   
659    VarIn_tmp(1)=VarIn
660    CALL Check_buffer_r(1)   
661    CALL reduce_sum_omp_rgen(VarIn_tmp,Varout_tmp,1,buffer_r)
662    VarOut=VarOut_tmp(1)
663 
664  END SUBROUTINE reduce_sum_omp_r
665
666  SUBROUTINE reduce_sum_omp_r1(VarIn, VarOut)
667    IMPLICIT NONE
668 
669    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
670    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
671   
672    CALL Check_buffer_r(size(VarIn))   
673    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
674   
675  END SUBROUTINE reduce_sum_omp_r1
676 
677 
678  SUBROUTINE reduce_sum_omp_r2(VarIn, VarOut)
679    IMPLICIT NONE
680 
681    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
682    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
683   
684    CALL Check_buffer_r(size(VarIn))   
685    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
686 
687  END SUBROUTINE reduce_sum_omp_r2
688
689
690  SUBROUTINE reduce_sum_omp_r3(VarIn, VarOut)
691    IMPLICIT NONE
692 
693    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
694    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
695   
696    CALL Check_buffer_r(size(VarIn))   
697    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
698 
699  END SUBROUTINE reduce_sum_omp_r3
700
701
702  SUBROUTINE reduce_sum_omp_r4(VarIn, VarOut)
703    IMPLICIT NONE
704
705    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
706    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
707 
708    CALL Check_buffer_r(size(VarIn))   
709    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
710 
711  END SUBROUTINE reduce_sum_omp_r4
712
713
714
715  SUBROUTINE reduce_min_omp_i(VarIn, VarOut)
716    IMPLICIT NONE
717 
718    INTEGER,INTENT(IN)  :: VarIn
719    INTEGER,INTENT(OUT) :: VarOut
720    INTEGER             :: VarIn_tmp(1)
721    INTEGER             :: VarOut_tmp(1)
722   
723    VarIn_tmp(1)=VarIn
724    CALL Check_buffer_i(1)   
725    CALL reduce_min_omp_igen(VarIn_tmp,Varout_tmp,1,buffer_i)
726    VarOut=VarOut_tmp(1)
727   
728  END SUBROUTINE reduce_min_omp_i
729
730  SUBROUTINE reduce_min_omp_i1(VarIn, VarOut)
731    IMPLICIT NONE
732 
733    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
734    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
735   
736    CALL Check_buffer_i(size(VarIn))   
737    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
738   
739  END SUBROUTINE reduce_min_omp_i1
740 
741 
742  SUBROUTINE reduce_min_omp_i2(VarIn, VarOut)
743    IMPLICIT NONE
744 
745    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
746    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
747
748    CALL Check_buffer_i(size(VarIn))   
749    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
750 
751  END SUBROUTINE reduce_min_omp_i2
752
753
754  SUBROUTINE reduce_min_omp_i3(VarIn, VarOut)
755    IMPLICIT NONE
756 
757    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
758    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
759   
760    CALL Check_buffer_i(size(VarIn))   
761    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
762 
763  END SUBROUTINE reduce_min_omp_i3
764
765
766  SUBROUTINE reduce_min_omp_i4(VarIn, VarOut)
767    IMPLICIT NONE
768
769    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
770    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
771 
772    CALL Check_buffer_i(size(VarIn))   
773    CALL reduce_min_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
774 
775  END SUBROUTINE reduce_min_omp_i4
776
777
778  SUBROUTINE reduce_min_omp_r(VarIn, VarOut)
779    IMPLICIT NONE
780 
781    REAL,INTENT(IN)  :: VarIn
782    REAL,INTENT(OUT) :: VarOut
783    REAL             :: VarIn_tmp(1)
784    REAL             :: VarOut_tmp(1)
785   
786    VarIn_tmp(1)=VarIn
787    CALL Check_buffer_r(1)   
788    CALL reduce_min_omp_rgen(VarIn_tmp,Varout_tmp,1,buffer_r)
789    VarOut=VarOut_tmp(1)
790 
791  END SUBROUTINE reduce_min_omp_r
792
793  SUBROUTINE reduce_min_omp_r1(VarIn, VarOut)
794    IMPLICIT NONE
795 
796    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
797    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
798   
799    CALL Check_buffer_r(size(VarIn))   
800    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
801   
802  END SUBROUTINE reduce_min_omp_r1
803 
804 
805  SUBROUTINE reduce_min_omp_r2(VarIn, VarOut)
806    IMPLICIT NONE
807 
808    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
809    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
810   
811    CALL Check_buffer_r(size(VarIn))   
812    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
813 
814  END SUBROUTINE reduce_min_omp_r2
815
816
817  SUBROUTINE reduce_min_omp_r3(VarIn, VarOut)
818    IMPLICIT NONE
819 
820    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
821    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
822   
823    CALL Check_buffer_r(size(VarIn))   
824    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
825 
826  END SUBROUTINE reduce_min_omp_r3
827
828
829  SUBROUTINE reduce_min_omp_r4(VarIn, VarOut)
830    IMPLICIT NONE
831
832    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
833    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
834 
835    CALL Check_buffer_r(size(VarIn))   
836    CALL reduce_min_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
837 
838  END SUBROUTINE reduce_min_omp_r4
839
840
841
842
843!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
844!    LES ROUTINES GENERIQUES    !
845!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
846
847  SUBROUTINE bcast_omp_cgen(Var,Nb,Buff)
848  IMPLICIT NONE
849   
850    CHARACTER(LEN=*),INTENT(INOUT) :: Var
851    CHARACTER(LEN=*),INTENT(INOUT) :: Buff
852    INTEGER,INTENT(IN) :: Nb
853   
854    INTEGER :: i
855 
856  !$OMP MASTER
857      Buff=Var
858  !$OMP END MASTER
859  !$OMP BARRIER
860
861    DO i=1,Nb
862      Var=Buff
863    ENDDO
864  !$OMP BARRIER     
865 
866  END SUBROUTINE bcast_omp_cgen
867
868
869     
870  SUBROUTINE bcast_omp_igen(Var,Nb,Buff)
871  IMPLICIT NONE
872   
873    INTEGER,INTENT(IN) :: Nb
874    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Var
875    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Buff
876
877    INTEGER :: i
878   
879  !$OMP MASTER
880    DO i=1,Nb
881      Buff(i)=Var(i)
882    ENDDO
883  !$OMP END MASTER
884  !$OMP BARRIER
885
886    DO i=1,Nb
887      Var(i)=Buff(i)
888    ENDDO
889  !$OMP BARRIER       
890
891  END SUBROUTINE bcast_omp_igen
892
893
894  SUBROUTINE bcast_omp_rgen(Var,Nb,Buff)
895  IMPLICIT NONE
896   
897    INTEGER,INTENT(IN) :: Nb
898    REAL,DIMENSION(Nb),INTENT(INOUT) :: Var
899    REAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
900
901    INTEGER :: i
902   
903  !$OMP MASTER
904    DO i=1,Nb
905      Buff(i)=Var(i)
906    ENDDO
907  !$OMP END MASTER
908  !$OMP BARRIER
909
910    DO i=1,Nb
911      Var(i)=Buff(i)
912    ENDDO
913  !$OMP BARRIER       
914
915  END SUBROUTINE bcast_omp_rgen
916
917  SUBROUTINE bcast_omp_lgen(Var,Nb,Buff)
918  IMPLICIT NONE
919   
920    INTEGER,INTENT(IN) :: Nb
921    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Var
922    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
923 
924    INTEGER :: i
925   
926  !$OMP MASTER
927    DO i=1,Nb
928      Buff(i)=Var(i)
929    ENDDO
930  !$OMP END MASTER
931  !$OMP BARRIER
932
933    DO i=1,Nb
934      Var(i)=Buff(i)
935    ENDDO
936  !$OMP BARRIER       
937
938  END SUBROUTINE bcast_omp_lgen
939
940
941  SUBROUTINE scatter_omp_igen(VarIn,VarOut,dimsize,Buff)
942    USE mod_phys_lmdz_omp_data
943    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
944    IMPLICIT NONE
945
946    INTEGER,INTENT(IN) :: dimsize
947    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
948    INTEGER,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
949    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
950
951    INTEGER :: i,ij
952   
953  !$OMP MASTER
954    DO i=1,dimsize
955      DO ij=1,klon_mpi
956        Buff(ij,i)=VarIn(ij,i)
957      ENDDO
958    ENDDO 
959  !$OMP END MASTER
960  !$OMP BARRIER
961 
962    DO i=1,dimsize
963      DO ij=1,klon_omp
964        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
965      ENDDO
966    ENDDO
967  !$OMP BARRIER 
968 
969  END SUBROUTINE scatter_omp_igen
970
971
972  SUBROUTINE scatter_omp_rgen(VarIn,VarOut,dimsize,Buff)
973  USE mod_phys_lmdz_omp_data
974  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
975  IMPLICIT NONE
976
977    INTEGER,INTENT(IN) :: dimsize
978    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
979    REAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
980    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
981
982    INTEGER :: i,ij
983   
984  !$OMP MASTER
985    DO i=1,dimsize
986      DO ij=1,klon_mpi
987        Buff(ij,i)=VarIn(ij,i)
988      ENDDO
989    ENDDO 
990  !$OMP END MASTER
991  !$OMP BARRIER
992
993    DO i=1,dimsize
994      DO ij=1,klon_omp
995        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
996      ENDDO
997    ENDDO
998  !$OMP BARRIER 
999
1000  END SUBROUTINE scatter_omp_rgen
1001
1002
1003  SUBROUTINE scatter_omp_lgen(VarIn,VarOut,dimsize,Buff)
1004  USE mod_phys_lmdz_omp_data
1005  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1006  IMPLICIT NONE
1007
1008    INTEGER,INTENT(IN) :: dimsize
1009    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
1010    LOGICAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
1011    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1012
1013    INTEGER :: i,ij
1014   
1015 !$OMP MASTER
1016    DO i=1,dimsize
1017      DO ij=1,klon_mpi
1018        Buff(ij,i)=VarIn(ij,i)
1019      ENDDO
1020    ENDDO 
1021  !$OMP END MASTER
1022  !$OMP BARRIER
1023
1024    DO i=1,dimsize
1025      DO ij=1,klon_omp
1026        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
1027      ENDDO
1028    ENDDO
1029  !$OMP BARRIER 
1030
1031  END SUBROUTINE scatter_omp_lgen
1032
1033
1034
1035
1036
1037  SUBROUTINE gather_omp_igen(VarIn,VarOut,dimsize,Buff)
1038  USE mod_phys_lmdz_omp_data
1039  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1040  IMPLICIT NONE
1041
1042    INTEGER,INTENT(IN) :: dimsize
1043    INTEGER,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
1044    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1045    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1046
1047    INTEGER :: i,ij
1048   
1049    DO i=1,dimsize
1050      DO ij=1,klon_omp
1051        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
1052      ENDDO
1053    ENDDO
1054  !$OMP BARRIER 
1055 
1056 
1057  !$OMP MASTER
1058    DO i=1,dimsize
1059      DO ij=1,klon_mpi
1060        VarOut(ij,i)=Buff(ij,i)
1061      ENDDO
1062    ENDDO 
1063  !$OMP END MASTER
1064  !$OMP BARRIER
1065
1066  END SUBROUTINE gather_omp_igen
1067
1068
1069  SUBROUTINE gather_omp_rgen(VarIn,VarOut,dimsize)
1070  USE mod_phys_lmdz_omp_data
1071  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1072  IMPLICIT NONE
1073
1074    INTEGER,INTENT(IN) :: dimsize
1075    REAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
1076    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize),TARGET :: VarOut
1077
1078    REAL, POINTER, SAVE :: Varout_ptr(:,:) ! Shared between threads NOT THREADPRIVATE
1079
1080    INTEGER :: i,ij
1081   
1082    !$omp master
1083    Varout_ptr => VarOut
1084    !$omp end master
1085    !$omp barrier
1086
1087    DO i=1,dimsize
1088      DO ij=1,klon_omp
1089        Varout_ptr(klon_omp_begin-1+ij,i)=VarIn(ij,i)
1090      ENDDO
1091    ENDDO
1092    !$omp barrier
1093  END SUBROUTINE gather_omp_rgen
1094
1095
1096  SUBROUTINE gather_omp_lgen(VarIn,VarOut,dimsize,Buff)
1097  USE mod_phys_lmdz_omp_data
1098  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
1099  IMPLICIT NONE
1100
1101    INTEGER,INTENT(IN) :: dimsize
1102    LOGICAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
1103    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
1104    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
1105
1106    INTEGER :: i,ij
1107   
1108    DO i=1,dimsize
1109      DO ij=1,klon_omp
1110        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
1111      ENDDO
1112    ENDDO
1113  !$OMP BARRIER 
1114
1115
1116  !$OMP MASTER
1117    DO i=1,dimsize
1118      DO ij=1,klon_mpi
1119        VarOut(ij,i)=Buff(ij,i)
1120      ENDDO
1121    ENDDO 
1122  !$OMP END MASTER
1123  !$OMP BARRIER
1124
1125  END SUBROUTINE gather_omp_lgen
1126
1127
1128  SUBROUTINE reduce_sum_omp_igen(VarIn,VarOut,dimsize,Buff)
1129  IMPLICIT NONE
1130
1131    INTEGER,INTENT(IN) :: dimsize
1132    INTEGER,INTENT(IN),DIMENSION(dimsize) :: VarIn
1133    INTEGER,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1134    INTEGER,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1135
1136    INTEGER :: i
1137
1138  !$OMP MASTER
1139    Buff(:)=0
1140  !$OMP END MASTER
1141  !$OMP BARRIER
1142 
1143  !$OMP CRITICAL     
1144    DO i=1,dimsize
1145      Buff(i)=Buff(i)+VarIn(i)
1146    ENDDO
1147  !$OMP END CRITICAL
1148  !$OMP BARRIER 
1149 
1150  !$OMP MASTER
1151    DO i=1,dimsize
1152      VarOut(i)=Buff(i)
1153    ENDDO
1154  !$OMP END MASTER
1155  !$OMP BARRIER
1156 
1157  END SUBROUTINE reduce_sum_omp_igen
1158
1159  SUBROUTINE reduce_sum_omp_rgen(VarIn,VarOut,dimsize,Buff)
1160  IMPLICIT NONE
1161
1162    INTEGER,INTENT(IN) :: dimsize
1163    REAL,INTENT(IN),DIMENSION(dimsize) :: VarIn
1164    REAL,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1165    REAL,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1166
1167    INTEGER :: i
1168
1169  !$OMP MASTER
1170    Buff(:)=0
1171  !$OMP END MASTER
1172  !$OMP BARRIER
1173 
1174  !$OMP CRITICAL     
1175    DO i=1,dimsize
1176      Buff(i)=Buff(i)+VarIn(i)
1177    ENDDO
1178  !$OMP END CRITICAL
1179  !$OMP BARRIER 
1180 
1181  !$OMP MASTER
1182    DO i=1,dimsize
1183      VarOut(i)=Buff(i)
1184    ENDDO
1185  !$OMP END MASTER
1186  !$OMP BARRIER
1187 
1188  END SUBROUTINE reduce_sum_omp_rgen
1189
1190
1191  SUBROUTINE reduce_min_omp_igen(VarIn,VarOut,dimsize,Buff)
1192  IMPLICIT NONE
1193
1194    INTEGER,INTENT(IN) :: dimsize
1195    INTEGER,INTENT(IN),DIMENSION(dimsize) :: VarIn
1196    INTEGER,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1197    INTEGER,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1198
1199    INTEGER :: i
1200    INTEGER :: var
1201
1202  !$OMP MASTER
1203    Buff(:)=HUGE(var)
1204  !$OMP END MASTER
1205  !$OMP BARRIER
1206 
1207  !$OMP CRITICAL     
1208    DO i=1,dimsize
1209      Buff(i)=MIN(Buff(i),VarIn(i))
1210    ENDDO
1211  !$OMP END CRITICAL
1212  !$OMP BARRIER 
1213 
1214  !$OMP MASTER
1215    DO i=1,dimsize
1216      VarOut(i)=Buff(i)
1217    ENDDO
1218  !$OMP END MASTER
1219  !$OMP BARRIER
1220 
1221  END SUBROUTINE reduce_min_omp_igen
1222
1223  SUBROUTINE reduce_min_omp_rgen(VarIn,VarOut,dimsize,Buff)
1224  IMPLICIT NONE
1225
1226    INTEGER,INTENT(IN) :: dimsize
1227    REAL,INTENT(IN),DIMENSION(dimsize) :: VarIn
1228    REAL,INTENT(OUT),DIMENSION(dimsize) :: VarOut
1229    REAL,INTENT(INOUT),DIMENSION(dimsize) :: Buff
1230
1231    INTEGER :: i
1232    REAL :: var
1233
1234  !$OMP MASTER
1235    Buff(:)=HUGE(var)
1236  !$OMP END MASTER
1237  !$OMP BARRIER
1238 
1239  !$OMP CRITICAL     
1240    DO i=1,dimsize
1241      Buff(i)=MIN(Buff(i),VarIn(i))
1242    ENDDO
1243  !$OMP END CRITICAL
1244  !$OMP BARRIER 
1245 
1246  !$OMP MASTER
1247    DO i=1,dimsize
1248      VarOut(i)=Buff(i)
1249    ENDDO
1250  !$OMP END MASTER
1251  !$OMP BARRIER
1252 
1253  END SUBROUTINE reduce_min_omp_rgen
1254
1255
1256END MODULE mod_phys_lmdz_omp_transfert
Note: See TracBrowser for help on using the repository browser.