source: branches/publications/ORCHIDEE_2.2_r7266/ORCHIDEE/src_parallel/mod_orchidee_para_var.F90 @ 7541

Last change on this file since 7541 was 7541, checked in by fabienne.maignan, 2 years ago
  1. Zhang publication on coupling factor
File size: 10.6 KB
Line 
1! ================================================================================================================================
2!  MODULE       : mod_orchidee_para_var
3!
4!  CONTACT      : orchidee-help _at_ listes.ipsl.fr
5!
6!  LICENCE      : IPSL (2006)
7!  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
8!
9!>\BRIEF   This module contains public variables for parallelization and domain decomposition.
10!!
11!!\n DESCRIPTION:  This module contains public variables for parallelization and domain decomposition.
12!!                 The variables in here can be used by USE mod_orchidee_para. Only at some specific cases it it needed to
13!!                 use this module directly to avoid depencendy problems.
14!!
15!! RECENT CHANGE(S): None
16!!
17!! REFERENCE(S) : None
18!!
19!! SVN          :
20!! $HeadURL: svn://forge.ipsl.jussieu.fr/orchidee/branches/ORCHIDEE_2_2/ORCHIDEE/src_parallel/mod_orchidee_para_var.F90 $
21!! $Date: 2019-11-04 10:22:17 +0100 (Mon, 04 Nov 2019) $
22!! $Revision: 6289 $
23!! \n
24!_ ================================================================================================================================
25
26MODULE mod_orchidee_para_var
27
28  USE defprec
29
30  !
31  ! 1. Variables related to the MPI parallelization and the MPI horizontal domain decompostion.
32  !    These variables were previously declared in mod_orchidee_mpi_data
33  !
34
35  ! Unit for output messages
36  INTEGER(i_std), SAVE :: numout = 6
37  !$OMP THREADPRIVATE(numout)
38
39  INTEGER,SAVE :: mpi_size                                            !! Number of parallel processes
40  INTEGER,SAVE :: mpi_rank                                            !! my rank num
41  INTEGER,SAVE :: mpi_rank_root                                       !! rank of MPI root
42  LOGICAL,SAVE :: is_mpi_root                                         !! Only MPI root proc is true
43  LOGICAL,SAVE :: is_ok_mpi                                           
44
45  INTEGER(i_std),SAVE              :: nbp_mpi                         !! number of local continental points in each mpi group
46  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: nbp_mpi_para
47  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: nbp_mpi_para_begin
48  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: nbp_mpi_para_end 
49
50  INTEGER,SAVE :: nbp_mpi_begin
51  INTEGER,SAVE :: nbp_mpi_end
52
53  ! i x j 2D points (not land points) index
54  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb           ! Number of 2D points for each mpi_rank block
55  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin        ! First 2D point for each mpi_rank block
56  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end          ! Last 2D point for each mpi_rank block
57  ! i 2D index
58  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin        ! First i index of 2D point for each mpi_rank block
59  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end          ! Last i index of 2D point for each mpi_rank block
60  ! j 2D index
61  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb           ! Number of complete j lines for each mpi_rank block
62  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin        ! First j index of 2D point for each mpi_rank block
63  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end          ! Last j index of 2D point for each mpi_rank block
64
65  INTEGER,SAVE :: ii_begin
66  INTEGER,SAVE :: ii_end
67  INTEGER,SAVE :: jj_begin
68  INTEGER,SAVE :: jj_end
69  INTEGER,SAVE :: jj_nb
70  INTEGER,SAVE :: ij_begin
71  INTEGER,SAVE :: ij_end
72  INTEGER,SAVE :: ij_nb
73
74  INTEGER,SAVE :: MPI_COMM_ORCH
75  INTEGER,SAVE :: MPI_REAL_ORCH
76  INTEGER,SAVE :: MPI_INT_ORCH
77  LOGICAL, SAVE :: cpl_lmdz
78
79  INTEGER,SAVE,ALLOCATABLE :: kindex_mpi (:)
80  INTEGER,SAVE             :: offset_mpi
81
82
83  !
84  ! 2. Variables related to the OpenMP paralelization and OpenMP horizontal domain decomposition
85  !    These variables were previously declared in mod_orchidee_omp_data
86  !
87
88  ! Check all OpenMP transferts in ORCHIDEE : use this flag to debug synchronism with OpenMP
89  LOGICAL, PARAMETER :: check_all_transfert=.FALSE.
90
91
92  INTEGER(i_std),SAVE :: omp_size
93  INTEGER(i_std),SAVE :: omp_rank
94  LOGICAL,SAVE :: is_omp_root                  !! Only OpenMP master thread is true
95  LOGICAL,SAVE :: is_ok_omp
96  !$OMP  THREADPRIVATE(omp_rank,is_omp_root)
97
98  INTEGER(i_std),SAVE,DIMENSION(:),ALLOCATABLE :: nbp_omp_para_nb
99  INTEGER(i_std),SAVE,DIMENSION(:),ALLOCATABLE :: nbp_omp_para_begin
100  INTEGER(i_std),SAVE,DIMENSION(:),ALLOCATABLE :: nbp_omp_para_end   
101
102  INTEGER(i_std),SAVE,DIMENSION(:),ALLOCATABLE :: ij_omp_para_nb
103  INTEGER(i_std),SAVE,DIMENSION(:),ALLOCATABLE :: ij_omp_para_begin
104  INTEGER(i_std),SAVE,DIMENSION(:),ALLOCATABLE :: ij_omp_para_end   
105
106  INTEGER(i_std),SAVE :: nbp_omp
107  INTEGER(i_std),SAVE :: nbp_omp_begin
108  INTEGER(i_std),SAVE :: nbp_omp_end
109  INTEGER(i_std),SAVE :: offset_omp
110
111  INTEGER(i_std),SAVE :: ij_omp_nb
112  INTEGER(i_std),SAVE :: ij_omp_begin
113  INTEGER(i_std),SAVE :: ij_omp_end
114  !$OMP  THREADPRIVATE(nbp_omp,nbp_omp_begin,nbp_omp_end,offset_omp)
115  !$OMP  THREADPRIVATE(ij_omp_nb,ij_omp_begin,ij_omp_end)
116
117  ! Flag for each OMP process for ORCHIDEE to verify synchronization if function Synchro_Omp is used
118  LOGICAL,SAVE,ALLOCATABLE :: proc_synchro_omp(:)
119
120  INTEGER, SAVE :: numout_omp = -1
121  !$OMP  THREADPRIVATE(numout_omp)
122
123  ! For debugging OpenMP processes : id of OMP function for each task.
124  ! If one task is not in the same function, we can see it.
125  INTEGER(i_std),SAVE,ALLOCATABLE,DIMENSION(:) :: omp_function
126  ! It is not SHARED.
127  ! List of values :
128  CHARACTER(LEN=28), PARAMETER :: omp_fct_name(-1:72) = (/ &
129       "Initialization              ", &
130       "Synchro_Omp                 ", &
131       "check_buffer_i              ", &
132       "check_buffer_r              ", &
133       "check_buffer_l              ", &
134       "bcast_omp_c                 ", &
135       "bcast_omp_i                 ", &
136       "bcast_omp_i1                ", &
137       "bcast_omp_i2                ", &
138       "bcast_omp_i3                ", &
139       "bcast_omp_i4                ", &
140       "bcast_omp_r                 ", &
141       "bcast_omp_r1                ", &
142       "bcast_omp_r2                ", &
143       "bcast_omp_r3                ", &
144       "bcast_omp_r4                ", &
145       "bcast_omp_l                 ", &
146       "bcast_omp_l1                ", &
147       "bcast_omp_l2                ", &
148       "bcast_omp_l3                ", &
149       "bcast_omp_l4                ", &
150       "scatter_omp_i               ", &
151       "scatter_omp_i1              ", &
152       "scatter_omp_i2              ", &
153       "scatter_omp_i3              ", &
154       "scatter_omp_r               ", &
155       "scatter_omp_r1              ", &
156       "scatter_omp_r2              ", &
157       "scatter_omp_r3              ", &
158       "scatter_omp_l               ", &
159       "scatter_omp_l1              ", &
160       "scatter_omp_l2              ", &
161       "scatter_omp_l3              ", &
162       "gather_omp_i0               ", &
163       "gather_omp_i                ", &
164       "gather_omp_i1               ", &
165       "gather_omp_i2               ", &
166       "gather_omp_i3               ", &
167       "gather_omp_r0               ", &
168       "gather_omp_r                ", &
169       "gather_omp_r1               ", &
170       "gather_omp_r2               ", &
171       "gather_omp_r3               ", &
172       "gather_omp_l0               ", &
173       "gather_omp_l                ", &
174       "gather_omp_l1               ", &
175       "gather_omp_l2               ", &
176       "gather_omp_l3               ", &
177       "reduce_sum_omp_i            ", &
178       "reduce_sum_omp_i1           ", &
179       "reduce_sum_omp_i2           ", &
180       "reduce_sum_omp_i3           ", &
181       "reduce_sum_omp_i4           ", &
182       "reduce_sum_omp_r            ", &
183       "reduce_sum_omp_r1           ", &
184       "reduce_sum_omp_r2           ", &
185       "reduce_sum_omp_r3           ", &
186       "reduce_sum_omp_r4           ", &
187       "orch_bcast_omp_cgen         ", &
188       "orch_bcast_omp_igen         ", &
189       "orch_bcast_omp_rgen         ", &
190       "orch_bcast_omp_lgen         ", &
191       "orch_scatter_omp_igen       ", &
192       "orch_scatter_omp_rgen       ", &
193       "orch_scatter_omp_lgen       ", &
194       "orch_gather_omp_simple_igen ", &
195       "orch_gather_omp_igen        ", &
196       "orch_gather_omp_simple_rgen ", &
197       "orch_gather_omp_rgen        ", &
198       "orch_gather_omp_simple_lgen ", &
199       "orch_gather_omp_lgen        ", &
200       "orch_reduce_sum_omp_igen    ", &
201       "orch_reduce_sum_omp_rgen    ", &
202       "check_buffer_c              " /)
203
204  ! Previous value for own omp_function
205  INTEGER, SAVE :: omp_previous
206  !$OMP  THREADPRIVATE(omp_previous)
207
208  !
209  !! 3. Variables previously declared in mod_orchide_para
210  !
211
212  INTEGER,SAVE :: nbp_loc                                             !! number of local continental points
213  !$OMP THREADPRIVATE(nbp_loc)
214  INTEGER,SAVE :: offset
215  !$OMP THREADPRIVATE(offset)
216
217  LOGICAL,SAVE :: is_root_prc = .FALSE.                               !! Only root proc for MPI and OpenMP is true
218  !$OMP THREADPRIVATE(is_root_prc)
219  !
220  !! Global grid arrays used by stomate and sechiba and available on each processor
221  !! They need to be broadcasted after initilisation of the parallelisation
222  !-
223  ! Dimensions
224  INTEGER(i_std),SAVE              :: iim_g                           !! Dimension of global fields for longitude
225  INTEGER(i_std),SAVE              :: jjm_g                           !! Dimension of global fields for latitude
226  INTEGER(i_std),SAVE              :: nbp_glo                         !! number of global continental points
227  ! Fields
228  !! index of land points on the 2D map
229  INTEGER(i_std),ALLOCATABLE,DIMENSION(:),SAVE   :: index_g
230  !-
231  !! indices of the 4 neighbours of each grid point (1=N, 2=E, 3=S, 4=W)
232  INTEGER(i_std),ALLOCATABLE,DIMENSION(:,:),SAVE :: neighbours_g
233  !-
234  ! Heading of the direction out of the grid box either through the vertex
235  ! of the mid-segment of the polygon.
236  !
237  REAL(r_std), ALLOCATABLE, DIMENSION(:,:), SAVE      :: headings_g
238  !
239  ! Length of segments of the polygon.
240  !
241  REAL(r_std), ALLOCATABLE, DIMENSION(:,:), SAVE      :: seglength_g
242  !
243  ! Area of the grid box
244  !
245  REAL(r_std), ALLOCATABLE, DIMENSION(:), SAVE        :: area_g
246  !
247  ! Coordinats of the vertices
248  !
249  REAL(r_std), ALLOCATABLE, DIMENSION(:,:,:), SAVE    :: corners_g
250  !
251  ! TEMPORARY !!!!!
252  !
253  !! resolution at each grid point in m (1=E-W, 2=N-S)
254  REAL(r_std),ALLOCATABLE,DIMENSION(:,:),SAVE    :: resolution_g 
255  !-
256  !! Geographical coordinates
257  REAL(r_std),ALLOCATABLE,DIMENSION(:,:),SAVE    :: lalo_g
258  ! Global grid, for all process
259  REAL(r_std), ALLOCATABLE, DIMENSION(:,:), SAVE     :: lon_g, lat_g
260  !-
261  !! Fraction of continents
262  REAL(r_std),ALLOCATABLE,DIMENSION(:),SAVE      :: contfrac_g 
263  !
264END MODULE mod_orchidee_para_var
Note: See TracBrowser for help on using the repository browser.