[8586] | 1 | #if defined MULTI |
---|
| 2 | # define NAT_IN(k) cd_nat(k) |
---|
| 3 | # define SGN_IN(k) psgn(k) |
---|
| 4 | # define F_SIZE(ptab) kfld |
---|
| 5 | # define OPT_K(k) ,ipf |
---|
| 6 | # if defined DIM_2d |
---|
| 7 | # define ARRAY_TYPE(i,j,k,l,f) TYPE(PTR_2D) , INTENT(inout) :: ptab(f) |
---|
| 8 | # define ARRAY_IN(i,j,k,l,f) ptab(f)%pt2d(i,j) |
---|
| 9 | # define K_SIZE(ptab) 1 |
---|
| 10 | # define L_SIZE(ptab) 1 |
---|
| 11 | # endif |
---|
| 12 | # if defined DIM_3d |
---|
| 13 | # define ARRAY_TYPE(i,j,k,l,f) TYPE(PTR_3D) , INTENT(inout) :: ptab(f) |
---|
| 14 | # define ARRAY_IN(i,j,k,l,f) ptab(f)%pt3d(i,j,k) |
---|
| 15 | # define K_SIZE(ptab) SIZE(ptab(1)%pt3d,3) |
---|
| 16 | # define L_SIZE(ptab) 1 |
---|
| 17 | # endif |
---|
| 18 | # if defined DIM_4d |
---|
| 19 | # define ARRAY_TYPE(i,j,k,l,f) TYPE(PTR_4D) , INTENT(inout) :: ptab(f) |
---|
| 20 | # define ARRAY_IN(i,j,k,l,f) ptab(f)%pt4d(i,j,k,l) |
---|
| 21 | # define K_SIZE(ptab) SIZE(ptab(1)%pt4d,3) |
---|
| 22 | # define L_SIZE(ptab) SIZE(ptab(1)%pt4d,4) |
---|
| 23 | # endif |
---|
| 24 | #else |
---|
| 25 | # define ARRAY_TYPE(i,j,k,l,f) REAL(wp) , INTENT(inout) :: ARRAY_IN(i,j,k,l,f) |
---|
| 26 | # define NAT_IN(k) cd_nat |
---|
| 27 | # define SGN_IN(k) psgn |
---|
| 28 | # define F_SIZE(ptab) 1 |
---|
| 29 | # define OPT_K(k) |
---|
| 30 | # if defined DIM_2d |
---|
| 31 | # define ARRAY_IN(i,j,k,l,f) ptab(i,j) |
---|
| 32 | # define K_SIZE(ptab) 1 |
---|
| 33 | # define L_SIZE(ptab) 1 |
---|
| 34 | # endif |
---|
| 35 | # if defined DIM_3d |
---|
| 36 | # define ARRAY_IN(i,j,k,l,f) ptab(i,j,k) |
---|
| 37 | # define K_SIZE(ptab) SIZE(ptab,3) |
---|
| 38 | # define L_SIZE(ptab) 1 |
---|
| 39 | # endif |
---|
| 40 | # if defined DIM_4d |
---|
| 41 | # define ARRAY_IN(i,j,k,l,f) ptab(i,j,k,l) |
---|
| 42 | # define K_SIZE(ptab) SIZE(ptab,3) |
---|
| 43 | # define L_SIZE(ptab) SIZE(ptab,4) |
---|
| 44 | # endif |
---|
| 45 | #endif |
---|
| 46 | |
---|
| 47 | #if defined MULTI |
---|
[11536] | 48 | SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv, ihlcom ) |
---|
| 49 | INTEGER , INTENT(in ) :: kfld ! number of pt3d arrays |
---|
[8586] | 50 | #else |
---|
[11536] | 51 | SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn , kfillmode, pfillval, lsend, lrecv, ihlcom ) |
---|
[8586] | 52 | #endif |
---|
| 53 | ARRAY_TYPE(:,:,:,:,:) ! array or pointer of arrays on which the boundary condition is applied |
---|
[11536] | 54 | CHARACTER(len=*) , INTENT(in ) :: cdname ! name of the calling subroutine |
---|
| 55 | CHARACTER(len=1) , INTENT(in ) :: NAT_IN(:) ! nature of array grid-points |
---|
| 56 | REAL(wp) , INTENT(in ) :: SGN_IN(:) ! sign used across the north fold boundary |
---|
| 57 | INTEGER , OPTIONAL, INTENT(in ) :: kfillmode ! filling method for halo over land (default = constant) |
---|
| 58 | REAL(wp), OPTIONAL, INTENT(in ) :: pfillval ! background value (used at closed boundaries) |
---|
| 59 | LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in ) :: lsend, lrecv ! communication with other 4 proc |
---|
| 60 | INTEGER ,OPTIONAL, INTENT(in ) :: ihlcom ! number of ranks and rows to be communicated |
---|
[8586] | 61 | ! |
---|
[11536] | 62 | INTEGER :: ji, jj, jk, jl, jf ! dummy loop indices |
---|
[8586] | 63 | INTEGER :: ipi, ipj, ipk, ipl, ipf ! dimension of the input array |
---|
[11536] | 64 | INTEGER :: isize, ishift, ishift2 ! local integers |
---|
| 65 | INTEGER :: ireq_we, ireq_ea, ireq_so, ireq_no ! mpi_request id |
---|
[10425] | 66 | INTEGER :: ierr |
---|
[11536] | 67 | INTEGER :: ifill_we, ifill_ea, ifill_so, ifill_no |
---|
| 68 | INTEGER :: ihl ! number of ranks and rows to be communicated |
---|
[8586] | 69 | REAL(wp) :: zland |
---|
[11536] | 70 | INTEGER , DIMENSION(MPI_STATUS_SIZE) :: istat ! for mpi_isend |
---|
| 71 | REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE :: zsnd_we, zrcv_we, zsnd_ea, zrcv_ea ! east -west & west - east halos |
---|
| 72 | REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE :: zsnd_so, zrcv_so, zsnd_no, zrcv_no ! north-south & south-north halos |
---|
| 73 | LOGICAL :: llsend_we, llsend_ea, llsend_no, llsend_so ! communication send |
---|
| 74 | LOGICAL :: llrecv_we, llrecv_ea, llrecv_no, llrecv_so ! communication receive |
---|
| 75 | LOGICAL :: lldo_nfd ! do north pole folding |
---|
[8586] | 76 | !!---------------------------------------------------------------------- |
---|
| 77 | ! |
---|
[11536] | 78 | ! ----------------------------------------- ! |
---|
| 79 | ! 0. local variables initialization ! |
---|
| 80 | ! ----------------------------------------- ! |
---|
| 81 | ! |
---|
[8586] | 82 | ipk = K_SIZE(ptab) ! 3rd dimension |
---|
| 83 | ipl = L_SIZE(ptab) ! 4th - |
---|
| 84 | ipf = F_SIZE(ptab) ! 5th - use in "multi" case (array of pointers) |
---|
| 85 | ! |
---|
[11536] | 86 | IF( PRESENT(ihlcom) ) THEN ; ihl = ihlcom |
---|
| 87 | ELSE ; ihl = 1 |
---|
| 88 | END IF |
---|
| 89 | ! |
---|
[10425] | 90 | IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. ) |
---|
[8586] | 91 | ! |
---|
[11536] | 92 | IF ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN |
---|
| 93 | llsend_we = lsend(1) ; llsend_ea = lsend(2) ; llsend_so = lsend(3) ; llsend_no = lsend(4) |
---|
| 94 | llrecv_we = lrecv(1) ; llrecv_ea = lrecv(2) ; llrecv_so = lrecv(3) ; llrecv_no = lrecv(4) |
---|
| 95 | ELSE IF( PRESENT(lsend) .OR. PRESENT(lrecv) ) THEN |
---|
| 96 | WRITE(ctmp1,*) ' E R R O R : Routine ', cdname, ' is calling lbc_lnk with only one of the two arguments lsend or lrecv' |
---|
| 97 | WRITE(ctmp2,*) ' ========== ' |
---|
| 98 | CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' ) |
---|
| 99 | ELSE ! send and receive with every neighbour |
---|
| 100 | llsend_we = nbondi == 1 .OR. nbondi == 0 ! keep for compatibility, should be defined in mppini |
---|
| 101 | llsend_ea = nbondi == -1 .OR. nbondi == 0 ! keep for compatibility, should be defined in mppini |
---|
| 102 | llsend_so = nbondj == 1 .OR. nbondj == 0 ! keep for compatibility, should be defined in mppini |
---|
| 103 | llsend_no = nbondj == -1 .OR. nbondj == 0 ! keep for compatibility, should be defined in mppini |
---|
| 104 | llrecv_we = llsend_we ; llrecv_ea = llsend_ea ; llrecv_so = llsend_so ; llrecv_no = llsend_no |
---|
| 105 | END IF |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | lldo_nfd = npolj /= 0 ! keep for compatibility, should be defined in mppini |
---|
[8586] | 109 | |
---|
[11536] | 110 | zland = 0._wp ! land filling value: zero by default |
---|
| 111 | IF( PRESENT( pfillval ) ) zland = pfillval ! set land value |
---|
| 112 | |
---|
| 113 | ! define the method we will use to fill the halos in each direction |
---|
| 114 | IF( llrecv_we ) THEN ; ifill_we = jpfillmpi |
---|
| 115 | ELSEIF( l_Iperio ) THEN ; ifill_we = jpfillperio |
---|
| 116 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_we = kfillmode |
---|
| 117 | ELSE ; ifill_we = jpfillcst |
---|
| 118 | END IF |
---|
[8586] | 119 | ! |
---|
[11536] | 120 | IF( llrecv_ea ) THEN ; ifill_ea = jpfillmpi |
---|
| 121 | ELSEIF( l_Iperio ) THEN ; ifill_ea = jpfillperio |
---|
| 122 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_ea = kfillmode |
---|
| 123 | ELSE ; ifill_ea = jpfillcst |
---|
| 124 | END IF |
---|
| 125 | ! |
---|
| 126 | IF( llrecv_so ) THEN ; ifill_so = jpfillmpi |
---|
| 127 | ELSEIF( l_Jperio ) THEN ; ifill_so = jpfillperio |
---|
| 128 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_so = kfillmode |
---|
| 129 | ELSE ; ifill_so = jpfillcst |
---|
| 130 | END IF |
---|
| 131 | ! |
---|
| 132 | IF( llrecv_no ) THEN ; ifill_no = jpfillmpi |
---|
| 133 | ELSEIF( l_Jperio ) THEN ; ifill_no = jpfillperio |
---|
| 134 | ELSEIF( PRESENT(kfillmode) ) THEN ; ifill_no = kfillmode |
---|
| 135 | ELSE ; ifill_no = jpfillcst |
---|
| 136 | END IF |
---|
| 137 | ! |
---|
| 138 | #if defined PRINT_CAUTION |
---|
| 139 | ! |
---|
| 140 | ! ================================================================================== ! |
---|
| 141 | ! CAUTION: semi-column notation is often impossible because of the cpp preprocessing ! |
---|
| 142 | ! ================================================================================== ! |
---|
| 143 | ! |
---|
| 144 | #endif |
---|
| 145 | ! |
---|
| 146 | ! -------------------------------------------------- ! |
---|
| 147 | ! 1. Do east and west MPI exchange if needed ! |
---|
| 148 | ! -------------------------------------------------- ! |
---|
| 149 | ! |
---|
| 150 | ! Must exchange the whole column (from 1 to jpj) to get the corners if we have no south/north neighbourg |
---|
| 151 | isize = ihl * jpj * ipk * ipl * ipf |
---|
| 152 | ! |
---|
| 153 | ! Allocate local temporary arrays to be sent/received. Fill arrays to be sent |
---|
| 154 | IF( llsend_we ) ALLOCATE( zsnd_we(ihl,jpj,ipk,ipl,ipf) ) |
---|
| 155 | IF( llsend_ea ) ALLOCATE( zsnd_ea(ihl,jpj,ipk,ipl,ipf) ) |
---|
| 156 | IF( llrecv_we ) ALLOCATE( zrcv_we(ihl,jpj,ipk,ipl,ipf) ) |
---|
| 157 | IF( llrecv_ea ) ALLOCATE( zrcv_ea(ihl,jpj,ipk,ipl,ipf) ) |
---|
| 158 | ! |
---|
| 159 | IF( llsend_we ) THEN ! copy western side of the inner mpi domain in local temporary array to be sent by MPI |
---|
| 160 | ishift = ihl |
---|
| 161 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 162 | zsnd_we(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf) ! ihl + 1 -> 2*ihl |
---|
| 163 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
[8586] | 164 | ENDIF |
---|
| 165 | ! |
---|
[11536] | 166 | IF(llsend_ea ) THEN ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI |
---|
| 167 | ishift = jpi - 2 * ihl |
---|
| 168 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 169 | zsnd_ea(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf) ! jpi - 2*ihl + 1 -> jpi - ihl |
---|
| 170 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 171 | ENDIF |
---|
[10425] | 172 | ! |
---|
| 173 | IF( ln_timing ) CALL tic_tac(.TRUE.) |
---|
| 174 | ! |
---|
[11536] | 175 | ! non-blocking send of the western/eastern side using local temporary arrays |
---|
| 176 | IF( llsend_we ) CALL mppsend( 1, zsnd_we(1,1,1,1,1), isize, nowe, ireq_we ) |
---|
| 177 | IF( llsend_ea ) CALL mppsend( 2, zsnd_ea(1,1,1,1,1), isize, noea, ireq_ea ) |
---|
| 178 | ! blocking receive of the western/eastern halo in local temporary arrays |
---|
| 179 | IF( llrecv_we ) CALL mpprecv( 2, zrcv_we(1,1,1,1,1), isize, nowe ) |
---|
| 180 | IF( llrecv_ea ) CALL mpprecv( 1, zrcv_ea(1,1,1,1,1), isize, noea ) |
---|
[8586] | 181 | ! |
---|
[10425] | 182 | IF( ln_timing ) CALL tic_tac(.FALSE.) |
---|
| 183 | ! |
---|
[8586] | 184 | ! |
---|
[11536] | 185 | ! ----------------------------------- ! |
---|
| 186 | ! 2. Fill east and west halos ! |
---|
| 187 | ! ----------------------------------- ! |
---|
| 188 | ! |
---|
| 189 | ! 2.1 fill weastern halo |
---|
| 190 | ! ---------------------- |
---|
| 191 | ! ishift = 0 ! fill halo from ji = 1 to ihl |
---|
| 192 | SELECT CASE ( ifill_we ) |
---|
| 193 | CASE ( jpfillnothing ) ! no filling |
---|
| 194 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
| 195 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 196 | ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_we(ji,jj,jk,jl,jf) ! 1 -> ihl |
---|
| 197 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 198 | CASE ( jpfillperio ) ! use east-weast periodicity |
---|
| 199 | ishift2 = jpi - 2 * ihl |
---|
| 200 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 201 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf) |
---|
| 202 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 203 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
| 204 | DO jf = 1, ipf ! number of arrays to be treated |
---|
| 205 | IF( .NOT. NAT_IN(jf) == 'F' ) THEN ! do nothing for F point |
---|
| 206 | DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 207 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ihl+1,jj,jk,jl,jf) |
---|
| 208 | END DO ; END DO ; END DO ; END DO |
---|
| 209 | ENDIF |
---|
[8586] | 210 | END DO |
---|
[11536] | 211 | CASE ( jpfillcst ) ! filling with constant value |
---|
| 212 | DO jf = 1, ipf ! number of arrays to be treated |
---|
| 213 | IF( .NOT. NAT_IN(jf) == 'F' ) THEN ! do nothing for F point |
---|
| 214 | DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 215 | ARRAY_IN(ji,jj,jk,jl,jf) = zland |
---|
| 216 | END DO; END DO ; END DO ; END DO |
---|
| 217 | ENDIF |
---|
[8586] | 218 | END DO |
---|
| 219 | END SELECT |
---|
[10425] | 220 | ! |
---|
[11536] | 221 | ! 2.2 fill eastern halo |
---|
| 222 | ! --------------------- |
---|
| 223 | ishift = jpi - ihl ! fill halo from ji = jpi-ihl+1 to jpi |
---|
| 224 | SELECT CASE ( ifill_ea ) |
---|
| 225 | CASE ( jpfillnothing ) ! no filling |
---|
| 226 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
| 227 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 228 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv_ea(ji,jj,jk,jl,jf) ! jpi - ihl + 1 -> jpi |
---|
| 229 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 230 | CASE ( jpfillperio ) ! use east-weast periodicity |
---|
| 231 | ishift2 = ihl |
---|
| 232 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 233 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf) |
---|
| 234 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 235 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
| 236 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 237 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf) |
---|
| 238 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 239 | CASE ( jpfillcst ) ! filling with constant value |
---|
| 240 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, jpj ; DO ji = 1, ihl |
---|
| 241 | ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland |
---|
| 242 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 243 | END SELECT |
---|
[10542] | 244 | ! |
---|
| 245 | ! ------------------------------- ! |
---|
| 246 | ! 3. north fold treatment ! |
---|
| 247 | ! ------------------------------- ! |
---|
[11536] | 248 | ! |
---|
[10542] | 249 | ! do it before south directions so concerned processes can do it without waiting for the comm with the sourthern neighbor |
---|
[11536] | 250 | ! |
---|
| 251 | IF( lldo_nfd .AND. ifill_no /= jpfillnothing ) THEN |
---|
[10542] | 252 | ! |
---|
| 253 | SELECT CASE ( jpni ) |
---|
| 254 | CASE ( 1 ) ; CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) ) ! only 1 northern proc, no mpp |
---|
| 255 | CASE DEFAULT ; CALL mpp_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) ) ! for all northern procs. |
---|
| 256 | END SELECT |
---|
| 257 | ! |
---|
[11536] | 258 | ifill_no = jpfillnothing ! force to do nothing for the northern halo as we just done the north pole folding |
---|
| 259 | ! |
---|
[10542] | 260 | ENDIF |
---|
| 261 | ! |
---|
[11536] | 262 | ! ---------------------------------------------------- ! |
---|
| 263 | ! 4. Do north and south MPI exchange if needed ! |
---|
| 264 | ! ---------------------------------------------------- ! |
---|
[8586] | 265 | ! |
---|
[11536] | 266 | IF( llsend_so ) ALLOCATE( zsnd_so(jpi,ihl,ipk,ipl,ipf) ) |
---|
| 267 | IF( llsend_no ) ALLOCATE( zsnd_no(jpi,ihl,ipk,ipl,ipf) ) |
---|
| 268 | IF( llrecv_so ) ALLOCATE( zrcv_so(jpi,ihl,ipk,ipl,ipf) ) |
---|
| 269 | IF( llrecv_no ) ALLOCATE( zrcv_no(jpi,ihl,ipk,ipl,ipf) ) |
---|
[10425] | 270 | ! |
---|
[11536] | 271 | isize = jpi * ihl * ipk * ipl * ipf |
---|
| 272 | |
---|
| 273 | ! allocate local temporary arrays to be sent/received. Fill arrays to be sent |
---|
| 274 | IF( llsend_so ) THEN ! copy sourhern side of the inner mpi domain in local temporary array to be sent by MPI |
---|
| 275 | ishift = ihl |
---|
| 276 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 277 | zsnd_so(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf) ! ihl+1 -> 2*ihl |
---|
| 278 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 279 | ENDIF |
---|
[8586] | 280 | ! |
---|
[11536] | 281 | IF( llsend_no ) THEN ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI |
---|
| 282 | ishift = jpj - 2 * ihl |
---|
| 283 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 284 | zsnd_no(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf) ! jpj-2*ihl+1 -> jpj-ihl |
---|
| 285 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 286 | ENDIF |
---|
[8586] | 287 | ! |
---|
[10425] | 288 | IF( ln_timing ) CALL tic_tac(.TRUE.) |
---|
[8586] | 289 | ! |
---|
[11536] | 290 | ! non-blocking send of the southern/northern side |
---|
| 291 | IF( llsend_so ) CALL mppsend( 3, zsnd_so(1,1,1,1,1), isize, noso, ireq_so ) |
---|
| 292 | IF( llsend_no ) CALL mppsend( 4, zsnd_no(1,1,1,1,1), isize, nono, ireq_no ) |
---|
| 293 | ! blocking receive of the southern/northern halo |
---|
| 294 | IF( llrecv_so ) CALL mpprecv( 4, zrcv_so(1,1,1,1,1), isize, noso ) |
---|
| 295 | IF( llrecv_no ) CALL mpprecv( 3, zrcv_no(1,1,1,1,1), isize, nono ) |
---|
| 296 | ! |
---|
[10425] | 297 | IF( ln_timing ) CALL tic_tac(.FALSE.) |
---|
[8586] | 298 | ! |
---|
[11536] | 299 | ! ------------------------------------- ! |
---|
| 300 | ! 5. Fill south and north halos ! |
---|
| 301 | ! ------------------------------------- ! |
---|
| 302 | ! |
---|
| 303 | ! 5.1 fill southern halo |
---|
| 304 | ! ---------------------- |
---|
| 305 | ! ishift = 0 ! fill halo from jj = 1 to ihl |
---|
| 306 | SELECT CASE ( ifill_so ) |
---|
| 307 | CASE ( jpfillnothing ) ! no filling |
---|
| 308 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
| 309 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 310 | ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_so(ji,jj,jk,jl,jf) ! 1 -> ihl |
---|
| 311 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 312 | CASE ( jpfillperio ) ! use north-south periodicity |
---|
| 313 | ishift2 = jpj - 2 * ihl |
---|
| 314 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 315 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf) |
---|
| 316 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 317 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
| 318 | DO jf = 1, ipf ! number of arrays to be treated |
---|
| 319 | IF( .NOT. NAT_IN(jf) == 'F' ) THEN ! do nothing for F point |
---|
| 320 | DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 321 | ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ihl+1,jk,jl,jf) |
---|
| 322 | END DO ; END DO ; END DO ; END DO |
---|
| 323 | ENDIF |
---|
[8586] | 324 | END DO |
---|
[11536] | 325 | CASE ( jpfillcst ) ! filling with constant value |
---|
| 326 | DO jf = 1, ipf ! number of arrays to be treated |
---|
| 327 | IF( .NOT. NAT_IN(jf) == 'F' ) THEN ! do nothing for F point |
---|
| 328 | DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 329 | ARRAY_IN(ji,jj,jk,jl,jf) = zland |
---|
| 330 | END DO; END DO ; END DO ; END DO |
---|
| 331 | ENDIF |
---|
[8586] | 332 | END DO |
---|
| 333 | END SELECT |
---|
[10425] | 334 | ! |
---|
[11536] | 335 | ! 5.2 fill northern halo |
---|
| 336 | ! ---------------------- |
---|
| 337 | ishift = jpj - ihl ! fill halo from jj = jpj-ihl+1 to jpj |
---|
| 338 | SELECT CASE ( ifill_no ) |
---|
| 339 | CASE ( jpfillnothing ) ! no filling |
---|
| 340 | CASE ( jpfillmpi ) ! use data received by MPI |
---|
| 341 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 342 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zrcv_no(ji,jj,jk,jl,jf) ! jpj-ihl+1 -> jpj |
---|
| 343 | END DO ; END DO ; END DO ; END DO ; END DO |
---|
| 344 | CASE ( jpfillperio ) ! use north-south periodicity |
---|
| 345 | ishift2 = ihl |
---|
| 346 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 347 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf) |
---|
| 348 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 349 | CASE ( jpfillcopy ) ! filling with inner domain values |
---|
| 350 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 351 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift,jk,jl,jf) |
---|
| 352 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 353 | CASE ( jpfillcst ) ! filling with constant value |
---|
| 354 | DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1, ihl ; DO ji = 1, jpi |
---|
| 355 | ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zland |
---|
| 356 | END DO; END DO ; END DO ; END DO ; END DO |
---|
| 357 | END SELECT |
---|
[8586] | 358 | ! |
---|
[11536] | 359 | ! -------------------------------------------- ! |
---|
| 360 | ! 6. deallocate local temporary arrays ! |
---|
| 361 | ! -------------------------------------------- ! |
---|
| 362 | ! |
---|
| 363 | IF( llsend_we ) THEN |
---|
| 364 | CALL mpi_wait(ireq_we, istat, ierr ) |
---|
| 365 | DEALLOCATE( zsnd_we ) |
---|
| 366 | ENDIF |
---|
| 367 | IF( llsend_ea ) THEN |
---|
| 368 | CALL mpi_wait(ireq_ea, istat, ierr ) |
---|
| 369 | DEALLOCATE( zsnd_ea ) |
---|
| 370 | ENDIF |
---|
| 371 | IF( llsend_so ) THEN |
---|
| 372 | CALL mpi_wait(ireq_so, istat, ierr ) |
---|
| 373 | DEALLOCATE( zsnd_so ) |
---|
| 374 | ENDIF |
---|
| 375 | IF( llsend_no ) THEN |
---|
| 376 | CALL mpi_wait(ireq_no, istat, ierr ) |
---|
| 377 | DEALLOCATE( zsnd_no ) |
---|
| 378 | ENDIF |
---|
| 379 | ! |
---|
| 380 | IF( llrecv_we ) DEALLOCATE( zrcv_we ) |
---|
| 381 | IF( llrecv_ea ) DEALLOCATE( zrcv_ea ) |
---|
| 382 | IF( llrecv_so ) DEALLOCATE( zrcv_so ) |
---|
| 383 | IF( llrecv_no ) DEALLOCATE( zrcv_no ) |
---|
| 384 | ! |
---|
[8586] | 385 | END SUBROUTINE ROUTINE_LNK |
---|
| 386 | |
---|
| 387 | #undef ARRAY_TYPE |
---|
| 388 | #undef NAT_IN |
---|
| 389 | #undef SGN_IN |
---|
| 390 | #undef ARRAY_IN |
---|
| 391 | #undef K_SIZE |
---|
| 392 | #undef L_SIZE |
---|
| 393 | #undef F_SIZE |
---|
| 394 | #undef OPT_K |
---|