source: LMDZ5/branches/LMDZ5-DOFOCO/libf/phylmd/mod_phys_lmdz_omp_data.F90 @ 4962

Last change on this file since 4962 was 1575, checked in by jghattas, 13 years ago
  • Added suffix _mpi_rank to lmdz.out text file. Each processus now write into seperate file but only if lunout/=6 (lunout is set in run.def).
  • Change some print* into write(lunout,*)
  • phytrac.F90 : always include ini_histrac and write_histrac. The file histrac.nc is written if ecrit_tra> 0 (set in physiq.def). Change default value of ecrit_tra into 0.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1!
2!$Id: mod_phys_lmdz_omp_data.F90 1575 2011-09-21 13:57:48Z lguez $
3!
4MODULE mod_phys_lmdz_omp_data
5
6  INTEGER,SAVE :: omp_size
7  INTEGER,SAVE :: omp_rank
8  LOGICAL,SAVE :: is_omp_root
9  LOGICAL,SAVE :: is_using_omp
10 
11  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
12  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
13  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end   
14 
15  INTEGER,SAVE :: klon_omp
16  INTEGER,SAVE :: klon_omp_begin
17  INTEGER,SAVE :: klon_omp_end
18!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,klon_omp_begin,klon_omp_end)
19
20CONTAINS
21 
22  SUBROUTINE Init_phys_lmdz_omp_data(klon_mpi)
23    USE dimphy
24    IMPLICIT NONE
25    INTEGER, INTENT(in) :: klon_mpi
26
27    INTEGER :: i
28
29    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
30    CHARACTER (LEN=80) :: abort_message
31
32
33#ifdef CPP_OMP   
34    INTEGER :: OMP_GET_NUM_THREADS
35    EXTERNAL OMP_GET_NUM_THREADS
36    INTEGER :: OMP_GET_THREAD_NUM
37    EXTERNAL OMP_GET_THREAD_NUM
38#endif 
39
40#ifdef CPP_OMP
41!$OMP MASTER
42        is_using_omp=.TRUE.
43        omp_size=OMP_GET_NUM_THREADS()
44!$OMP END MASTER
45        omp_rank=OMP_GET_THREAD_NUM()   
46#else   
47    is_using_omp=.FALSE.
48    omp_size=1
49    omp_rank=0
50#endif
51
52   is_omp_root=.FALSE.
53!$OMP MASTER
54   IF (omp_rank==0) THEN
55     is_omp_root=.TRUE.
56   ELSE
57     abort_message = 'ANORMAL : OMP_MASTER /= 0'
58     CALL abort_gcm (modname,abort_message,1)
59   ENDIF
60!$OMP END MASTER
61
62
63!$OMP MASTER
64    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
65    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
66    ALLOCATE(klon_omp_para_end(0:omp_size-1))
67   
68    DO i=0,omp_size-1
69      klon_omp_para_nb(i)=klon_mpi/omp_size
70      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
71    ENDDO
72   
73    klon_omp_para_begin(0) = 1
74    klon_omp_para_end(0) = klon_omp_para_nb(0)
75   
76    DO i=1,omp_size-1
77      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
78      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
79    ENDDO
80!$OMP END MASTER
81!$OMP BARRIER
82   
83    klon_omp=klon_omp_para_nb(omp_rank)
84    klon_omp_begin=klon_omp_para_begin(omp_rank)
85    klon_omp_end=klon_omp_para_end(omp_rank)
86   
87    CALL Print_module_data
88   
89  END SUBROUTINE Init_phys_lmdz_omp_data
90
91  SUBROUTINE Print_module_data
92  IMPLICIT NONE
93  INCLUDE "iniprint.h"
94
95!$OMP CRITICAL 
96  WRITE(lunout,*)'--------> TASK ',omp_rank
97  WRITE(lunout,*)'omp_size =',omp_size
98  WRITE(lunout,*)'omp_rank =',omp_rank
99  WRITE(lunout,*)'is_omp_root =',is_omp_root
100  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
101  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
102  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end   
103  WRITE(lunout,*)'klon_omp =',klon_omp
104  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
105  WRITE(lunout,*)'klon_omp_end =',klon_omp_end   
106!$OMP END CRITICAL
107
108  END SUBROUTINE Print_module_data
109END MODULE mod_phys_lmdz_omp_data
Note: See TracBrowser for help on using the repository browser.