source: branches/publications/ORCHIDEE-MICT-BIOENERGY_r7298/src_parallel/mod_orchidee_para_var.F90 @ 8076

Last change on this file since 8076 was 7297, checked in by wei.li, 3 years ago

updated code for publication, 2021,9,25

File size: 10.4 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-MICT/ORCHIDEE/src_parallel/mod_orchidee_para_var.F90 $
21!! $Date: 2017-10-26 15:35:04 +0200 (Thu, 26 Oct 2017) $
22!! $Revision: 4719 $
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
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 :: nbp_omp
103  INTEGER(i_std),SAVE :: nbp_omp_begin
104  INTEGER(i_std),SAVE :: nbp_omp_end
105  INTEGER(i_std),SAVE :: offset_omp
106  !$OMP  THREADPRIVATE(nbp_omp,nbp_omp_begin,nbp_omp_end,offset_omp)
107
108  ! Flag for each OMP process for ORCHIDEE to verify synchronization if function Synchro_Omp is used
109  LOGICAL,SAVE,ALLOCATABLE :: proc_synchro_omp(:)
110
111  INTEGER, SAVE :: numout_omp = -1
112  !$OMP  THREADPRIVATE(numout_omp)
113
114  ! For debugging OpenMP processes : id of OMP function for each task.
115  ! If one task is not in the same function, we can see it.
116  INTEGER(i_std),SAVE,ALLOCATABLE,DIMENSION(:) :: omp_function
117  ! It is not SHARED.
118  ! List of values :
119  CHARACTER(LEN=28), PARAMETER :: omp_fct_name(-1:72) = (/ &
120       "Initialization              ", &
121       "Synchro_Omp                 ", &
122       "check_buffer_i              ", &
123       "check_buffer_r              ", &
124       "check_buffer_l              ", &
125       "bcast_omp_c                 ", &
126       "bcast_omp_i                 ", &
127       "bcast_omp_i1                ", &
128       "bcast_omp_i2                ", &
129       "bcast_omp_i3                ", &
130       "bcast_omp_i4                ", &
131       "bcast_omp_r                 ", &
132       "bcast_omp_r1                ", &
133       "bcast_omp_r2                ", &
134       "bcast_omp_r3                ", &
135       "bcast_omp_r4                ", &
136       "bcast_omp_l                 ", &
137       "bcast_omp_l1                ", &
138       "bcast_omp_l2                ", &
139       "bcast_omp_l3                ", &
140       "bcast_omp_l4                ", &
141       "scatter_omp_i               ", &
142       "scatter_omp_i1              ", &
143       "scatter_omp_i2              ", &
144       "scatter_omp_i3              ", &
145       "scatter_omp_r               ", &
146       "scatter_omp_r1              ", &
147       "scatter_omp_r2              ", &
148       "scatter_omp_r3              ", &
149       "scatter_omp_l               ", &
150       "scatter_omp_l1              ", &
151       "scatter_omp_l2              ", &
152       "scatter_omp_l3              ", &
153       "gather_omp_i0               ", &
154       "gather_omp_i                ", &
155       "gather_omp_i1               ", &
156       "gather_omp_i2               ", &
157       "gather_omp_i3               ", &
158       "gather_omp_r0               ", &
159       "gather_omp_r                ", &
160       "gather_omp_r1               ", &
161       "gather_omp_r2               ", &
162       "gather_omp_r3               ", &
163       "gather_omp_l0               ", &
164       "gather_omp_l                ", &
165       "gather_omp_l1               ", &
166       "gather_omp_l2               ", &
167       "gather_omp_l3               ", &
168       "reduce_sum_omp_i            ", &
169       "reduce_sum_omp_i1           ", &
170       "reduce_sum_omp_i2           ", &
171       "reduce_sum_omp_i3           ", &
172       "reduce_sum_omp_i4           ", &
173       "reduce_sum_omp_r            ", &
174       "reduce_sum_omp_r1           ", &
175       "reduce_sum_omp_r2           ", &
176       "reduce_sum_omp_r3           ", &
177       "reduce_sum_omp_r4           ", &
178       "orch_bcast_omp_cgen         ", &
179       "orch_bcast_omp_igen         ", &
180       "orch_bcast_omp_rgen         ", &
181       "orch_bcast_omp_lgen         ", &
182       "orch_scatter_omp_igen       ", &
183       "orch_scatter_omp_rgen       ", &
184       "orch_scatter_omp_lgen       ", &
185       "orch_gather_omp_simple_igen ", &
186       "orch_gather_omp_igen        ", &
187       "orch_gather_omp_simple_rgen ", &
188       "orch_gather_omp_rgen        ", &
189       "orch_gather_omp_simple_lgen ", &
190       "orch_gather_omp_lgen        ", &
191       "orch_reduce_sum_omp_igen    ", &
192       "orch_reduce_sum_omp_rgen    ", &
193       "check_buffer_c              " /)
194
195  ! Previous value for own omp_function
196  INTEGER, SAVE :: omp_previous
197  !$OMP  THREADPRIVATE(omp_previous)
198
199  !
200  !! 3. Variables previously declared in mod_orchide_para
201  !
202
203  INTEGER,SAVE :: nbp_loc                                             !! number of local continental points
204  !$OMP THREADPRIVATE(nbp_loc)
205  INTEGER,SAVE :: offset
206  !$OMP THREADPRIVATE(offset)
207
208  LOGICAL,SAVE :: is_root_prc = .FALSE.                               !! Only root proc for MPI and OpenMP is true
209  !$OMP THREADPRIVATE(is_root_prc)
210  !
211  !! Global grid arrays used by stomate and sechiba and available on each processor
212  !! They need to be broadcasted after initilisation of the parallelisation
213  !-
214  ! Dimensions
215  INTEGER(i_std),SAVE              :: iim_g                           !! Dimension of global fields for longitude
216  INTEGER(i_std),SAVE              :: jjm_g                           !! Dimension of global fields for latitude
217  INTEGER(i_std),SAVE              :: nbp_glo                         !! number of global continental points
218  ! Fields
219  !! index of land points on the 2D map
220  INTEGER(i_std),ALLOCATABLE,DIMENSION(:),SAVE   :: index_g
221  !-
222  !! indices of the 4 neighbours of each grid point (1=N, 2=E, 3=S, 4=W)
223  INTEGER(i_std),ALLOCATABLE,DIMENSION(:,:),SAVE :: neighbours_g
224  !-
225  ! Heading of the direction out of the grid box either through the vertex
226  ! of the mid-segment of the polygon.
227  !
228  REAL(r_std), ALLOCATABLE, DIMENSION(:,:), SAVE      :: headings_g
229  !
230  ! Length of segments of the polygon.
231  !
232  REAL(r_std), ALLOCATABLE, DIMENSION(:,:), SAVE      :: seglength_g
233  !
234  ! Area of the grid box
235  !
236  REAL(r_std), ALLOCATABLE, DIMENSION(:), SAVE        :: area_g
237  !
238  ! Coordinats of the vertices
239  !
240  REAL(r_std), ALLOCATABLE, DIMENSION(:,:,:), SAVE    :: corners_g
241  !
242  ! TEMPORARY !!!!!
243  !
244  !! resolution at each grid point in m (1=E-W, 2=N-S)
245  REAL(r_std),ALLOCATABLE,DIMENSION(:,:),SAVE    :: resolution_g 
246  !-
247  !! Geographical coordinates
248  REAL(r_std),ALLOCATABLE,DIMENSION(:,:),SAVE    :: lalo_g
249  ! Global grid, for all process
250  REAL(r_std), ALLOCATABLE, DIMENSION(:,:), SAVE     :: lon_g, lat_g
251  !-
252  !! Fraction of continents
253  REAL(r_std),ALLOCATABLE,DIMENSION(:),SAVE      :: contfrac_g 
254  !-
255  !!
256  !
257  ! ALLREDUCE available operations
258  !
259  INTEGER(i_std), PARAMETER :: ORCH_SUM=1
260  INTEGER(i_std), PARAMETER :: ORCH_MAX=2
261  INTEGER(i_std), PARAMETER :: ORCH_MIN=3
262  !
263END MODULE mod_orchidee_para_var
Note: See TracBrowser for help on using the repository browser.