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_lnk_icb_generic.h90 in NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/OCE/LBC – NEMO

source: NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/OCE/LBC/mpp_lnk_icb_generic.h90 @ 12632

Last change on this file since 12632 was 12632, checked in by orioltp, 4 years ago

Added two missing files with interfaces.

File size: 9.1 KB
Line 
1# if defined SINGLE_PRECISION
2#    define PRECISION sp
3#    define SENDROUTINE mppsend_sp
4#    define RECVROUTINE mpprecv_sp
5#    define LBCNORTH mpp_lbc_north_icb_sp
6# else
7#    define PRECISION dp
8#    define SENDROUTINE mppsend_dp
9#    define RECVROUTINE mpprecv_dp
10#    define LBCNORTH mpp_lbc_north_icb_dp
11# endif
12
13   SUBROUTINE ROUTINE_LNK( cdname, pt2d, cd_type, psgn, kexti, kextj )
14      !!----------------------------------------------------------------------
15      !!                  ***  routine mpp_lnk_2d_icb  ***
16      !!
17      !! ** Purpose :   Message passing management for 2d array (with extra halo for icebergs)
18      !!                This routine receives a (1-kexti:jpi+kexti,1-kexti:jpj+kextj)
19      !!                array (usually (0:jpi+1, 0:jpj+1)) from lbc_lnk_icb calls.
20      !!
21      !! ** Method  :   Use mppsend and mpprecv function for passing mask
22      !!      between processors following neighboring subdomains.
23      !!            domain parameters
24      !!                    jpi    : first dimension of the local subdomain
25      !!                    jpj    : second dimension of the local subdomain
26      !!                    kexti  : number of columns for extra outer halo
27      !!                    kextj  : number of rows for extra outer halo
28      !!                    nbondi : mark for "east-west local boundary"
29      !!                    nbondj : mark for "north-south local boundary"
30      !!                    noea   : number for local neighboring processors
31      !!                    nowe   : number for local neighboring processors
32      !!                    noso   : number for local neighboring processors
33      !!                    nono   : number for local neighboring processors
34      !!----------------------------------------------------------------------
35      CHARACTER(len=*)                                        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
36      REAL(PRECISION), DIMENSION(1-kexti:jpi+kexti,1-kextj:jpj+kextj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
37      CHARACTER(len=1)                                        , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
38      REAL(wp)                                                , INTENT(in   ) ::   psgn     ! sign used across the north fold
39      INTEGER                                                 , INTENT(in   ) ::   kexti    ! extra i-halo width
40      INTEGER                                                 , INTENT(in   ) ::   kextj    ! extra j-halo width
41      !
42      INTEGER  ::   jl   ! dummy loop indices
43      INTEGER  ::   imigr, iihom, ijhom        ! local integers
44      INTEGER  ::   ipreci, iprecj             !   -       -
45      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
46      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
47      !!
48      REAL(PRECISION), DIMENSION(1-kexti:jpi+kexti,nn_hls+kextj,2) ::   r2dns, r2dsn
49      REAL(PRECISION), DIMENSION(1-kextj:jpj+kextj,nn_hls+kexti,2) ::   r2dwe, r2dew
50      !!----------------------------------------------------------------------
51      ipreci = nn_hls + kexti      ! take into account outer extra 2D overlap area
52      iprecj = nn_hls + kextj
53
54      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, 1, 1, 1, ld_lbc = .TRUE. )
55
56      ! 1. standard boundary treatment
57      ! ------------------------------
58      ! Order matters Here !!!!
59      !
60      !                                      ! East-West boundaries
61      !                                           !* Cyclic east-west
62      IF( l_Iperio ) THEN
63         pt2d(1-kexti:     1   ,:) = pt2d(jpim1-kexti: jpim1 ,:)       ! east
64         pt2d(  jpi  :jpi+kexti,:) = pt2d(     2     :2+kexti,:)       ! west
65         !
66      ELSE                                        !* closed
67         IF( .NOT. cd_type == 'F' )   pt2d(  1-kexti   :nn_hls   ,:) = 0._PRECISION    ! east except at F-point
68                                      pt2d(jpi-nn_hls+1:jpi+kexti,:) = 0._PRECISION    ! west
69      ENDIF
70      !                                      ! North-South boundaries
71      IF( l_Jperio ) THEN                         !* cyclic (only with no mpp j-split)
72         pt2d(:,1-kextj:     1   ) = pt2d(:,jpjm1-kextj:  jpjm1)       ! north
73         pt2d(:,  jpj  :jpj+kextj) = pt2d(:,     2     :2+kextj)       ! south
74      ELSE                                        !* closed
75         IF( .NOT. cd_type == 'F' )   pt2d(:,  1-kextj   :nn_hls   ) = 0._PRECISION    ! north except at F-point
76                                      pt2d(:,jpj-nn_hls+1:jpj+kextj) = 0._PRECISION    ! south
77      ENDIF
78      !
79
80      ! north fold treatment
81      ! -----------------------
82      IF( npolj /= 0 ) THEN
83         !
84         SELECT CASE ( jpni )
85                   CASE ( 1 )     ;   CALL lbc_nfd         ( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
86                   CASE DEFAULT   ;   CALL LBCNORTH        ( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
87         END SELECT
88         !
89      ENDIF
90
91      ! 2. East and west directions exchange
92      ! ------------------------------------
93      ! we play with the neigbours AND the row number because of the periodicity
94      !
95      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
96      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
97         iihom = jpi-nreci-kexti
98         DO jl = 1, ipreci
99            r2dew(:,jl,1) = pt2d(nn_hls+jl,:)
100            r2dwe(:,jl,1) = pt2d(iihom +jl,:)
101         END DO
102      END SELECT
103      !
104      !                           ! Migrations
105      imigr = ipreci * ( jpj + 2*kextj )
106      !
107      !                           ! Migrations
108      imigr = ipreci * ( jpj + 2*kextj )
109      !
110      IF( ln_timing ) CALL tic_tac(.TRUE.)
111      !
112      SELECT CASE ( nbondi )
113      CASE ( -1 )
114         CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req1 )
115         CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, noea )
116         CALL mpi_wait(ml_req1,ml_stat,ml_err)
117      CASE ( 0 )
118         CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
119         CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req2 )
120         CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, noea )
121         CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, nowe )
122         CALL mpi_wait(ml_req1,ml_stat,ml_err)
123         CALL mpi_wait(ml_req2,ml_stat,ml_err)
124      CASE ( 1 )
125         CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
126         CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, nowe )
127         CALL mpi_wait(ml_req1,ml_stat,ml_err)
128      END SELECT
129      !
130      IF( ln_timing ) CALL tic_tac(.FALSE.)
131      !
132      !                           ! Write Dirichlet lateral conditions
133      iihom = jpi - nn_hls
134      !
135      SELECT CASE ( nbondi )
136      CASE ( -1 )
137         DO jl = 1, ipreci
138            pt2d(iihom+jl,:) = r2dew(:,jl,2)
139         END DO
140      CASE ( 0 )
141         DO jl = 1, ipreci
142            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
143            pt2d(iihom+jl,:) = r2dew(:,jl,2)
144         END DO
145      CASE ( 1 )
146         DO jl = 1, ipreci
147            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
148         END DO
149      END SELECT
150
151
152      ! 3. North and south directions
153      ! -----------------------------
154      ! always closed : we play only with the neigbours
155      !
156      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
157         ijhom = jpj-nrecj-kextj
158         DO jl = 1, iprecj
159            r2dsn(:,jl,1) = pt2d(:,ijhom +jl)
160            r2dns(:,jl,1) = pt2d(:,nn_hls+jl)
161         END DO
162      ENDIF
163      !
164      !                           ! Migrations
165      imigr = iprecj * ( jpi + 2*kexti )
166      !
167      IF( ln_timing ) CALL tic_tac(.TRUE.)
168      !
169      SELECT CASE ( nbondj )
170      CASE ( -1 )
171         CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req1 )
172         CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, nono )
173         CALL mpi_wait(ml_req1,ml_stat,ml_err)
174      CASE ( 0 )
175         CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
176         CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req2 )
177         CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, nono )
178         CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, noso )
179         CALL mpi_wait(ml_req1,ml_stat,ml_err)
180         CALL mpi_wait(ml_req2,ml_stat,ml_err)
181      CASE ( 1 )
182         CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
183         CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, noso )
184         CALL mpi_wait(ml_req1,ml_stat,ml_err)
185      END SELECT
186      !
187      IF( ln_timing ) CALL tic_tac(.FALSE.)
188      !
189      !                           ! Write Dirichlet lateral conditions
190      ijhom = jpj - nn_hls
191      !
192      SELECT CASE ( nbondj )
193      CASE ( -1 )
194         DO jl = 1, iprecj
195            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
196         END DO
197      CASE ( 0 )
198         DO jl = 1, iprecj
199            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
200            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
201         END DO
202      CASE ( 1 )
203         DO jl = 1, iprecj
204            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
205         END DO
206      END SELECT
207      !
208   END SUBROUTINE ROUTINE_LNK
209
210#    undef LBCNORTH
211#    undef PRECISION
212#    undef SENDROUTINE
213#    undef RECVROUTINE
Note: See TracBrowser for help on using the repository browser.