source: LMDZ5/trunk/libf/phy_common/mod_phys_lmdz_mpi_data.F90 @ 2326

Last change on this file since 2326 was 2326, checked in by Ehouarn Millour, 9 years ago

Further code reorganization: adding "phy_common", a directory which should contain routines common (wrt structural nature of the underlying code/grid) to all LMDZ-related physics packages.
EM

  • 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: 5.6 KB
Line 
1!
2!$Header$
3!
4MODULE mod_phys_lmdz_mpi_data
5  USE mod_const_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_root
38  LOGICAL,SAVE :: is_mpi_root
39  LOGICAL,SAVE :: is_using_mpi
40 
41 
42  LOGICAL,SAVE :: is_north_pole
43  LOGICAL,SAVE :: is_south_pole
44  INTEGER,SAVE :: COMM_LMDZ_PHY
45
46CONTAINS
47 
48  SUBROUTINE Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
49  USE mod_const_mpi, ONLY : COMM_LMDZ
50  IMPLICIT NONE
51    INTEGER,INTENT(in) :: iim
52    INTEGER,INTENT(in) :: jjp1
53    INTEGER,INTENT(in) :: nb_proc
54    INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
55   
56    INTEGER :: ierr
57    INTEGER :: klon_glo
58    INTEGER :: i
59   
60#ifdef CPP_MPI
61    is_using_mpi=.TRUE.
62#else
63    is_using_mpi=.FALSE.
64#endif
65   
66    if (iim.eq.1) then
67       klon_glo=1
68    else
69       klon_glo=iim*(jjp1-2)+2
70    endif
71   
72    COMM_LMDZ_PHY=COMM_LMDZ
73
74    IF (is_using_mpi) THEN   
75#ifdef CPP_MPI
76      CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr)   
77      CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr)
78#endif
79    ELSE
80      mpi_size=1
81      mpi_rank=0
82    ENDIF
83   
84    IF (mpi_rank == 0) THEN
85      mpi_root = 0
86      is_mpi_root = .true.
87    ENDIF
88   
89    IF (mpi_rank == 0) THEN
90      is_north_pole = .TRUE.
91    ELSE
92      is_north_pole = .FALSE.
93    ENDIF
94   
95    IF (mpi_rank == mpi_size-1) THEN
96      is_south_pole = .TRUE.
97    ELSE
98      is_south_pole = .FALSE.
99    ENDIF
100   
101    ALLOCATE(jj_para_nb(0:mpi_size-1))
102    ALLOCATE(jj_para_begin(0:mpi_size-1))
103    ALLOCATE(jj_para_end(0:mpi_size-1))
104   
105    ALLOCATE(ij_para_nb(0:mpi_size-1))
106    ALLOCATE(ij_para_begin(0:mpi_size-1))
107    ALLOCATE(ij_para_end(0:mpi_size-1))
108   
109    ALLOCATE(ii_para_begin(0:mpi_size-1))
110    ALLOCATE(ii_para_end(0:mpi_size-1))
111
112    ALLOCATE(klon_mpi_para_nb(0:mpi_size-1))
113    ALLOCATE(klon_mpi_para_begin(0:mpi_size-1))
114    ALLOCATE(klon_mpi_para_end(0:mpi_size-1))
115 
116     
117    klon_mpi_para_nb(0:mpi_size-1)=distrib(0:nb_proc-1)
118
119    DO i=0,mpi_size-1
120      IF (i==0) THEN
121        klon_mpi_para_begin(i)=1
122      ELSE
123        klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1
124      ENDIF
125        klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1
126    ENDDO
127
128
129    DO i=0,mpi_size-1
130     
131      IF (i==0) THEN
132        ij_para_begin(i) = 1
133      ELSE
134        ij_para_begin(i) = klon_mpi_para_begin(i)+iim-1
135      ENDIF
136
137      jj_para_begin(i) = (ij_para_begin(i)-1)/iim + 1
138      ii_para_begin(i) = MOD(ij_para_begin(i)-1,iim) + 1
139
140     
141      ij_para_end(i) = klon_mpi_para_end(i)+iim-1
142      jj_para_end(i) = (ij_para_end(i)-1)/iim + 1
143      ii_para_end(i) = MOD(ij_para_end(i)-1,iim) + 1
144
145
146      ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1
147      jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1
148         
149    ENDDO
150 
151    ii_begin = ii_para_begin(mpi_rank)
152    ii_end   = ii_para_end(mpi_rank)
153    jj_begin = jj_para_begin(mpi_rank)
154    jj_end   = jj_para_end(mpi_rank)
155    jj_nb    = jj_para_nb(mpi_rank)
156    ij_begin = ij_para_begin(mpi_rank)
157    ij_end   = ij_para_end(mpi_rank)
158    ij_nb    = ij_para_nb(mpi_rank)
159    klon_mpi_begin = klon_mpi_para_begin(mpi_rank)
160    klon_mpi_end   = klon_mpi_para_end(mpi_rank)
161    klon_mpi       = klon_mpi_para_nb(mpi_rank)
162   
163    CALL Print_module_data
164   
165  END SUBROUTINE Init_phys_lmdz_mpi_data
166
167  SUBROUTINE print_module_data
168  IMPLICIT NONE
169  INCLUDE "iniprint.h"
170 
171    WRITE(lunout,*) 'ii_begin =', ii_begin
172    WRITE(lunout,*) 'ii_end =', ii_end
173    WRITE(lunout,*) 'jj_begin =',jj_begin
174    WRITE(lunout,*) 'jj_end =', jj_end
175    WRITE(lunout,*) 'jj_nb =', jj_nb
176    WRITE(lunout,*) 'ij_begin =', ij_begin
177    WRITE(lunout,*) 'ij_end =', ij_end
178    WRITE(lunout,*) 'ij_nb =', ij_nb
179    WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin
180    WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end
181    WRITE(lunout,*) 'klon_mpi =', klon_mpi
182    WRITE(lunout,*) 'jj_para_nb =', jj_para_nb
183    WRITE(lunout,*) 'jj_para_begin =', jj_para_begin
184    WRITE(lunout,*) 'jj_para_end =', jj_para_end
185    WRITE(lunout,*) 'ii_para_begin =', ii_para_begin
186    WRITE(lunout,*) 'ii_para_end =', ii_para_end
187    WRITE(lunout,*) 'ij_para_nb =', ij_para_nb
188    WRITE(lunout,*) 'ij_para_begin =', ij_para_begin
189    WRITE(lunout,*) 'ij_para_end =', ij_para_end
190    WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb
191    WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin
192    WRITE(lunout,*) 'klon_mpi_para_end  =', klon_mpi_para_end
193    WRITE(lunout,*) 'mpi_rank =', mpi_rank
194    WRITE(lunout,*) 'mpi_size =', mpi_size
195    WRITE(lunout,*) 'mpi_root =', mpi_root
196    WRITE(lunout,*) 'is_mpi_root =', is_mpi_root
197    WRITE(lunout,*) 'is_north_pole =', is_north_pole
198    WRITE(lunout,*) 'is_south_pole =', is_south_pole
199    WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY
200 
201  END SUBROUTINE print_module_data
202 
203END MODULE mod_phys_lmdz_mpi_data
Note: See TracBrowser for help on using the repository browser.