New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
mpp_bdy_generic.h90 in NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/mpp_bdy_generic.h90 @ 10357

Last change on this file since 10357 was 10314, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: action 2: add generic glob_min/max/sum and locmin/max, complete timing and report (including bdy and icb), see #2133

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-fortran
File size: 12.3 KB
Line 
1#   define ARRAY_TYPE(i,j,k,l,f)    REAL(wp)                    , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
2#   define NAT_IN(k)                cd_nat
3#   define SGN_IN(k)                psgn
4#   define IBD_IN(k)                kb_bdy
5#   define F_SIZE(ptab)             1
6#   define OPT_K(k)                 
7#   if defined DIM_2d
8#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
9#      define K_SIZE(ptab)          1
10#      define L_SIZE(ptab)          1
11#   endif
12#   if defined DIM_3d
13#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
14#      define K_SIZE(ptab)          SIZE(ptab,3)
15#      define L_SIZE(ptab)          1
16#   endif
17#   if defined DIM_4d
18#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
19#      define K_SIZE(ptab)          SIZE(ptab,3)
20#      define L_SIZE(ptab)          SIZE(ptab,4)
21#   endif
22
23   SUBROUTINE ROUTINE_BDY( cdname, ptab, cd_nat, psgn      , kb_bdy )
24      !!----------------------------------------------------------------------
25      !!                  ***  routine mpp_lnk_bdy_3d  ***
26      !!
27      !! ** Purpose :   Message passing management
28      !!
29      !! ** Method  :   Use mppsend and mpprecv function for passing BDY boundaries
30      !!      between processors following neighboring subdomains.
31      !!            domain parameters
32      !!                    nlci   : first dimension of the local subdomain
33      !!                    nlcj   : second dimension of the local subdomain
34      !!                    nbondi_bdy : mark for "east-west local boundary"
35      !!                    nbondj_bdy : mark for "north-south local boundary"
36      !!                    noea   : number for local neighboring processors
37      !!                    nowe   : number for local neighboring processors
38      !!                    noso   : number for local neighboring processors
39      !!                    nono   : number for local neighboring processors
40      !!
41      !! ** Action  :   ptab with update value at its periphery
42      !!
43      !!----------------------------------------------------------------------
44      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
45      ARRAY_TYPE(:,:,:,:,:)   ! array or pointer of arrays on which the boundary condition is applied
46      CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
47      REAL(wp)                    , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
48      INTEGER                     , INTENT(in   ) ::   IBD_IN(:)   ! BDY boundary set
49      !
50      INTEGER  ::   ji, jj, jk, jl, jh, jf     ! dummy loop indices
51      INTEGER  ::   ipk, ipl, ipf              ! 3dimension of the input array
52      INTEGER  ::   imigr, iihom, ijhom        ! local integers
53      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
54      REAL(wp) ::   zland                      ! local scalar
55      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
56      !
57      REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! 3d for north-south & south-north
58      REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! 3d for east-west & west-east
59      !!----------------------------------------------------------------------
60      !
61      ipk = K_SIZE(ptab)   ! 3rd dimension
62      ipl = L_SIZE(ptab)   ! 4th    -
63      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
64      !
65      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
66      !     
67      ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2),   &
68         &      zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2)  )
69
70      zland = 0._wp
71
72      ! 1. standard boundary treatment
73      ! ------------------------------
74      !
75      DO jf = 1, ipf                   ! number of arrays to be treated
76         !
77         !                                ! East-West boundaries
78         !                   
79         IF( nbondi == 2) THEN                  ! neither subdomain to the east nor to the west
80            !                                      !* Cyclic
81            IF( l_Iperio ) THEN
82               ARRAY_IN( 1 ,:,:,:,jf) = ARRAY_IN(jpim1,:,:,:,jf)
83               ARRAY_IN(jpi,:,:,:,jf) = ARRAY_IN(  2  ,:,:,:,jf)
84            ELSE                                   !* Closed
85               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(     1       :nn_hls,:,:,:,jf) = zland  ! east except F-point
86                                               ARRAY_IN(nlci-nn_hls+1:jpi   ,:,:,:,jf) = zland  ! west
87            ENDIF
88         ELSEIF(nbondi == -1) THEN              ! subdomain to the east only
89            IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(1:nn_hls,:,:,:,jf) = zland     ! south except F-point
90            !
91         ELSEIF(nbondi ==  1) THEN              ! subdomain to the west only
92            ARRAY_IN(nlci-nn_hls+1:jpi,:,:,:,jf) = zland    ! north
93         ENDIF
94         !                                ! North-South boundaries
95         !
96         IF( nbondj == 2) THEN                  ! neither subdomain to the north nor to the south
97            !                                      !* Cyclic
98            IF( l_Jperio ) THEN
99               ARRAY_IN(:, 1 ,:,:,jf) = ARRAY_IN(:,jpjm1,:,:,jf)
100               ARRAY_IN(:,jpj,:,:,jf) = ARRAY_IN(:,  2  ,:,:,jf)
101            ELSE                                   !* Closed
102               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:,     1       :nn_hls,:,:,jf) = zland  ! east except F-point
103                                               ARRAY_IN(:,nlcj-nn_hls+1:jpj   ,:,:,jf) = zland  ! west
104            ENDIF
105         ELSEIF(nbondj == -1) THEN              ! subdomain to the east only
106            IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:,1:nn_hls,:,:,jf) = zland     ! south except F-point
107            !
108         ELSEIF(nbondj ==  1) THEN              ! subdomain to the west only
109            ARRAY_IN(:,nlcj-nn_hls+1:jpj,:,:,jf) = zland    ! north
110         ENDIF
111         !
112      END DO
113
114      ! 2. East and west directions exchange
115      ! ------------------------------------
116      ! we play with the neigbours AND the row number because of the periodicity
117      !
118      !
119      DO jf = 1, ipf
120         SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )      ! Read Dirichlet lateral conditions
121         CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
122            iihom = nlci-nreci
123               DO jl = 1, ipl
124                  DO jk = 1, ipk
125                     DO jh = 1, nn_hls
126                        zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf)
127                        zt3we(:,jh,jk,jl,jf,1) = ARRAY_IN(iihom +jh,:,jk,jl,jf)
128                     END DO
129                  END DO
130               END DO
131         END SELECT
132         !
133         !                           ! Migrations
134!!gm      imigr = nn_hls * jpj * ipk * ipl * ipf
135         imigr = nn_hls * jpj * ipk * ipl
136         !
137         IF( ln_timing ) CALL tic_tac(.TRUE.)
138         !
139         SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )
140         CASE ( -1 )
141            CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req1 )
142            CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
143            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
144         CASE ( 0 )
145            CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
146            CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req2 )
147            CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
148            CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
149            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
150            IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
151         CASE ( 1 )
152            CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
153            CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
154            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
155         END SELECT
156         !
157         IF( ln_timing ) CALL tic_tac(.FALSE.)
158         !
159         !                           ! Write Dirichlet lateral conditions
160         iihom = nlci-nn_hls
161         !
162         !
163         SELECT CASE ( nbondi_bdy_b(IBD_IN(jf)) )
164         CASE ( -1 )
165            DO jl = 1, ipl
166               DO jk = 1, ipk
167                  DO jh = 1, nn_hls
168                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
169                  END DO
170               END DO
171            END DO
172         CASE ( 0 )
173            DO jl = 1, ipl
174               DO jk = 1, ipk
175                  DO jh = 1, nn_hls
176                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
177                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
178                  END DO
179               END DO
180            END DO
181         CASE ( 1 )
182            DO jl = 1, ipl
183               DO jk = 1, ipk
184                  DO jh = 1, nn_hls
185                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
186                  END DO
187               END DO
188            END DO
189         END SELECT
190         !
191      END DO
192
193      ! 3. North and south directions
194      ! -----------------------------
195      ! always closed : we play only with the neigbours
196      !
197      DO jf = 1, ipf
198         IF( nbondj_bdy(IBD_IN(jf)) /= 2 ) THEN      ! Read Dirichlet lateral conditions
199            ijhom = nlcj-nrecj
200            DO jl = 1, ipl
201               DO jk = 1, ipk
202                  DO jh = 1, nn_hls
203                     zt3sn(:,jh,jk,jl,jf,1) = ARRAY_IN(:,ijhom +jh,jk,jl,jf)
204                     zt3ns(:,jh,jk,jl,jf,1) = ARRAY_IN(:,nn_hls+jh,jk,jl,jf)
205                  END DO
206               END DO
207            END DO
208         ENDIF
209         !
210         !                           ! Migrations
211!!gm      imigr = nn_hls * jpi * ipk * ipl * ipf
212         imigr = nn_hls * jpi * ipk * ipl
213         !
214         IF( ln_timing ) CALL tic_tac(.TRUE.)
215         !
216         SELECT CASE ( nbondj_bdy(IBD_IN(jf)) )
217         CASE ( -1 )
218            CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req1 )
219            CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
220            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
221         CASE ( 0 )
222            CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
223            CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req2 )
224            CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
225            CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
226            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
227            IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
228         CASE ( 1 )
229            CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
230            CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
231            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
232         END SELECT
233         !
234         IF( ln_timing ) CALL tic_tac(.FALSE.)
235         !
236         !                           ! Write Dirichlet lateral conditions
237         ijhom = nlcj-nn_hls
238         !
239         SELECT CASE ( nbondj_bdy_b(IBD_IN(jf)) )
240         CASE ( -1 )
241            DO jl = 1, ipl
242               DO jk = 1, ipk
243                  DO jh = 1, nn_hls
244                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
245                  END DO
246               END DO
247            END DO
248         CASE ( 0 )
249            DO jl = 1, ipl
250               DO jk = 1, ipk
251                  DO jh = 1, nn_hls
252                     ARRAY_IN(:,      jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
253                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
254                  END DO
255               END DO
256            END DO
257         CASE ( 1 )
258            DO jl = 1, ipl
259               DO jk = 1, ipk
260                  DO jh = 1, nn_hls
261                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
262                  END DO
263               END DO
264            END DO
265         END SELECT
266      END DO
267
268      ! 4. north fold treatment
269      ! -----------------------
270      !
271      IF( npolj /= 0) THEN
272         !
273         SELECT CASE ( jpni )
274         CASE ( 1 )     ;   CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) )   ! only 1 northern proc, no mpp
275         CASE DEFAULT   ;   CALL mpp_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) )   ! for all northern procs.
276         END SELECT
277         !
278      ENDIF
279      !
280      DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we  )
281      !
282   END SUBROUTINE ROUTINE_BDY
283
284#undef ARRAY_TYPE
285#undef NAT_IN
286#undef SGN_IN
287#undef IBD_IN
288#undef ARRAY_IN
289#undef K_SIZE
290#undef L_SIZE
291#undef F_SIZE
292#undef OPT_K
Note: See TracBrowser for help on using the repository browser.