LMDZ
sutrle_mod.F90
Go to the documentation of this file.
1 MODULE sutrle_mod
2 CONTAINS
3 SUBROUTINE sutrle(PNM)
4 
5 !**** *sutrle * - transposition of Legendre polynomials during set-up
6 
7 ! Purpose.
8 ! --------
9 ! transposition of Legendre polynomials during set-up
10 
11 !** Interface.
12 ! ----------
13 ! *call* *sutrle(pnm)
14 
15 ! Explicit arguments :
16 ! --------------------
17 
18 ! Implicit arguments :
19 ! --------------------
20 
21 ! Method.
22 ! -------
23 ! See documentation
24 
25 ! Externals.
26 ! ----------
27 
28 ! Reference.
29 ! ----------
30 ! ECMWF Research Department documentation of the IFS
31 
32 ! Author.
33 ! -------
34 ! MPP Group *ECMWF*
35 
36 ! Modifications.
37 ! --------------
38 ! Original : 95-10-01
39 ! ------------------------------------------------------------------
40 
41 
42 USE parkind1 ,ONLY : jpim ,jprb
43 !USE MPL_MODULE
44 
45 USE tpm_gen
46 USE tpm_dim
47 USE tpm_distr
48 USE tpm_fields
49 USE set2pe_mod
51 
52 IMPLICIT NONE
53 
54 REAL(KIND=JPRB),INTENT(IN) :: PNM(r%nspoleg,d%nlei3d)
55 
56 ! LOCAL
57 
58 REAL(KIND=JPRB), ALLOCATABLE :: ZCOMBUF(:)
59 REAL(KIND=JPRB), POINTER :: ZPNM(:,:)
60 INTEGER(KIND=JPIM) :: IGLLOC, ILREC, IM, INENTR, IPOS, &
61  &IRECSET, IRECV, ISEND, ISENDSET, ITAG, &
62  &JGL, JGLLOC, JM, JMLOC, JN, JROC ,IOFFT, IOFFG
63 
64 LOGICAL :: LLADMSG, LLEXACT
65 
66 ! ------------------------------------------------------------------
67 
68 !* 0. Some initializations.
69 ! ---------------------
70 !! Workaround for obscure unwillingness to vectorize on VPP
71 zpnm => f%RPNM
72 
73 ! Perform barrier synchronisation to guarantee all processors have
74 ! completed all previous communication
75 
76 IF( nproc > 1 )THEN
77 ! CALL GSTATS(783,0) ! MPL 3.12.08
78 ! CALL MPL_BARRIER(CDSTRING='SUTRLE:')
79 ! CALL GSTATS(783,1)
80  CALL abor1(' SUTRLE:A LA PLACE DE MPL_BARRIER')
81 ENDIF
82 
83 ALLOCATE (zcombuf(ncombflen))
84 
85 DO jroc=1,nprtrw-1
86 
87  lladmsg = .false.
88  itag = mtagletr
89 
90 !* Define PE to which data have to be sent and PE from which
91 !* data have to be received
92 
93 ! CALL GSTATS(801,0) ! MPL 4.12.08
94  isend = mysetw-jroc
95  irecv = mysetw+jroc
96  IF (isend <= 0) isend = isend+nprtrw
97  IF (irecv > nprtrw) irecv = irecv-nprtrw
98  irecset = irecv
99  isendset = isend
100  CALL set2pe(isend,0,0,isend,mysetv)
101  CALL set2pe(irecv,0,0,irecv,mysetv)
102 
103 !* copy data to be sent into zcombuf
104 
105  ipos = 0
106  DO jm=0,r%NSMAX
107  IF (isendset == d%NPROCM(jm)) THEN
108  inentr = (d%NLATLE(mysetw)-d%NLATLS(mysetw)+1)*(r%NTMAX-jm+2)
109  IF (ipos + inentr < ncombflen) THEN
110  DO jgl=d%NLATLS(mysetw),d%NLATLE(mysetw)
111  jglloc = jgl - d%NLATLS(mysetw) + 1
112  DO jn=1,r%NTMAX-jm+2
113  ipos = ipos + 1
114  zcombuf(ipos) = pnm(d%NPMG(jm)+jn,jglloc)
115  ENDDO
116  ENDDO
117  ELSE
118  DO jgl=d%NLATLS(mysetw),d%NLATLE(mysetw)
119  jglloc = jgl - d%NLATLS(mysetw) + 1
120  DO jn=1,r%NTMAX-jm+2
121  ipos = ipos + 1
122  zcombuf(ipos) = pnm(d%NPMG(jm)+jn,jglloc)
123  IF (ipos == ncombflen) THEN
124 ! CALL MPL_SEND(zcombuf(1:ipos),KDEST=NPRCIDS(ISEND), &
125 ! & KTAG=ITAG,CDSTRING='SUTRLE:') ! MPL 3.12.08
126  CALL abor1(' SUTRLE:A LA PLACE DE MPL_SEND')
127  ipos = 0
128  itag = itag + 1
129  llexact = (jgl == d%NLATLE(mysetw) .AND. jn == r%NTMAX-jm+2)
130  IF (.NOT.llexact) lladmsg = .true.
131  ENDIF
132  ENDDO
133  ENDDO
134  ENDIF
135  ENDIF
136  ENDDO
137 
138 !* send message (if not empty or if message has been split)
139 
140  IF (ipos > 0 .OR. lladmsg) THEN
141 ! CALL MPL_SEND(ZCOMBUF(1:IPOS),KDEST=NPRCIDS(ISEND), &
142 ! & KTAG=ITAG,CDSTRING='SUTRLE:') ! MPL 3.12.08
143  CALL abor1(' SUTRLE:A LA PLACE DE MPL_SEND')
144  ENDIF
145 ! CALL GSTATS(801,1) ! MPL 4.12.08
146 
147  ilrec = 0
148  itag = mtagletr
149  IF (d%NUMP > 0.AND. d%NLATLE(irecset) >= d%NLATLS(irecset)) THEN
150 
151 !* receive message (if not empty)
152 
153 ! CALL GSTATS(801,0)
154 ! CALL MPL_RECV(ZCOMBUF(1:NCOMBFLEN),KSOURCE=NPRCIDS(IRECV), &
155 ! & KTAG=ITAG,KOUNT=ILREC,CDSTRING='SUTRLE:') ! MPL 3.12.08
156  CALL abor1(' SUTRLE:A LA PLACE DE MPL_RECV')
157 
158 !* copy data from buffer to f%rpnm
159 
160  ipos = 0
161  DO jmloc=1,d%NUMP
162  jm = d%MYMS(jmloc)
163  inentr = (d%NLATLE(irecset)-d%NLATLS(irecset)+1)*(r%NTMAX-jm+2)
164  iofft = d%NPMT(jm)
165  IF (ipos + inentr < ncombflen) THEN
166  DO jgl=d%NLATLS(irecset),d%NLATLE(irecset)
167  DO jn=1,r%NTMAX-jm+2
168  ipos = ipos + 1
169  zpnm(jgl,iofft+jn) = zcombuf(ipos)
170  ENDDO
171  ENDDO
172  ELSE
173  DO jgl=d%NLATLS(irecset),d%NLATLE(irecset)
174  DO jn=1,r%NTMAX-jm+2
175  ipos = ipos + 1
176  zpnm(jgl,iofft+jn) = zcombuf(ipos)
177  IF (ipos == ncombflen) THEN
178  itag = itag + 1
179 ! CALL MPL_RECV(ZCOMBUF(1:NCOMBFLEN), &
180 ! & KSOURCE=NPRCIDS(IRECV),KTAG=ITAG, &
181 ! & KOUNT=ILREC,CDSTRING='SUTRLE:') ! MPL 3.12.08
182  CALL abor1(' SUTRLE:A LA PLACE DE MPL_RECV')
183  ipos = 0
184  ENDIF
185  ENDDO
186  ENDDO
187  ENDIF
188  ENDDO
189 ! CALL GSTATS(801,1) ! MPL 4.12.08
190 
191 !* check received message length
192 
193  IF (ilrec /= ipos) THEN
194  WRITE(nout,*)' SUTRLE: ILREC,IPOS,NCOMBLEN ',ilrec,ipos,ncombflen
195  CALL abort_trans(' SUTRLE:RECEIVED MESSAGE LENGTH DOES NOT MATCH')
196  ENDIF
197  ENDIF
198 
199 ! Perform barrier synchronisation to guarantee all processors have
200 ! completed communication for this jroc loop iteration
201 
202 ! CALL MPL_BARRIER(CDSTRING='SUTRLE:') ! MPL 3.12.08
203  CALL abor1(' SUTRLE:A LA PLACE DE MPL_BARRIER')
204 
205 ENDDO
206 
207 !* copy data from pnm to rpnm
208 
209 !CALL GSTATS(1803,0) ! MPL 4.12.08
210 !cjfe OMP not efficient in that case
211 !cjfe!$OMP PARALLEL DO SCHEDULE(STATIC) PRIVATE(jmloc,im,iofft,ioffg,jgl,iglloc,jn)
212 DO jmloc=1,d%NUMP
213  im = d%MYMS(jmloc)
214  iofft = d%NPMT(im)
215  ioffg = d%NPMG(im)
216  DO jgl=d%NLATLS(mysetw),d%NLATLE(mysetw)
217  iglloc = jgl-d%NLATLS(mysetw)+1
218  DO jn=1,r%NTMAX-im+2
219  zpnm(jgl,iofft+jn) = pnm(ioffg+jn,iglloc)
220  ENDDO
221  ENDDO
222 ENDDO
223 !cjfe!$OMP END PARALLEL DO
224 !CALL GSTATS(1803,1) ! MPL 4.12.08
225 
226 DEALLOCATE (zcombuf)
227 
228 END SUBROUTINE sutrle
229 END MODULE sutrle_mod
!$Id mode_top_bound COMMON comconstr r
Definition: comconst.h:7
type(fields_type), pointer f
Definition: tpm_fields.F90:23
integer(kind=jpim) ncombflen
Definition: tpm_distr.F90:23
!$Id jm
Definition: comconst.h:7
type(distr_type), pointer d
Definition: tpm_distr.F90:152
subroutine abor1(CDTEXT)
Definition: abor1.F90:2
!$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
subroutine sutrle(PNM)
Definition: sutrle_mod.F90:4
integer(kind=jpim) mtagletr
Definition: tpm_distr.F90:25
integer, parameter jprb
Definition: parkind1.F90:31
integer(kind=jpim) nproc
Definition: tpm_distr.F90:11
integer(kind=jpim) mysetw
Definition: tpm_distr.F90:21
!$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(kind=jpim) mysetv
Definition: tpm_distr.F90:22
integer(kind=jpim) nprtrw
Definition: tpm_distr.F90:14
subroutine set2pe(KPE, KPRGPNS, KPRGPEW, KPRTRW, KPRTRV)
Definition: set2pe_mod.F90:4
integer, parameter jpim
Definition: parkind1.F90:13
integer(kind=jpim) nout
Definition: tpm_gen.F90:9
subroutine abort_trans(CDTEXT)