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 2882 for branches/2011/dev_r2855_NOCS_mppsca/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90 – NEMO

Ignore:
Timestamp:
2011-09-30T17:57:57+02:00 (13 years ago)
Author:
acc
Message:

Branch 2011/dev_r2855_NOCS_mppsca. Code to avoid the use of MPI_ALLGATHER at the north fold. Prace investigations suggest this can improve scalability for large domain decompositions. This is a completion and replacement of work started on branch DEV_1879_mpp_sca. See #679

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2011/dev_r2855_NOCS_mppsca/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90

    r2715 r2882  
    291291                            CALL     dom_cfg    ! Domain configuration 
    292292                            CALL     dom_init   ! Domain 
     293 
     294      IF( ln_nnogather )    CALL nemo_northcomms   ! Initialise the northfold neighbour lists (must be done after the masks are defined) 
    293295 
    294296      IF( ln_ctl        )   CALL prt_ctl_init   ! Print control 
     
    617619   END SUBROUTINE factorise 
    618620 
     621   SUBROUTINE nemo_northcomms 
     622      !!====================================================================== 
     623      !!                     ***  ROUTINE  nemo_northcomms  *** 
     624      !! nemo_northcomms    :  Setup for north fold exchanges with explicit peer to peer messaging 
     625      !!===================================================================== 
     626      !!---------------------------------------------------------------------- 
     627      !!  
     628      !! ** Purpose :   Initialization of the northern neighbours lists. 
     629      !!---------------------------------------------------------------------- 
     630      !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)  
     631      !!---------------------------------------------------------------------- 
     632 
     633      INTEGER ::   ji, jj, jk, ij, jtyp    ! dummy loop indices 
     634      INTEGER ::   ijpj                    ! number of rows involved in north-fold exchange 
     635      INTEGER ::   northcomms_alloc        ! allocate return status 
     636      REAL(wp), ALLOCATABLE, DIMENSION ( :,: ) ::   znnbrs     ! workspace 
     637      LOGICAL,  ALLOCATABLE, DIMENSION ( : )   ::   lrankset   ! workspace 
     638 
     639      IF(lwp) WRITE(numout,*) 
     640      IF(lwp) WRITE(numout,*) 'nemo_northcomms : Initialization of the northern neighbours lists' 
     641      IF(lwp) WRITE(numout,*) '~~~~~~~~~~' 
     642 
     643      !!---------------------------------------------------------------------- 
     644      ALLOCATE( znnbrs(jpi,jpj), stat = northcomms_alloc ) 
     645      ALLOCATE( lrankset(jpnij), stat = northcomms_alloc ) 
     646      IF( northcomms_alloc /= 0 ) THEN 
     647         WRITE(numout,cform_war) 
     648         WRITE(numout,*) 'northcomms_alloc : failed to allocate arrays' 
     649         CALL ctl_stop( 'STOP', 'nemo_northcomms : unable to allocate temporary arrays' ) 
     650      ENDIF 
     651      nsndto = 0 
     652      isendto = -1 
     653      ijpj   = 4 
     654! 
     655! This routine has been called because ln_nnogather has been set true ( nammpp ) 
     656! However, these first few exchanges have to use the mpi_allgather method to 
     657! establish the neighbour lists to use in subsequent peer to peer exchanges. 
     658! Consequently, set l_north_nogather to be false here and set it true only after 
     659! the lists have been established. 
     660! 
     661      l_north_nogather = .FALSE. 
     662      ! 
     663! Exchange and store ranks on northern rows 
     664        WRITE(numout,*) narea, njmppt(narea) , MAXVAL( njmppt ) ; FLUSH(numout) 
     665 
     666     DO jtyp = 1,4 
     667 
     668        lrankset = .FALSE. 
     669        znnbrs = narea 
     670        SELECT CASE (jtyp) 
     671        CASE(1) 
     672           ! 
     673           ! Type 1: T,W-points 
     674           ! 
     675           CALL lbc_lnk( znnbrs, 'T', 1. ) 
     676        CASE(2) 
     677           ! 
     678           ! Type 2: U-point 
     679           ! 
     680           CALL lbc_lnk( znnbrs, 'U', 1. ) 
     681        CASE(3) 
     682           ! 
     683           ! Type 3: V-point 
     684           ! 
     685           CALL lbc_lnk( znnbrs, 'V', 1. ) 
     686        CASE(4) 
     687           ! 
     688           ! Type 5: F-point 
     689           ! 
     690           CALL lbc_lnk( znnbrs, 'F', 1. ) 
     691        END SELECT 
     692 
     693        IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN 
     694          do jj = nlcj-ijpj+1, nlcj 
     695           ij = jj - nlcj + ijpj 
     696           do ji = 1,jpi 
     697            if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) & 
     698         &         lrankset(int(znnbrs(ji,jj))) = .true. 
     699           end do 
     700          end do 
     701 
     702          do jj = 1,jpnij 
     703           IF (lrankset(jj)) THEN 
     704            nsndto(jtyp) = nsndto(jtyp) + 1 
     705            IF(nsndto(jtyp) .gt. jpmaxngh ) THEN 
     706             CALL ctl_stop( ' Too many neighbours in nemo_northcomms ', & 
     707           &                ' jpmaxngh will need to be increased ') 
     708            ENDIF 
     709            isendto(nsndto(jtyp),jtyp) = jj-1   ! narea converted to MPI rank 
     710           ENDIF 
     711          end do 
     712        ENDIF 
     713 
     714     END DO 
     715 
     716! 
     717! Type 5: I-point 
     718! 
     719! ICE point exchanges may involve some averaging. The neighbours list is 
     720! built up using two exchanges to ensure that the whole stencil is covered. 
     721! lrankset should not be reset between these 'J' and 'K' point exchanges 
     722 
     723      jtyp = 5 
     724      lrankset = .FALSE. 
     725      znnbrs = narea  
     726      CALL lbc_lnk( znnbrs, 'J', 1. ) ! first ice U-V point 
     727 
     728      IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN 
     729        do jj = nlcj-ijpj+1, nlcj 
     730         ij = jj - nlcj + ijpj 
     731         do ji = 1,jpi 
     732          if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) & 
     733         &       lrankset(int(znnbrs(ji,jj))) = .true. 
     734         end do 
     735        end do 
     736      ENDIF 
     737 
     738      znnbrs = narea  
     739      CALL lbc_lnk( znnbrs, 'K', 1. ) ! second ice U-V point 
     740 
     741      IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN 
     742        do jj = nlcj-ijpj+1, nlcj 
     743         ij = jj - nlcj + ijpj 
     744         do ji = 1,jpi 
     745          if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) & 
     746         &       lrankset(int(znnbrs(ji,jj))) = .true. 
     747         end do 
     748        end do 
     749 
     750        do jj = 1,jpnij 
     751         IF (lrankset(jj)) THEN 
     752          nsndto(jtyp) = nsndto(jtyp) + 1 
     753          IF(nsndto(jtyp) .gt. jpmaxngh ) THEN 
     754           CALL ctl_stop( ' Too many neighbours in nemo_northcomms ', & 
     755           &              ' jpmaxngh will need to be increased ') 
     756          ENDIF 
     757          isendto(nsndto(jtyp),jtyp) = jj-1   ! narea converted to MPI rank 
     758         ENDIF 
     759        end do 
     760! 
     761! For northern row areas, set l_north_nogather so that all subsequent exchanges can use 
     762! peer to peer communications at the north fold 
     763! 
     764        l_north_nogather = .TRUE. 
     765! 
     766        DO jtyp=1,5 
     767         write(numout,'(i4,a,2i4,a,8i5)') narea-1,' : ',jtyp,nsndto(jtyp),' ids ',(isendto(ij,jtyp),ij=1,nsndto(jtyp)) 
     768        END DO 
     769        CALL FLUSH(numout) 
     770      ENDIF 
     771        WRITE(numout,*) narea, ' l_north_nogather ',l_north_nogather; FLUSH(numout) 
     772      DEALLOCATE( znnbrs ) 
     773      DEALLOCATE( lrankset ) 
     774 
     775   END SUBROUTINE nemo_northcomms 
    619776   !!====================================================================== 
    620777END MODULE nemogcm 
Note: See TracChangeset for help on using the changeset viewer.