source: trunk/LMDZ.GENERIC/libf/dynlonlat_phylonlat/mod_phys_lmdz_mpi_data.F90 @ 1470

Last change on this file since 1470 was 1403, checked in by emillour, 10 years ago

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

EM

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