source: LMDZ5/trunk/libf/phylmd/mod_phys_lmdz_omp_data.F90 @ 2183

Last change on this file since 2183 was 1907, checked in by lguez, 11 years ago

Added a copyright property to every file of the distribution, except
for the fcm files (which have their own copyright). Use svn propget on
a file to see the copyright. For instance:

$ svn propget copyright libf/phylmd/physiq.F90
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

Also added the files defining the CeCILL version 2 license, in French
and English, at the top of the LMDZ tree.

  • 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: 2.8 KB
Line 
1!
2!$Id: mod_phys_lmdz_omp_data.F90 1907 2013-11-26 13:10:46Z acozic $
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.