LMDZ
sumplatb_mod.F90
Go to the documentation of this file.
2 CONTAINS
3 SUBROUTINE sumplatb(KDGSA,KDGL,KPROCA,KLOENG,LDSPLIT,&
4  &kmediap,krestm,kindic,klast)
5 
6 !**** *SUMPLATB * - Routine to initialize parallel environment
7 
8 ! Purpose.
9 ! --------
10 
11 
12 !** Interface.
13 ! ----------
14 ! *CALL* *SUMPLATB *
15 
16 ! Explicit arguments - input :
17 ! --------------------
18 ! KDGSA -first latitude (grid-space)
19 ! (may be different from NDGSAG)
20 ! KDGL -last latitude
21 ! KPROCA -number of processors in A direction
22 ! KLOENG -actual number of longitudes per latitude.
23 ! LDSPLIT -true for latitudes shared between sets
24 
25 ! Explicit arguments - output:
26 ! --------------------
27 ! KMEDIAP -mean number of grid points per PE
28 ! KRESTM -number of PEs with one extra point
29 ! KINDIC -intermediate quantity for 'sumplat'
30 ! KLAST -intermediate quantity for 'sumplat'
31 
32 ! Implicit arguments :
33 ! --------------------
34 
35 
36 ! Method.
37 ! -------
38 ! See documentation
39 
40 ! Externals. NONE.
41 ! ----------
42 
43 ! Reference.
44 ! ----------
45 ! ECMWF Research Department documentation of the IFS
46 
47 ! Author.
48 ! -------
49 ! K. YESSAD (after old version of sumplat.F).
50 
51 ! Modifications.
52 ! --------------
53 ! Original : 98-12-07
54 ! ------------------------------------------------------------------
55 
56 
57 USE parkind1 ,ONLY : jpim ,jprb
58 
60 
61 IMPLICIT NONE
62 
63 
64 ! * DUMMY:
65 INTEGER(KIND=JPIM),INTENT(IN) :: KDGSA
66 INTEGER(KIND=JPIM),INTENT(IN) :: KDGL
67 INTEGER(KIND=JPIM),INTENT(IN) :: KPROCA
68 INTEGER(KIND=JPIM),INTENT(IN) :: KLOENG(kdgsa:kdgl)
69 LOGICAL,INTENT(IN) :: LDSPLIT
70 INTEGER(KIND=JPIM),INTENT(OUT) :: KMEDIAP
71 INTEGER(KIND=JPIM),INTENT(OUT) :: KRESTM
72 INTEGER(KIND=JPIM),INTENT(OUT) :: KINDIC(kproca)
73 INTEGER(KIND=JPIM),INTENT(OUT) :: KLAST(kproca)
74 
75 ! * LOCAL:
76 INTEGER(KIND=JPIM) :: IPP1(kproca),ILAST1(kproca)
77 INTEGER(KIND=JPIM) :: IPP(kproca)
78 INTEGER(KIND=JPIM) :: IFIRST(kproca)
79 
80 ! LOCAL INTEGER SCALARS
81 INTEGER(KIND=JPIM) :: ICOMP, IGL, IMAXI, IMAXIOL, IMEDIA, ITOT, JA, JGL,&
82  &ILAST,IREST,ILIMIT,IFRST
83 LOGICAL :: LLDONE
84 
85 ! -----------------------------------------------------------------
86 
87 !* 1. COMPUTATION OF KMEDIAP, KRESTM, KINDIC, KLAST.
88 ! ----------------------------------------------
89 
90 ! * Computation of KMEDIAP and KRESTM.
91 
92 imedia = sum(kloeng(kdgsa:kdgl))
93 kmediap = imedia / kproca
94 IF (kmediap < kloeng(kdgl/2)) THEN
95  CALL abort_trans ('SUMPLATB: KPROCA TOO BIG FOR THIS RESOLUTION')
96 ENDIF
97 krestm = imedia - kmediap * kproca
98 IF (krestm > 0) kmediap = kmediap + 1
99 
100 ! * Computation of intermediate quantities KINDIC and KLAST
101 
102 IF (ldsplit) THEN
103 
104  irest = 0
105  ilast =0
106  DO ja=1,kproca
107  IF (ja <= krestm .OR. krestm == 0) THEN
108  icomp = kmediap
109  ELSE
110  icomp = kmediap - 1
111  ENDIF
112  itot = irest
113  igl = ilast+1
114  DO jgl=igl,kdgl
115  ilast = jgl
116  IF(itot+kloeng(jgl) < icomp) THEN
117  itot = itot+kloeng(jgl)
118  ELSEIF(itot+kloeng(jgl) == icomp) THEN
119  irest = 0
120  klast(ja) = jgl
121  kindic(ja) = 0
122  EXIT
123  ELSE
124  irest = kloeng(jgl) -(icomp-itot)
125  klast(ja) = jgl
126  kindic(ja) = jgl
127  EXIT
128  ENDIF
129  ENDDO
130  ENDDO
131 
132 ELSE
133 
134  kindic(:) = 0
135 
136  imaxi = kmediap-1
137  imaxiol = huge(imaxiol)
138  DO
139  ilimit = imaxi
140  imaxi = 0
141  ifrst = kdgl
142  ilast1(:) = 0
143  ipp1(:) = 0
144  DO ja=kproca,1,-1
145  igl = ifrst
146  lats:DO jgl=igl,1,-1
147  IF (ipp1(ja) < ilimit .OR. ja == 1) THEN
148  ifrst = jgl-1
149  ipp1(ja) = ipp1(ja) + kloeng(jgl)
150  IF(ilast1(ja) == 0) ilast1(ja) = jgl
151  ELSE
152  EXIT lats
153  ENDIF
154  ENDDO lats
155  imaxi = max(imaxi,ipp1(ja))
156  ENDDO
157  IF(imaxi >= imaxiol) EXIT
158  klast(:) = ilast1(:)
159  ipp(:) = ipp1(:)
160  imaxiol = imaxi
161  ENDDO
162 
163 ! make the distribution more uniform
164 ! ----------------------------------
165 
166  ifirst(1) = 0
167  IF (klast(1) > 0) ifirst(1) = 1
168  DO ja=2,kproca
169  IF (ipp(ja) > 0) THEN
170  ifirst(ja) = klast(ja-1)+1
171  ELSE
172  ifirst(ja) = 0
173  ENDIF
174  ENDDO
175 
176  lldone = .false.
177  DO WHILE( .NOT.lldone )
178  lldone = .true.
179 
180  DO ja=1,kproca-1
181  IF (ipp(ja) > ipp(ja+1)) THEN
182  IF (ipp(ja)-ipp(ja+1) > ipp(ja+1) + 2 *&
183  &kloeng(klast(ja)) -ipp(ja) ) THEN
184  ipp(ja) = ipp(ja) - kloeng(klast(ja))
185  ipp(ja+1) = ipp(ja+1) + kloeng(klast(ja))
186  IF (klast(ja+1) == 0) klast(ja+1) = klast(ja)
187  ifirst(ja+1) = klast(ja)
188  klast(ja) = klast(ja) - 1
189  IF (klast(ja) == 0) ifirst(ja) = 0
190  lldone = .false.
191  ENDIF
192  ELSE
193  IF( ifirst(ja+1) > 0 )THEN
194  IF (ipp(ja+1)-ipp(ja) >= ipp(ja) + 2 *&
195  &kloeng(ifirst(ja+1)) -ipp(ja+1) ) THEN
196  ipp(ja) = ipp(ja) + kloeng(ifirst(ja+1))
197  ipp(ja+1) = ipp(ja+1) - kloeng(ifirst(ja+1))
198  klast(ja) = ifirst(ja+1)
199  IF (ifirst(ja) == 0) ifirst(ja) = klast(ja)
200  IF (klast(ja+1) == klast(ja)) THEN
201  klast(ja+1) = 0
202  ifirst(ja+1) = 0
203  ELSE
204  ifirst(ja+1) = ifirst(ja+1) + 1
205  ENDIF
206  lldone = .false.
207  ENDIF
208  ENDIF
209  ENDIF
210  ENDDO
211  ENDDO
212 
213 ENDIF
214 
215 END SUBROUTINE sumplatb
216 END MODULE sumplatb_mod
!$Id itapm1 ENDIF!IM on interpole les champs sur les niveaux STD de pression!IM a chaque pas de temps de la physique c!positionnement de l argument logique a false c!pour ne pas recalculer deux fois la meme chose!c!a cet effet un appel a plevel_new a ete deplace c!a la fin de la serie d appels c!la boucle DO nlevSTD a ete internalisee c!dans d ou la creation de cette routine c c!CALL false
Definition: calcul_STDlev.h:26
integer, parameter jprb
Definition: parkind1.F90:31
!$Id itapm1 ENDIF!IM on interpole les champs sur les niveaux STD de pression!IM a chaque pas de temps de la physique c!positionnement de l argument logique a false c!pour ne pas recalculer deux fois la meme chose!c!a cet effet un appel a plevel_new a ete deplace c!a la fin de la serie d appels c!la boucle DO nlevSTD a ete internalisee c!dans d ou la creation de cette routine c c!CALL ulevSTD CALL &zphi philevSTD CALL &zx_rh rhlevSTD!DO klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon klev DO klon du jour ou toutes les read_climoz CALL true
integer, parameter jpim
Definition: parkind1.F90:13
subroutine sumplatb(KDGSA, KDGL, KPROCA, KLOENG, LDSPLIT, KMEDIAP, KRESTM, KINDIC, KLAST)
Definition: sumplatb_mod.F90:5
subroutine abort_trans(CDTEXT)