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.
Changeset 14363 for NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90 – NEMO

Ignore:
Timestamp:
2021-02-01T08:34:52+01:00 (3 years ago)
Author:
smasson
Message:

dev_r14312_MPI_Interface: suppress communications involving only land points, #2598

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2021/dev_r14312_MPI_Interface/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90

    r14349 r14363  
    11 
    2    SUBROUTINE lbc_lnk_pt2pt_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv ) 
     2   SUBROUTINE lbc_lnk_pt2pt_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, khls, lsend, lrecv ) 
    33      CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine 
    44      TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c. 
     
    88      INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant) 
    99      REAL(PRECISION),      OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries) 
     10      INTEGER ,             OPTIONAL, INTENT(in   ) ::   khls        ! halo size, default = nn_hls 
    1011      LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc 
    1112      ! 
    12       INTEGER  ::   ji, jj, jk, jl, jf, jn      ! dummy loop indices 
    13       INTEGER  ::   ipk, ipl, ipf      ! dimension of the input array 
     13      INTEGER  ::     ji,   jj,  jk,  jl,  jf, jn     ! dummy loop indices 
     14      INTEGER  ::    ipi,  ipj, ipk, ipl, ipf         ! dimension of the input array 
    1415      INTEGER  ::   ip0i, ip1i, im0i, im1i 
    1516      INTEGER  ::   ip0j, ip1j, im0j, im1j 
    1617      INTEGER  ::   ishti, ishtj, ishti2, ishtj2 
    1718      INTEGER  ::   ifill_nfd, icomm, ierr 
    18       INTEGER  ::   idxs, idxr 
    19       INTEGER, DIMENSION(4)  ::   isizei, ishtsi, ishtri, ishtpi 
    20       INTEGER, DIMENSION(4)  ::   isizej, ishtsj, ishtrj, ishtpj 
    21       INTEGER, DIMENSION(4)  ::   ifill, iszall, ishts, ishtr 
     19      INTEGER  ::   ihls, idxs, idxr 
     20      INTEGER, DIMENSION(4)  ::   isizei, ishtSi, ishtRi, ishtPi 
     21      INTEGER, DIMENSION(4)  ::   isizej, ishtSj, ishtRj, ishtPj 
     22      INTEGER, DIMENSION(4)  ::   ifill, iszall, ishtS, ishtR 
    2223      INTEGER, DIMENSION(4)  ::   ireq  ! mpi_request id 
    2324      REAL(PRECISION) ::   zland 
     
    3132      ! ----------------------------------------- ! 
    3233      ! 
     34      ipi = SIZE(ptab(1)%pt4d,1) 
     35      ipj = SIZE(ptab(1)%pt4d,2) 
    3336      ipk = SIZE(ptab(1)%pt4d,3) 
    3437      ipl = SIZE(ptab(1)%pt4d,4) 
     
    3841      ! 
    3942      ! take care of optional parameters 
     43      ! 
     44      ihls = nn_hls   ! default definition 
     45      IF( PRESENT( khls ) )   ihls = khls 
     46      IF( ihls > n_hlsmax ) THEN 
     47         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with khls > n_hlsmax : ', khls, '>', n_hlsmax 
     48         CALL ctl_stop( 'STOP', ctmp1 ) 
     49      ENDIF 
     50      IF( ipi /= Ni_0+2*ihls ) THEN 
     51         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along i: ', ipi, ihls, Ni_0 
     52         CALL ctl_stop( 'STOP', ctmp1 ) 
     53      ENDIF 
     54      IF( ipj /= Nj_0+2*ihls ) THEN 
     55         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along j:', ipj, ihls , Nj_0 
     56         CALL ctl_stop( 'STOP', ctmp1 ) 
     57      ENDIF 
    4058      ! 
    4159      zland = 0._wp                                     ! land filling value: zero by default 
     
    4664         llsend(1:4) = lsend(1:4)   ;   llrecv(1:4) = lrecv(1:4) 
    4765      ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN 
    48          WRITE(ctmp1,*) ' Routine ', cdname, ' is calling lbc_lnk with only one of the two arguments lsend or lrecv' 
     66         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with only one of the two arguments lsend or lrecv' 
    4967         CALL ctl_stop( 'STOP', ctmp1 ) 
    5068      ELSE                                                  ! default neighbours 
    51          llsend(1:4) = mpinei(1:4) >= 0 
    52          llrecv(:) = llsend(:) 
     69         llsend(:) = mpiSnei(ihls,1:4) >= 0 
     70         llrecv(:) = mpiRnei(ihls,1:4) >= 0 
    5371      END IF 
    5472      ! 
     
    7290      ! or used for periodocity (p). The localization is defined as "the bottom left corner - 1" in i and j directions. 
    7391      ! This is a shift that will be applied later in the do loops to pick-up the appropriate part of the array 
    74       !                    !                       ________________________ 
    75       ip0i =          0    !          im0j = inner |__|__|__________|__|__| 
    76       ip1i =      nn_hls   !   im1j = inner - halo |__|__|__________|__|__| 
    77       im1i = Nie0-nn_hls   !                       |  |  |          |  |  | 
    78       im0i = Nie0          !                       |  |  |          |  |  | 
    79       ip0j =          0    !                       |  |  |          |  |  | 
    80       ip1j =      nn_hls   !                       |__|__|__________|__|__| 
    81       im1j = Nje0-nn_hls   !           ip1j = halo |__|__|__________|__|__| 
    82       im0j = Nje0          !              ip0j = 0 |__|__|__________|__|__| 
    83       !                    !                    ip0i ip1i        im1i im0i 
    84       ! 
    85       !     sides:       west    east   south   north 
    86       isizei(1:4) = (/ nn_hls, nn_hls,    jpi,    jpi /)   ! i- count 
    87       isizej(1:4) = (/    jpj,    jpj, nn_hls, nn_hls /)   ! j- count 
    88       ishtsi(1:4) = (/   ip1i,   im1i,   ip0i,   ip0i /)   ! i- shift send data 
    89       ishtsj(1:4) = (/   ip0j,   ip0j,   ip1j,   im1j /)   ! j- shift send data 
    90       ishtri(1:4) = (/   ip0i,   im0i,   ip0i,   ip0i /)   ! i- shift received data location 
    91       ishtrj(1:4) = (/   ip0j,   ip0j,   ip0j,   im0j /)   ! j- shift received data location 
    92       ishtpi(1:4) = (/   im1i,   ip1i,   ip0i,   ip0i /)   ! i- shift data used for periodicity 
    93       ishtpj(1:4) = (/   ip0j,   ip0j,   im1j,   ip1j /)   ! j- shift data used for periodicity 
     92      ! 
     93      ! all definitions bellow do not refer to N[ij][se]0 so we can use it with any local value of ihls 
     94      !                   !                       ________________________ 
     95      ip0i =          0   !          im0j = inner |__|__|__________|__|__| 
     96      ip1i =       ihls   !   im1j = inner - halo |__|__|__________|__|__| 
     97      im1i = ipi-2*ihls   !                       |  |  |          |  |  | 
     98      im0i = ipi - ihls   !                       |  |  |          |  |  | 
     99      ip0j =          0   !                       |  |  |          |  |  | 
     100      ip1j =       ihls   !                       |__|__|__________|__|__| 
     101      im1j = ipj-2*ihls   !           ip1j = halo |__|__|__________|__|__| 
     102      im0j = ipj - ihls   !              ip0j = 0 |__|__|__________|__|__| 
     103      !                   !                    ip0i ip1i        im1i im0i 
     104      ! 
     105      !     sides:     west  east south north 
     106      isizei(1:4) = (/ ihls, ihls,  ipi,  ipi /)   ! i- count 
     107      isizej(1:4) = (/  ipj,  ipj, ihls, ihls /)   ! j- count 
     108      ishtSi(1:4) = (/ ip1i, im1i, ip0i, ip0i /)   ! i- shift send data 
     109      ishtSj(1:4) = (/ ip0j, ip0j, ip1j, im1j /)   ! j- shift send data 
     110      ishtRi(1:4) = (/ ip0i, im0i, ip0i, ip0i /)   ! i- shift received data location 
     111      ishtRj(1:4) = (/ ip0j, ip0j, ip0j, im0j /)   ! j- shift received data location 
     112      ishtPi(1:4) = (/ im1i, ip1i, ip0i, ip0i /)   ! i- shift data used for periodicity 
     113      ishtPj(1:4) = (/ ip0j, ip0j, im1j, ip1j /)   ! j- shift data used for periodicity 
    94114      ! 
    95115      ! -------------------------------- ! 
     
    99119      ireq(:) = MPI_REQUEST_NULL 
    100120      iszall(:) = isizei(:) * isizej(:) * ipk * ipl * ipf 
    101       ishts(1) = 0 
     121      ishtS(1) = 0 
    102122      DO jn = 2,4 
    103          ishts(jn) = ishts(jn-1) + iszall(jn-1) * COUNT( (/llsend(jn-1)/) )   ! with _alltoallv: in units of sendtype 
    104       END DO 
    105       ishtr(1) = 0 
     123         ishtS(jn) = ishtS(jn-1) + iszall(jn-1) * COUNT( (/llsend(jn-1)/) )   ! with _alltoallv: in units of sendtype 
     124      END DO 
     125      ishtR(1) = 0 
    106126      DO jn = 2,4 
    107          ishtr(jn) = ishtr(jn-1) + iszall(jn-1) * COUNT( (/llrecv(jn-1)/) )   ! with _alltoallv: in units of sendtype 
     127         ishtR(jn) = ishtR(jn-1) + iszall(jn-1) * COUNT( (/llrecv(jn-1)/) )   ! with _alltoallv: in units of sendtype 
    108128      END DO 
    109129 
     
    119139      DO jn = 1, 2 
    120140         IF( llsend(jn) ) THEN 
    121             ishti = ishtsi(jn) 
    122             ishtj = ishtsj(jn) 
     141            ishti = ishtSi(jn) 
     142            ishtj = ishtSj(jn) 
    123143            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn) 
    124144               zsnd(idxs) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) 
     
    134154      ! non-blocking send of the western/eastern side using local temporary arrays 
    135155      jn = jpwe 
    136       IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 1, icomm, ireq(jn), ierr ) 
     156      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 1, icomm, ireq(jn), ierr ) 
    137157      jn = jpea 
    138       IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 2, icomm, ireq(jn), ierr ) 
     158      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 2, icomm, ireq(jn), ierr ) 
    139159      ! blocking receive of the western/eastern halo in local temporary arrays 
    140160      jn = jpwe 
    141       IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 2, icomm, MPI_STATUS_IGNORE, ierr ) 
     161      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 2, icomm, MPI_STATUS_IGNORE, ierr ) 
    142162      jn = jpea 
    143       IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 1, icomm, MPI_STATUS_IGNORE, ierr ) 
     163      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 1, icomm, MPI_STATUS_IGNORE, ierr ) 
    144164      ! 
    145165      IF( ln_timing ) CALL tic_tac(.FALSE.) 
     
    152172      idxr = 1 
    153173      DO jn = 1, 2 
    154          ishti = ishtri(jn) 
    155          ishtj = ishtrj(jn) 
     174         ishti = ishtRi(jn) 
     175         ishtj = ishtRj(jn) 
    156176         SELECT CASE ( ifill(jn) ) 
    157177         CASE ( jpfillnothing )               ! no filling  
     
    162182            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO 
    163183         CASE ( jpfillperio )                 ! use periodicity 
    164             ishti2 = ishtpi(jn) 
    165             ishtj2 = ishtpj(jn) 
     184            ishti2 = ishtPi(jn) 
     185            ishtj2 = ishtPj(jn) 
    166186            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn) 
    167187               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl) 
    168188            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO 
    169189         CASE ( jpfillcopy  )                 ! filling with inner domain values 
    170             ishti2 = ishtsi(jn) 
    171             ishtj2 = ishtsj(jn) 
     190            ishti2 = ishtSi(jn) 
     191            ishtj2 = ishtSj(jn) 
    172192            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn) 
    173193               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl) 
     
    187207      ! 
    188208      IF( ll_IdoNFold ) THEN 
    189          IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ipf )   ! self NFold 
    190          ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ipf )   ! mpi  NFold 
     209         IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ihls, ipf )   ! self NFold 
     210         ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ihls, ipf )   ! mpi  NFold 
    191211         ENDIF 
    192212      ENDIF 
     
    198218      DO jn = 3, 4 
    199219         IF( llsend(jn) ) THEN 
    200             ishti = ishtsi(jn) 
    201             ishtj = ishtsj(jn) 
     220            ishti = ishtSi(jn) 
     221            ishtj = ishtSj(jn) 
    202222            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn) 
    203223               zsnd(idxs) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) 
     
    212232      ! non-blocking send of the western/eastern side using local temporary arrays 
    213233      jn = jpso 
    214       IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 3, icomm, ireq(jn), ierr ) 
     234      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 3, icomm, ireq(jn), ierr ) 
    215235      jn = jpno 
    216       IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishts(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 4, icomm, ireq(jn), ierr ) 
     236      IF( llsend(jn) )   CALL MPI_ISEND( zsnd(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), 4, icomm, ireq(jn), ierr ) 
    217237      ! blocking receive of the western/eastern halo in local temporary arrays 
    218238      jn = jpso 
    219       IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 4, icomm, MPI_STATUS_IGNORE, ierr ) 
     239      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 4, icomm, MPI_STATUS_IGNORE, ierr ) 
    220240      jn = jpno 
    221       IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtr(jn)+1), iszall(jn), MPI_TYPE, mpinei(jn), 3, icomm, MPI_STATUS_IGNORE, ierr ) 
     241      IF( llrecv(jn) )   CALL MPI_RECV(  zrcv(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), 3, icomm, MPI_STATUS_IGNORE, ierr ) 
    222242      ! 
    223243      IF( ln_timing ) CALL tic_tac(.FALSE.) 
     
    229249      ! 
    230250      DO jn = 3, 4 
    231          ishti = ishtri(jn) 
    232          ishtj = ishtrj(jn) 
     251         ishti = ishtRi(jn) 
     252         ishtj = ishtRj(jn) 
    233253         SELECT CASE ( ifill(jn) ) 
    234254         CASE ( jpfillnothing )               ! no filling  
     
    239259            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO 
    240260         CASE ( jpfillperio )                 ! use periodicity 
    241             ishti2 = ishtpi(jn) 
    242             ishtj2 = ishtpj(jn) 
     261            ishti2 = ishtPi(jn) 
     262            ishtj2 = ishtPj(jn) 
    243263            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn) 
    244264               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl) 
    245265            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO 
    246266         CASE ( jpfillcopy  )                 ! filling with inner domain values 
    247             ishti2 = ishtsi(jn) 
    248             ishtj2 = ishtsj(jn) 
     267            ishti2 = ishtSi(jn) 
     268            ishtj2 = ishtSj(jn) 
    249269            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn) 
    250270               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl) 
Note: See TracChangeset for help on using the changeset viewer.