source: LMDZ6/trunk/libf/phy_common/mod_phys_lmdz_mpi_data.F90 @ 5206

Last change on this file since 5206 was 4602, checked in by yann meurdesoif, 17 months ago

Bug fix introduced in rev 4600 (is_using_mpi was undefined)

YM

  • 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 Id
File size: 6.4 KB
Line 
1!
2!$Id: mod_phys_lmdz_mpi_data.F90 4602 2023-07-03 12:54:38Z fairhead $
3!
4MODULE mod_phys_lmdz_mpi_data
5  USE lmdz_mpi
6
7  INTEGER,SAVE :: ii_begin
8  INTEGER,SAVE :: ii_end
9  INTEGER,SAVE :: jj_begin
10  INTEGER,SAVE :: jj_end
11  INTEGER,SAVE :: jj_nb
12  INTEGER,SAVE :: ij_begin
13  INTEGER,SAVE :: ij_end
14  INTEGER,SAVE :: ij_nb
15  INTEGER,SAVE :: klon_mpi_begin
16  INTEGER,SAVE :: klon_mpi_end
17  INTEGER,SAVE :: klon_mpi
18 
19  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb
20  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin
21  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end
22
23  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin
24  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end
25
26  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb
27  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin
28  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end
29
30  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_nb
31  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin
32  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end
33
34 
35  INTEGER,SAVE :: mpi_rank
36  INTEGER,SAVE :: mpi_size
37  INTEGER,SAVE :: mpi_master
38  LOGICAL,SAVE :: is_mpi_root
39  LOGICAL,SAVE :: is_using_mpi
40 
41 
42  LOGICAL,SAVE :: is_north_pole_dyn
43  LOGICAL,SAVE :: is_south_pole_dyn
44  INTEGER,SAVE :: COMM_LMDZ_PHY
45  INTEGER,SAVE :: MPI_REAL_LMDZ   ! MPI_REAL8
46
47CONTAINS
48 
49  SUBROUTINE init_phys_lmdz_mpi_data(nbp, nbp_lon, nbp_lat, nbp_lev, grid_type, nvertex, communicator)
50  USE lmdz_mpi
51  IMPLICIT NONE
52    INTEGER,INTENT(IN) :: nbp
53    INTEGER,INTENT(IN) :: nbp_lon
54    INTEGER,INTENT(IN) :: nbp_lat
55    INTEGER,INTENT(IN) :: nbp_lev
56    INTEGER,INTENT(IN) :: communicator
57    INTEGER,INTENT(IN) :: grid_type
58    INTEGER,INTENT(IN) :: nvertex
59   
60    INTEGER,ALLOCATABLE :: distrib(:)
61    INTEGER :: ierr
62    INTEGER :: klon_glo
63    INTEGER :: i
64   
65    is_using_mpi = using_mpi
66   
67    if ((nbp_lon.eq.1).and.(nbp_lat.eq.1)) then ! running 1D column model
68       klon_glo=1
69    else
70    ! The usual global physics grid: 1 point for each pole and nbp_lon points
71    ! for all other latitudes
72       klon_glo=nbp_lon*(nbp_lat-2)+2
73    endif
74   
75    COMM_LMDZ_PHY=communicator
76
77    IF (is_using_mpi) THEN   
78      MPI_REAL_LMDZ=MPI_REAL8
79      CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr)   
80      CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr)
81    ELSE
82      mpi_size=1
83      mpi_rank=0
84    ENDIF
85   
86    ALLOCATE(distrib(0:mpi_size-1))
87
88    IF (is_using_mpi) THEN   
89      CALL MPI_ALLGATHER(nbp,1,MPI_INTEGER,distrib,1,MPI_INTEGER,COMM_LMDZ_PHY,ierr)
90    ELSE
91     distrib(:)=nbp
92    ENDIF
93
94
95    IF (mpi_rank == 0) THEN
96      mpi_master = 0
97      is_mpi_root = .true.
98    ENDIF
99   
100    IF (mpi_rank == 0) THEN
101      is_north_pole_dyn = .TRUE.
102    ELSE
103      is_north_pole_dyn = .FALSE.
104    ENDIF
105   
106    IF (mpi_rank == mpi_size-1) THEN
107      is_south_pole_dyn = .TRUE.
108    ELSE
109      is_south_pole_dyn = .FALSE.
110    ENDIF
111   
112    ALLOCATE(jj_para_nb(0:mpi_size-1))
113    ALLOCATE(jj_para_begin(0:mpi_size-1))
114    ALLOCATE(jj_para_end(0:mpi_size-1))
115   
116    ALLOCATE(ij_para_nb(0:mpi_size-1))
117    ALLOCATE(ij_para_begin(0:mpi_size-1))
118    ALLOCATE(ij_para_end(0:mpi_size-1))
119   
120    ALLOCATE(ii_para_begin(0:mpi_size-1))
121    ALLOCATE(ii_para_end(0:mpi_size-1))
122
123    ALLOCATE(klon_mpi_para_nb(0:mpi_size-1))
124    ALLOCATE(klon_mpi_para_begin(0:mpi_size-1))
125    ALLOCATE(klon_mpi_para_end(0:mpi_size-1))
126 
127     
128    klon_mpi_para_nb(0:mpi_size-1)=distrib(0:mpi_size-1)
129
130    DO i=0,mpi_size-1
131      IF (i==0) THEN
132        klon_mpi_para_begin(i)=1
133      ELSE
134        klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1
135      ENDIF
136        klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1
137    ENDDO
138
139
140    DO i=0,mpi_size-1
141     
142      IF (i==0) THEN
143        ij_para_begin(i) = 1
144      ELSE
145        ij_para_begin(i) = klon_mpi_para_begin(i)+nbp_lon-1
146      ENDIF
147
148      jj_para_begin(i) = (ij_para_begin(i)-1)/nbp_lon + 1
149      ii_para_begin(i) = MOD(ij_para_begin(i)-1,nbp_lon) + 1
150
151     
152      ij_para_end(i) = klon_mpi_para_end(i)+nbp_lon-1
153      jj_para_end(i) = (ij_para_end(i)-1)/nbp_lon + 1
154      ii_para_end(i) = MOD(ij_para_end(i)-1,nbp_lon) + 1
155
156
157      ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1
158      jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1
159         
160    ENDDO
161 
162    ii_begin = ii_para_begin(mpi_rank)
163    ii_end   = ii_para_end(mpi_rank)
164    jj_begin = jj_para_begin(mpi_rank)
165    jj_end   = jj_para_end(mpi_rank)
166    jj_nb    = jj_para_nb(mpi_rank)
167    ij_begin = ij_para_begin(mpi_rank)
168    ij_end   = ij_para_end(mpi_rank)
169    ij_nb    = ij_para_nb(mpi_rank)
170    klon_mpi_begin = klon_mpi_para_begin(mpi_rank)
171    klon_mpi_end   = klon_mpi_para_end(mpi_rank)
172    klon_mpi       = klon_mpi_para_nb(mpi_rank)
173   
174    CALL Print_module_data
175
176#ifdef INCA
177       CALL init_inca_para( &
178            nbp_lon,nbp_lat,nbp_lev,klon_glo,mpi_size, &
179            distrib,nvertex, grid_type,communicator)
180#endif
181   
182  END SUBROUTINE Init_phys_lmdz_mpi_data
183
184  SUBROUTINE print_module_data
185  USE print_control_mod, ONLY: lunout
186  IMPLICIT NONE
187!  INCLUDE "iniprint.h"
188 
189    WRITE(lunout,*) 'ii_begin =', ii_begin
190    WRITE(lunout,*) 'ii_end =', ii_end
191    WRITE(lunout,*) 'jj_begin =',jj_begin
192    WRITE(lunout,*) 'jj_end =', jj_end
193    WRITE(lunout,*) 'jj_nb =', jj_nb
194    WRITE(lunout,*) 'ij_begin =', ij_begin
195    WRITE(lunout,*) 'ij_end =', ij_end
196    WRITE(lunout,*) 'ij_nb =', ij_nb
197    WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin
198    WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end
199    WRITE(lunout,*) 'klon_mpi =', klon_mpi
200    WRITE(lunout,*) 'jj_para_nb =', jj_para_nb
201    WRITE(lunout,*) 'jj_para_begin =', jj_para_begin
202    WRITE(lunout,*) 'jj_para_end =', jj_para_end
203    WRITE(lunout,*) 'ii_para_begin =', ii_para_begin
204    WRITE(lunout,*) 'ii_para_end =', ii_para_end
205    WRITE(lunout,*) 'ij_para_nb =', ij_para_nb
206    WRITE(lunout,*) 'ij_para_begin =', ij_para_begin
207    WRITE(lunout,*) 'ij_para_end =', ij_para_end
208    WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb
209    WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin
210    WRITE(lunout,*) 'klon_mpi_para_end  =', klon_mpi_para_end
211    WRITE(lunout,*) 'mpi_rank =', mpi_rank
212    WRITE(lunout,*) 'mpi_size =', mpi_size
213    WRITE(lunout,*) 'mpi_master =', mpi_master
214    WRITE(lunout,*) 'is_mpi_root =', is_mpi_root
215    WRITE(lunout,*) 'is_north_pole =', is_north_pole_dyn
216    WRITE(lunout,*) 'is_south_pole =', is_south_pole_dyn
217    WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY
218 
219  END SUBROUTINE print_module_data
220 
221END MODULE mod_phys_lmdz_mpi_data
Note: See TracBrowser for help on using the repository browser.