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

Changeset 2652


Ignore:
Timestamp:
2011-03-04T13:04:09+01:00 (13 years ago)
Author:
cetlod
Message:

OFF_SRC/nemogcm.F90: minor changes on style

File:
1 edited

Legend:

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

    r2648 r2652  
    379379      !! ** Method  : 
    380380      !!---------------------------------------------------------------------- 
    381       USE par_oce 
    382381      INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have 
    383       ! Local variables 
     382      ! 
    384383      INTEGER, PARAMETER :: nfactmax = 20 
    385384      INTEGER :: nfact ! The no. of factors returned 
    386385      INTEGER :: ierr  ! Error flag 
    387       INTEGER :: i 
     386      INTEGER :: ji 
    388387      INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value 
    389388      INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors 
     
    403402         mindiff = 1000000 
    404403         imin    = 1 
    405          DO i=1,nfact-1,2 
    406             idiff = ABS(ifact(i) - ifact(i+1)) 
    407             IF(idiff < mindiff)THEN 
     404         DO ji = 1, nfact-1, 2 
     405            idiff = ABS( ifact(ji) - ifact(ji+1) ) 
     406            IF( idiff < mindiff ) THEN 
    408407               mindiff = idiff 
    409                imin = i 
    410             END IF 
     408               imin = ji 
     409            ENDIF 
    411410         END DO 
    412411         jpnj = ifact(imin) 
     
    419418   END SUBROUTINE nemo_partition 
    420419 
    421  
    422    SUBROUTINE factorise( ifax, maxfax, nfax, n, ierr ) 
     420   SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) 
    423421      !!---------------------------------------------------------------------- 
    424422      !!                     ***  ROUTINE factorise  *** 
    425423      !! 
    426424      !! ** Purpose :   return the prime factors of n. 
    427       !!                nfax factors are returned in array ifax which is of  
    428       !!                maximum dimension maxfax. 
     425      !!                knfax factors are returned in array kfax which is of  
     426      !!                maximum dimension kmaxfax. 
    429427      !! ** Method  : 
    430428      !!---------------------------------------------------------------------- 
    431       INTEGER, INTENT(in)  :: n, maxfax 
    432       INTEGER, INTENT(Out) :: ierr, nfax 
    433       INTEGER, INTENT(out) :: ifax(maxfax) 
    434       ! Local variables. 
    435       INTEGER :: i, ifac, l, nu 
     429      INTEGER                    , INTENT(in   ) ::   kn, kmaxfax 
     430      INTEGER                    , INTENT(  out) ::   kerr, knfax 
     431      INTEGER, DIMENSION(kmaxfax), INTENT(  out) ::   kfax 
     432      ! 
     433      INTEGER :: ifac, jl, inu 
    436434      INTEGER, PARAMETER :: ntest = 14 
    437       INTEGER :: lfax(ntest) 
     435      INTEGER :: ilfax(ntest) 
    438436 
    439437      ! lfax contains the set of allowed factors. 
    440       data (lfax(i),i=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  & 
    441          &                         128,   64,   32,   16,    8,   4,   2  / 
     438      data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  & 
     439         &                            128,   64,   32,   16,    8,   4,   2  / 
    442440      !!---------------------------------------------------------------------- 
    443441 
    444442      ! Clear the error flag and initialise output vars 
    445       ierr = 0 
    446       ifax = 1 
    447       nfax = 0 
     443      kerr = 0 
     444      kfax = 1 
     445      knfax = 0 
    448446 
    449447      ! Find the factors of n. 
    450       IF( n == 1 ) GOTO 20 
     448      IF( kn == 1 )  GOTO 20 
    451449 
    452450      ! nu holds the unfactorised part of the number. 
    453       ! nfax holds the number of factors found. 
     451      ! knfax holds the number of factors found. 
    454452      ! l points to the allowed factor list. 
    455453      ! ifac holds the current factor. 
    456454 
    457       nu   = n 
    458       nfax = 0 
    459  
    460       DO l = ntest, 1, -1 
    461          ! 
    462          ifac = lfax(l) 
    463          IF(ifac > nu)CYCLE 
     455      inu   = kn 
     456      knfax = 0 
     457 
     458      DO jl = ntest, 1, -1 
     459         ! 
     460         ifac = ilfax(jl) 
     461         IF( ifac > inu )   CYCLE 
    464462 
    465463         ! Test whether the factor will divide. 
    466464 
    467          IF( MOD(nu,ifac) == 0 ) THEN 
     465         IF( MOD(inu,ifac) == 0 ) THEN 
    468466            ! 
    469             nfax = nfax+1            ! Add the factor to the list 
    470             IF( nfax > maxfax ) THEN 
    471                ierr = 6 
    472                write (*,*) 'FACTOR: insufficient space in factor array ',nfax 
     467            knfax = knfax + 1            ! Add the factor to the list 
     468            IF( knfax > kmaxfax ) THEN 
     469               kerr = 6 
     470               write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
    473471               return 
    474472            ENDIF 
    475             ifax(nfax) = ifac 
     473            kfax(knfax) = ifac 
    476474            ! Store the other factor that goes with this one 
    477             nfax = nfax + 1 
    478             ifax(nfax) = nu / ifac 
    479             !WRITE (*,*) 'ARPDBG, factors ',nfax-1,' & ',nfax,' are ', & 
    480             !            ifax(nfax-1),' and ',ifax(nfax) 
     475            knfax = knfax + 1 
     476            kfax(knfax) = inu / ifac 
     477            !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    481478         ENDIF 
    482479         ! 
     
    485482   20 CONTINUE      ! Label 20 is the exit point from the factor search loop. 
    486483      ! 
    487       RETURN 
    488       ! 
    489484   END SUBROUTINE factorise 
     485 
    490486   !!====================================================================== 
    491487END MODULE nemogcm 
Note: See TracChangeset for help on using the changeset viewer.