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

Changeset 4185


Ignore:
Timestamp:
2013-11-13T15:14:28+01:00 (10 years ago)
Author:
epico
Message:

northfold update in OFF_SRC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90

    r3827 r4185  
    4646   USE timing          ! Timing 
    4747   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
     48   USE lbcnfd, ONLY: isendto, nsndto 
    4849 
    4950   IMPLICIT NONE 
     
    520521      !!====================================================================== 
    521522      !!                     ***  ROUTINE  nemo_northcomms  *** 
    522       !! nemo_northcomms    :  Setup for north fold exchanges with explicit peer to peer messaging 
     523      !! nemo_northcomms    :  Setup for north fold exchanges with explicit  
     524      !!                       point-to-point messaging 
    523525      !!===================================================================== 
    524526      !!---------------------------------------------------------------------- 
    525       !!  
     527      !! 
    526528      !! ** Purpose :   Initialization of the northern neighbours lists. 
    527529      !!---------------------------------------------------------------------- 
    528       !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)  
    529       !!---------------------------------------------------------------------- 
    530  
    531       INTEGER ::   ji, jj, jk, ij, jtyp    ! dummy loop indices 
    532       INTEGER ::   ijpj                    ! number of rows involved in north-fold exchange 
    533       INTEGER ::   northcomms_alloc        ! allocate return status 
    534       REAL(wp), ALLOCATABLE, DIMENSION ( :,: ) ::   znnbrs     ! workspace 
    535       LOGICAL,  ALLOCATABLE, DIMENSION ( : )   ::   lrankset   ! workspace 
    536  
    537       IF(lwp) WRITE(numout,*) 
    538       IF(lwp) WRITE(numout,*) 'nemo_northcomms : Initialization of the northern neighbours lists' 
    539       IF(lwp) WRITE(numout,*) '~~~~~~~~~~' 
    540  
    541       !!---------------------------------------------------------------------- 
    542       ALLOCATE( znnbrs(jpi,jpj), stat = northcomms_alloc ) 
    543       ALLOCATE( lrankset(jpnij), stat = northcomms_alloc ) 
    544       IF( northcomms_alloc /= 0 ) THEN 
    545          WRITE(numout,cform_war) 
    546          WRITE(numout,*) 'northcomms_alloc : failed to allocate arrays' 
    547          CALL ctl_stop( 'STOP', 'nemo_northcomms : unable to allocate temporary arrays' ) 
    548       ENDIF 
     530      !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE) 
     531      !!    2.0  ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC)  
     532      !!---------------------------------------------------------------------- 
     533 
     534      INTEGER  ::   sxM, dxM, sxT, dxT, jn 
     535      INTEGER  ::   njmppmax 
     536 
     537      njmppmax = MAXVAL( njmppt ) 
     538 
     539      !initializes the north-fold communication variables 
     540      isendto(:) = 0 
    549541      nsndto = 0 
    550       isendto = -1 
    551       ijpj   = 4 
    552       ! 
    553       ! This routine has been called because ln_nnogather has been set true ( nammpp ) 
    554       ! However, these first few exchanges have to use the mpi_allgather method to 
    555       ! establish the neighbour lists to use in subsequent peer to peer exchanges. 
    556       ! Consequently, set l_north_nogather to be false here and set it true only after 
    557       ! the lists have been established. 
    558       ! 
    559       l_north_nogather = .FALSE. 
    560       ! 
    561       ! Exchange and store ranks on northern rows 
    562  
    563       DO jtyp = 1,4 
    564  
    565          lrankset = .FALSE. 
    566          znnbrs = narea 
    567          SELECT CASE (jtyp) 
    568             CASE(1) 
    569                CALL lbc_lnk( znnbrs, 'T', 1. )      ! Type 1: T,W-points 
    570             CASE(2) 
    571                CALL lbc_lnk( znnbrs, 'U', 1. )      ! Type 2: U-point 
    572             CASE(3) 
    573                CALL lbc_lnk( znnbrs, 'V', 1. )      ! Type 3: V-point 
    574             CASE(4) 
    575                CALL lbc_lnk( znnbrs, 'F', 1. )      ! Type 4: F-point 
    576          END SELECT 
    577  
    578          IF ( njmppt(narea) .EQ. MAXVAL( njmppt ) ) THEN 
    579             DO jj = nlcj-ijpj+1, nlcj 
    580                ij = jj - nlcj + ijpj 
    581                DO ji = 1,jpi 
    582                   IF ( INT(znnbrs(ji,jj)) .NE. 0 .AND. INT(znnbrs(ji,jj)) .NE. narea ) & 
    583                &     lrankset(INT(znnbrs(ji,jj))) = .true. 
    584                END DO 
    585             END DO 
    586  
    587             DO jj = 1,jpnij 
    588                IF ( lrankset(jj) ) THEN 
    589                   nsndto(jtyp) = nsndto(jtyp) + 1 
    590                   IF ( nsndto(jtyp) .GT. jpmaxngh ) THEN 
    591                      CALL ctl_stop( ' Too many neighbours in nemo_northcomms ', & 
    592                   &                 ' jpmaxngh will need to be increased ') 
    593                   ENDIF 
    594                   isendto(nsndto(jtyp),jtyp) = jj-1   ! narea converted to MPI rank 
    595                ENDIF 
    596             END DO 
    597          ENDIF 
    598  
    599       END DO 
    600  
    601       ! 
    602       ! Type 5: I-point 
    603       ! 
    604       ! ICE point exchanges may involve some averaging. The neighbours list is 
    605       ! built up using two exchanges to ensure that the whole stencil is covered. 
    606       ! lrankset should not be reset between these 'J' and 'K' point exchanges 
    607  
    608       jtyp = 5 
    609       lrankset = .FALSE. 
    610       znnbrs = narea  
    611       CALL lbc_lnk( znnbrs, 'J', 1. ) ! first ice U-V point 
    612  
    613       IF ( njmppt(narea) .EQ. MAXVAL( njmppt ) ) THEN 
    614          DO jj = nlcj-ijpj+1, nlcj 
    615             ij = jj - nlcj + ijpj 
    616             DO ji = 1,jpi 
    617                IF ( INT(znnbrs(ji,jj)) .NE. 0 .AND. INT(znnbrs(ji,jj)) .NE. narea ) & 
    618             &     lrankset(INT(znnbrs(ji,jj))) = .true. 
    619          END DO 
    620         END DO 
    621       ENDIF 
    622  
    623       znnbrs = narea  
    624       CALL lbc_lnk( znnbrs, 'K', 1. ) ! second ice U-V point 
    625  
    626       IF ( njmppt(narea) .EQ. MAXVAL( njmppt )) THEN 
    627          DO jj = nlcj-ijpj+1, nlcj 
    628             ij = jj - nlcj + ijpj 
    629             DO ji = 1,jpi 
    630                IF ( INT(znnbrs(ji,jj)) .NE. 0 .AND.  INT(znnbrs(ji,jj)) .NE. narea ) & 
    631             &       lrankset( INT(znnbrs(ji,jj))) = .true. 
    632             END DO 
    633          END DO 
    634  
    635          DO jj = 1,jpnij 
    636             IF ( lrankset(jj) ) THEN 
    637                nsndto(jtyp) = nsndto(jtyp) + 1 
    638                IF ( nsndto(jtyp) .GT. jpmaxngh ) THEN 
    639                   CALL ctl_stop( ' Too many neighbours in nemo_northcomms ', & 
    640                &                 ' jpmaxngh will need to be increased ') 
    641                ENDIF 
    642                isendto(nsndto(jtyp),jtyp) = jj-1   ! narea converted to MPI rank 
    643             ENDIF 
    644          END DO 
    645          ! 
    646          ! For northern row areas, set l_north_nogather so that all subsequent exchanges  
    647          ! can use peer to peer communications at the north fold 
    648          ! 
    649          l_north_nogather = .TRUE. 
    650          ! 
    651       ENDIF 
    652       DEALLOCATE( znnbrs ) 
    653       DEALLOCATE( lrankset ) 
     542 
     543      !if I am a process in the north 
     544      IF ( njmpp == njmppmax ) THEN 
     545          !sxM is the first point (in the global domain) needed to compute the 
     546          !north-fold for the current process 
     547          sxM = jpiglo - nimppt(narea) - nlcit(narea) + 1 
     548          !dxM is the last point (in the global domain) needed to compute the 
     549          !north-fold for the current process 
     550          dxM = jpiglo - nimppt(narea) + 2 
     551 
     552          !loop over the other north-fold processes to find the processes 
     553          !managing the points belonging to the sxT-dxT range 
     554          DO jn = jpnij - jpni +1, jpnij 
     555             IF ( njmppt(jn) == njmppmax ) THEN 
     556                !sxT is the first point (in the global domain) of the jn 
     557                !process 
     558                sxT = nimppt(jn) 
     559                !dxT is the last point (in the global domain) of the jn 
     560                !process 
     561                dxT = nimppt(jn) + nlcit(jn) - 1 
     562                IF ((sxM .gt. sxT) .AND. (sxM .lt. dxT)) THEN 
     563                   nsndto = nsndto + 1 
     564                   isendto(nsndto) = jn 
     565                ELSEIF ((sxM .le. sxT) .AND. (dxM .gt. dxT)) THEN 
     566                   nsndto = nsndto + 1 
     567                   isendto(nsndto) = jn 
     568                ELSEIF ((dxM .lt. dxT) .AND. (sxT .lt. dxM)) THEN 
     569                   nsndto = nsndto + 1 
     570                   isendto(nsndto) = jn 
     571                END IF 
     572             END IF 
     573          END DO 
     574      ENDIF 
     575      l_north_nogather = .TRUE. 
    654576 
    655577   END SUBROUTINE nemo_northcomms 
Note: See TracChangeset for help on using the changeset viewer.