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 13490 – NEMO

Changeset 13490


Ignore:
Timestamp:
2020-09-18T08:48:31+02:00 (4 years ago)
Author:
smasson
Message:

trunk: fix bestpartition in mppini, see #2526

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/src/OCE/LBC/mppini.F90

    r13438 r13490  
    786786      !! ** Method  : 
    787787      !!---------------------------------------------------------------------- 
    788       INTEGER,           INTENT(in   ) ::   knbij         ! total number if subdomains              (knbi*knbj) 
     788      INTEGER,           INTENT(in   ) ::   knbij         ! total number of subdomains (knbi*knbj) 
    789789      INTEGER, OPTIONAL, INTENT(  out) ::   knbi, knbj    ! number if subdomains along i and j (knbi and knbj) 
    790790      INTEGER, OPTIONAL, INTENT(  out) ::   knbcnt        ! number of land subdomains 
     
    794794      INTEGER :: iszitst, iszjtst 
    795795      INTEGER :: isziref, iszjref 
     796      INTEGER :: iszimin, iszjmin 
    796797      INTEGER :: inbij, iszij 
    797798      INTEGER :: inbimax, inbjmax, inbijmax, inbijold 
     
    822823      inbimax = 0 
    823824      inbjmax = 0 
    824       isziref = Ni0glo*Nj0glo+1 
    825       iszjref = Ni0glo*Nj0glo+1 
     825      isziref = jpiglo*jpjglo+1   ! define a value that is larger than the largest possible 
     826      iszjref = jpiglo*jpjglo+1 
     827      ! 
     828      iszimin = 4*nn_hls          ! minimum size of the MPI subdomain so halos are always adressing neighbor inner domain 
     829      iszjmin = 4*nn_hls 
     830      IF( jperio == 3 .OR. jperio == 4 )   iszjmin = MAX(iszjmin, 2+3*nn_hls)   ! V and F folding must be outside of southern halos 
     831      IF( jperio == 5 .OR. jperio == 6 )   iszjmin = MAX(iszjmin, 1+3*nn_hls)   ! V and F folding must be outside of southern halos 
    826832      ! 
    827833      ! get the list of knbi that gives a smaller jpimax than knbi-1 
     
    831837         iszitst = ( nx_global+2-2*nn_hls + (ji-1) ) / ji + 2*nn_hls    ! first  dim. 
    832838#else 
    833          iszitst = ( Ni0glo + (ji-1) ) / ji 
     839         iszitst = ( Ni0glo + (ji-1) ) / ji + 2*nn_hls   ! max subdomain i-size 
    834840#endif 
    835          IF( iszitst < isziref ) THEN 
     841         IF( iszitst < isziref .AND. iszitst >= iszimin ) THEN 
    836842            isziref = iszitst 
    837843            inbimax = inbimax + 1 
     
    842848         iszjtst = ( ny_global+2-2*nn_hls + (ji-1) ) / ji + 2*nn_hls    ! first  dim. 
    843849#else 
    844          iszjtst = ( Nj0glo + (ji-1) ) / ji 
     850         iszjtst = ( Nj0glo + (ji-1) ) / ji + 2*nn_hls   ! max subdomain j-size 
    845851#endif 
    846          IF( iszjtst < iszjref ) THEN 
     852         IF( iszjtst < iszjref .AND. iszjtst >= iszjmin ) THEN 
    847853            iszjref = iszjtst 
    848854            inbjmax = inbjmax + 1 
     
    897903      isz0 = 0                                                  ! number of best partitions      
    898904      inbij = 1                                                 ! start with the min value of inbij1 => 1 
    899       iszij = Ni0glo*Nj0glo+1                                   ! default: larger than global domain 
     905      iszij = jpiglo*jpjglo+1                                   ! default: larger than global domain 
    900906      DO WHILE( inbij <= inbijmax )                             ! if we did not reach the max of inbij1 
    901907         ii = MINLOC(iszij1, mask = inbij1 == inbij, dim = 1)   ! warning: send back the first occurence if multiple results 
    902908         IF ( iszij1(ii) < iszij ) THEN 
     909            ii = MINLOC( iszi1+iszj1, mask = iszij1 == iszij1(ii) .AND. inbij1 == inbij, dim = 1)  ! select the smaller perimeter if multiple min 
    903910            isz0 = isz0 + 1 
    904911            indexok(isz0) = ii 
Note: See TracChangeset for help on using the changeset viewer.