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 10132 for NEMO/branches – NEMO

Changeset 10132 for NEMO/branches


Ignore:
Timestamp:
2018-09-17T14:57:19+02:00 (6 years ago)
Author:
dguibert
Message:

introduce BULL_GET_DIVISORS/BULL_MPI_DIMS_CREATE

These two options returns a tuple (jpni,jnpj) based on the full
list of divisors instead of the tuple with one equal to a power of 2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/mppini.F90

    r9926 r10132  
    738738      INTEGER, INTENT(in) ::   num_pes   ! The number of MPI processes we have 
    739739      ! 
    740       INTEGER, PARAMETER :: nfactmax = 20 
     740      INTEGER, PARAMETER :: nfactmax = 40 
    741741      INTEGER :: nfact ! The no. of factors returned 
    742742      INTEGER :: ierr  ! Error flag 
     
    744744      INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value 
    745745      INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors 
     746      integer, dimension(2) :: pdims 
    746747      !!---------------------------------------------------------------------- 
    747748      ! 
    748749      ierr = 0 
    749       ! 
     750#ifdef BULL_MPI_DIMS_CREATE 
     751      ! compute good (rectangular) domain decomposition 
     752      call MPI_Dims_create(num_pes, 2, pdims, ierr) 
     753      if(ierr == 0) then 
     754        write(numout, *) 'MPI_Dims_create: ',pdims 
     755        jpni=pdims(1) 
     756        jpnj=pdims(2) 
     757      else 
     758         WRITE (numout, *) 'WARNING: factorisation of number of PEs failed' 
     759         WRITE (numout, *) '       : using grid of ',num_pes,' x 1' 
     760         jpnj = 1 
     761         jpni = num_pes 
     762      endif 
     763      jpnij = jpni*jpnj 
     764#else 
     765#ifdef BULL_GET_DIVISORS 
     766      CALL get_divisors( ifact, nfactmax, nfact, num_pes, ierr ) 
     767#else 
    750768      CALL factorise( ifact, nfactmax, nfact, num_pes, ierr ) 
     769#endif 
    751770      ! 
    752771      IF( nfact <= 1 ) THEN 
     
    771790      ! 
    772791      jpnij = jpni*jpnj 
     792#endif 
    773793      ! 
    774794   END SUBROUTINE mpp_init_partition 
    775795 
    776  
     796   SUBROUTINE get_divisors( kfax, kmaxfax, knfax, kn, kerr ) 
     797      !!---------------------------------------------------------------------- 
     798      !!                     ***  ROUTINE factorise  *** 
     799      !! 
     800      !! ** Purpose :   A O(sqrt(n)) program that prints all divisors 
     801      !!                in sorted order 
     802      !! ** Method  : 
     803      !!---------------------------------------------------------------------- 
     804      INTEGER                    , INTENT(in   ) ::   kn, kmaxfax 
     805      INTEGER                    , INTENT(  out) ::   kerr, knfax 
     806      INTEGER, DIMENSION(kmaxfax), INTENT(  out) ::   kfax 
     807      ! 
     808      INTEGER :: ifac, jl, inu 
     809      kerr=0 
     810      inu = kn 
     811      knfax = 0 
     812      do ifac=1, sqrt(real(kn)) 
     813          if(mod(kn,ifac) == 0) then 
     814               IF( knfax+2 > kmaxfax ) THEN 
     815                  kerr = 6 
     816                  write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
     817                  return 
     818               ENDIF 
     819               knfax = knfax + 1 ! Add the factor to the list 
     820               kfax(knfax) = ifac 
     821               ! Store the other factor that goes with this one 
     822               knfax = knfax + 1 
     823               kfax(knfax) = kn/ifac 
     824               !WRITE (*,'(4(a,i))') 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
     825          endif 
     826      end do 
     827   END SUBROUTINE get_divisors 
     828  
    777829   SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) 
    778830      !!---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.