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 3432 for branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90 – NEMO

Ignore:
Timestamp:
2012-07-11T13:22:58+02:00 (12 years ago)
Author:
trackstand2
Message:

Merge branch 'ksection_partition'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90

    r3211 r3432  
    6565   PUBLIC   mpp_lnk_3d, mpp_lnk_3d_gather, mpp_lnk_2d, mpp_lnk_2d_e 
    6666   PUBLIC   mppobc, mpp_ini_ice, mpp_ini_znl 
    67    PUBLIC   mppsize 
     67   PUBLIC   mppsize, MAX_FACTORS, nxfactors, xfactors, nyfactors, yfactors 
    6868   PUBLIC   lib_mpp_alloc   ! Called in nemogcm.F90 
    6969 
     
    146146   LOGICAL          ::   l_isend = .FALSE.   ! isend use indicator (T if cn_mpi_send='I') 
    147147   INTEGER          ::   nn_buffer = 0       ! size of the buffer in case of mpi_bsend  
    148        
     148   CHARACTER(len=256) :: nn_xfactors = ''    ! String holding factors to use for PE grid in x direction       
     149   CHARACTER(len=256) :: nn_yfactors = ''    ! String holding factors to use for PE grid in y direction       
     150   INTEGER, PARAMETER :: MAX_FACTORS = 20    ! Maximum no. of factors factor() can return 
     151   ! Arrays to hold specific factorisation of the processor grid specified 
     152   ! in the namelist. Set to -1 if no specific factorisation requested. 
     153   INTEGER, SAVE, DIMENSION(MAX_FACTORS) :: xfactors, yfactors 
     154   INTEGER, SAVE                         :: nxfactors, nyfactors 
     155   LOGICAL,       PUBLIC                 :: nn_pttrim = .FALSE. ! Whether to trim dry  
     156                                                                ! land from PE domains 
     157   INTEGER, SAVE, PUBLIC                 :: nn_cpnode = 4 ! Number of cores per  
     158                                                          ! compute node on current computer 
     159  
    149160   REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE :: tampon  ! buffer in case of bsend 
    150161 
     
    203214      !!---------------------------------------------------------------------- 
    204215      ! 
    205       ALLOCATE( t4ns(jpi,jprecj,jpk,2,2) , t4sn(jpi,jprecj,jpk,2,2) ,                                            & 
     216      ALLOCATE( & 
     217#if !defined key_mpp_rkpart 
     218                t4ns(jpi,jprecj,jpk,2,2) , t4sn(jpi,jprecj,jpk,2,2) ,                                            & 
    206219         &      t4ew(jpj,jpreci,jpk,2,2) , t4we(jpj,jpreci,jpk,2,2) ,                                            & 
    207220         &      t4p1(jpi,jprecj,jpk,2,2) , t4p2(jpi,jprecj,jpk,2,2) ,                                            & 
     
    212225         &      t2ew(jpj,jpreci    ,2)   , t2we(jpj,jpreci    ,2)   ,                                            & 
    213226         &      t2p1(jpi,jprecj    ,2)   , t2p2(jpi,jprecj    ,2)   ,                                            & 
     227#endif 
    214228         ! 
    215229         &      tr2ns(1-jpr2di:jpi+jpr2di,jprecj+jpr2dj,2) ,                                                     & 
     
    248262      LOGICAL ::   mpi_was_called 
    249263      ! 
    250       NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, jpnij 
     264      NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, jpnij, & 
     265                       nn_xfactors, nn_yfactors, nn_pttrim, nn_cpnode 
    251266      !!---------------------------------------------------------------------- 
    252267      ! 
     
    263278      WRITE(ldtxt(ii),*) '      mpi send type                      cn_mpi_send = ', cn_mpi_send   ;   ii = ii + 1 
    264279      WRITE(ldtxt(ii),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer     ;   ii = ii + 1 
    265  
     280      WRITE(ldtxt(ii),*) '      whether to trim dry points         nn_pttrim   = ', nn_pttrim     ;   ii = ii + 1 
     281      WRITE(ldtxt(ii),*) '      number of cores per compute node   nn_cpn      = ', nn_cpnode     ;   ii = ii + 1 
    266282#if defined key_agrif 
    267283      IF( .NOT. Agrif_Root() ) THEN 
     
    284300         WRITE(ldtxt(ii),*) '      processor grid extent in j         jpnj = ',jpnj; ii = ii + 1 
    285301         WRITE(ldtxt(ii),*) '      number of local domains           jpnij = ',jpnij; ii = ii +1 
     302      END IF 
     303 
     304      ! Check to see whether a specific factorisation of the number of  
     305      ! processors has been specified in the namelist file 
     306      nxfactors = 0; xfactors(:) = -1 
     307      nyfactors = 0; yfactors(:) = -1 
     308      IF((LEN_TRIM(nn_xfactors) > 0) .OR. (LEN_TRIM(nn_yfactors) > 0))THEN 
     309 
     310         IF( (VERIFY(TRIM(nn_xfactors),'0123456789,') > 0) .OR. & 
     311             (VERIFY(TRIM(nn_yfactors),'0123456789,') > 0) )THEN 
     312            WRITE(ldtxt(ii),*)'Invalid character in nn_xfactors/nn_yfactors namelist string. '; ii = ii + 1 
     313            WRITE(ldtxt(ii),*)'Will ignore requested factorisation.' ; ii = ii + 1 
     314         ELSE 
     315            READ(nn_xfactors, *,end=80,err=100) xfactors 
     316         80 CONTINUE 
     317            READ(nn_yfactors, *,end=90,err=100) yfactors 
     318         90 CONTINUE 
     319 
     320            trim_xarray: DO ji=MAX_FACTORS,1,-1 
     321               IF (xfactors(ji) .GE. 0) THEN 
     322                  nxfactors = ji 
     323                  EXIT trim_xarray 
     324               ENDIF 
     325            ENDDO trim_xarray 
     326            trim_yarray: DO ji=MAX_FACTORS,1,-1 
     327               IF (yfactors(ji) .GE. 0) THEN 
     328                  nyfactors = ji 
     329                  EXIT trim_yarray 
     330               ENDIF 
     331            ENDDO trim_yarray 
     332 
     333        100 CONTINUE 
     334            WRITE (*,*) 'ARPDBG: n{x,y}factors = ',nxfactors,nyfactors 
     335            IF(nxfactors < 1 .AND. nyfactors < 1)THEN 
     336               WRITE(ldtxt(ii),*)'Failed to parse factorisation string'    ; ii = ii + 1 
     337               WRITE(ldtxt(ii),*)' - will ignore requested factorisation.' ; ii = ii + 1 
     338            ELSE 
     339               WRITE(ldtxt(ii),*)'      automatic factorisation overridden'   ; ii = ii + 1 
     340               WRITE(ldtxt(ii),*)'      factors:', xfactors(1:nxfactors), & 
     341                                 '-',yfactors(1:nyfactors) 
     342               ii = ii + 1 
     343            END IF 
     344         ENDIF 
     345 
    286346      END IF 
    287347 
     
    356416      mynode = mpprank 
    357417      !  
     418      IF( (jpni < 1) .OR. (jpnj < 1) )THEN 
     419         IF(mynode == 0)WRITE(ldtxt(ii),*) '      Running on ',mppsize,' MPI processes'; ii = ii + 1 
     420      END IF 
     421 
    358422#if defined key_mpp_rep 
    359423      CALL MPI_OP_CREATE(DDPDD_MPI, .TRUE., MPI_SUMDD, ierr) 
     
    363427 
    364428 
    365    SUBROUTINE mpp_lnk_3d( ptab3d, cd_type, psgn, cd_mpp, pval ) 
     429   SUBROUTINE mpp_lnk_3d( ptab3d, cd_type, psgn, cd_mpp, pval, lzero ) 
    366430      !!---------------------------------------------------------------------- 
    367431      !!                  ***  routine mpp_lnk_3d  *** 
     
    394458      CHARACTER(len=3), OPTIONAL      , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only  
    395459      REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries) 
     460      LOGICAL         , OPTIONAL      , INTENT(in   ) ::   lzero    ! Whether to zero field at closed boundaries 
    396461      !! 
    397462      INTEGER  ::   ji, jj, jk, jl             ! dummy loop indices 
     
    400465      REAL(wp) ::   zland 
    401466      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    402       !!---------------------------------------------------------------------- 
     467      LOGICAL  ::   lzeroarg 
     468      !!---------------------------------------------------------------------- 
     469 
     470#if defined key_mpp_rkpart 
     471      CALL ctl_stop('mpp_lnk_3d: should not have been called when key_mpp_rkpart defined!') 
     472      RETURN 
     473#endif 
     474      ! Deal with optional routine arguments 
     475      lzeroarg = .TRUE. 
     476      IF( PRESENT(lzero) ) lzeroarg = lzero 
    403477 
    404478      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
     
    443517            ptab3d(jpi,:,:) = ptab3d(  2  ,:,:) 
    444518         ELSE                                     !* closed 
    445             IF( .NOT. cd_type == 'F' )   ptab3d(     1       :jpreci,:,:) = zland    ! south except F-point 
    446                                          ptab3d(nlci-jpreci+1:jpi   ,:,:) = zland    ! north 
     519            IF( lzeroarg )THEN 
     520               IF( .NOT. cd_type == 'F' )   ptab3d(     1       :jpreci,:,:) = zland    ! south except F-point 
     521                                            ptab3d(nlci-jpreci+1:jpi   ,:,:) = zland    ! north 
     522            END IF 
    447523         ENDIF 
    448524         !                                   ! North-South boundaries (always closed) 
    449          IF( .NOT. cd_type == 'F' )   ptab3d(:,     1       :jprecj,:) = zland       ! south except F-point 
    450                                       ptab3d(:,nlcj-jprecj+1:jpj   ,:) = zland       ! north 
     525         IF( lzeroarg )THEN 
     526            IF( .NOT. cd_type == 'F' )   ptab3d(:,     1       :jprecj,:) = zland       ! south except F-point 
     527                                         ptab3d(:,nlcj-jprecj+1:jpj   ,:) = zland       ! north 
     528         END IF 
    451529         ! 
    452530      ENDIF 
     
    574652 
    575653 
    576    SUBROUTINE mpp_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval ) 
     654   SUBROUTINE mpp_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval, lzero ) 
    577655      !!---------------------------------------------------------------------- 
    578656      !!                  ***  routine mpp_lnk_2d  *** 
     
    600678      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only  
    601679      REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval     ! background value (used at closed boundaries) 
     680      LOGICAL         , OPTIONAL  , INTENT(in   ) ::   lzero    ! Whether to zero field at closed boundaries 
    602681      !! 
    603682      INTEGER  ::   ji, jj, jl   ! dummy loop indices 
     
    606685      REAL(wp) ::   zland 
    607686      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend 
    608       !!---------------------------------------------------------------------- 
     687      LOGICAL  ::   lzeroarg 
     688      !!---------------------------------------------------------------------- 
     689 
     690#if defined key_mpp_rkpart 
     691      CALL ctl_stop('mpp_lnk_3d: should not have been called when key_mpp_rkpart defined!') 
     692      RETURN 
     693#endif 
     694 
     695      ! Deal with optional routine arguments 
     696      lzeroarg = .TRUE. 
     697      IF( PRESENT(lzero) ) lzeroarg = lzero 
    609698 
    610699      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value 
     
    637726            pt2d(jpi,:) = pt2d(  2  ,:)                                    ! east 
    638727         ELSE                                     ! closed 
    639             IF( .NOT. cd_type == 'F' )   pt2d(     1       :jpreci,:) = zland    ! south except F-point 
    640                                          pt2d(nlci-jpreci+1:jpi   ,:) = zland    ! north 
     728            IF( lzeroarg )THEN 
     729               IF( .NOT. cd_type == 'F' )   pt2d(     1       :jpreci,:) = zland    ! south except F-point 
     730                                            pt2d(nlci-jpreci+1:jpi   ,:) = zland    ! north 
     731            END IF 
    641732         ENDIF 
    642733         !                                   ! North-South boundaries (always closed) 
    643             IF( .NOT. cd_type == 'F' )   pt2d(:,     1       :jprecj) = zland    !south except F-point 
    644                                          pt2d(:,nlcj-jprecj+1:jpj   ) = zland    ! north 
     734            IF( lzeroarg )THEN 
     735               IF( .NOT. cd_type == 'F' )   pt2d(:,     1       :jprecj) = zland    !south except F-point 
     736                                            pt2d(:,nlcj-jprecj+1:jpj   ) = zland    ! north 
     737            END IF 
    645738         ! 
    646739      ENDIF 
     
    17821875      CALL mppsync 
    17831876      CALL mpi_finalize( info ) 
     1877      STOP 
    17841878      ! 
    17851879   END SUBROUTINE mppstop 
Note: See TracChangeset for help on using the changeset viewer.