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 2651 for branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90 – NEMO

Ignore:
Timestamp:
2011-03-04T12:04:28+01:00 (13 years ago)
Author:
gm
Message:

dynamic mem: #785 ; minor changes, style mainly

File:
1 edited

Legend:

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

    r2647 r2651  
    502502      !! ** Method  : 
    503503      !!---------------------------------------------------------------------- 
    504       USE par_oce 
    505504      INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have 
    506       ! Local variables 
     505      ! 
    507506      INTEGER, PARAMETER :: nfactmax = 20 
    508507      INTEGER :: nfact ! The no. of factors returned 
    509508      INTEGER :: ierr  ! Error flag 
    510       INTEGER :: i 
     509      INTEGER :: ji 
    511510      INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value 
    512511      INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors 
     
    526525         mindiff = 1000000 
    527526         imin    = 1 
    528          DO i=1,nfact-1,2 
    529             idiff = ABS(ifact(i) - ifact(i+1)) 
    530             IF(idiff < mindiff)THEN 
     527         DO ji = 1, nfact-1, 2 
     528            idiff = ABS( ifact(ji) - ifact(ji+1) ) 
     529            IF( idiff < mindiff ) THEN 
    531530               mindiff = idiff 
    532                imin = i 
    533             END IF 
     531               imin = ji 
     532            ENDIF 
    534533         END DO 
    535534         jpnj = ifact(imin) 
     
    543542 
    544543 
    545    SUBROUTINE factorise( ifax, maxfax, nfax, n, ierr ) 
     544   SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) 
    546545      !!---------------------------------------------------------------------- 
    547546      !!                     ***  ROUTINE factorise  *** 
    548547      !! 
    549548      !! ** Purpose :   return the prime factors of n. 
    550       !!                nfax factors are returned in array ifax which is of  
    551       !!                maximum dimension maxfax. 
     549      !!                knfax factors are returned in array kfax which is of  
     550      !!                maximum dimension kmaxfax. 
    552551      !! ** Method  : 
    553552      !!---------------------------------------------------------------------- 
    554       INTEGER, INTENT(in)  :: n, maxfax 
    555       INTEGER, INTENT(Out) :: ierr, nfax 
    556       INTEGER, INTENT(out) :: ifax(maxfax) 
    557       ! Local variables. 
    558       INTEGER :: i, ifac, l, nu 
     553      INTEGER                    , INTENT(in   ) ::   kn, kmaxfax 
     554      INTEGER                    , INTENT(  out) ::   kerr, knfax 
     555      INTEGER, DIMENSION(kmaxfax), INTENT(  out) ::   kfax 
     556      ! 
     557      INTEGER :: ifac, jl, inu 
    559558      INTEGER, PARAMETER :: ntest = 14 
    560       INTEGER :: lfax(ntest) 
     559      INTEGER :: ilfax(ntest) 
    561560 
    562561      ! lfax contains the set of allowed factors. 
    563       data (lfax(i),i=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  & 
    564          &                         128,   64,   32,   16,    8,   4,   2  / 
     562      data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  & 
     563         &                            128,   64,   32,   16,    8,   4,   2  / 
    565564      !!---------------------------------------------------------------------- 
    566565 
    567566      ! Clear the error flag and initialise output vars 
    568       ierr = 0 
    569       ifax = 1 
    570       nfax = 0 
     567      kerr = 0 
     568      kfax = 1 
     569      knfax = 0 
    571570 
    572571      ! Find the factors of n. 
    573       IF( n == 1 ) GOTO 20 
     572      IF( kn == 1 )  GOTO 20 
    574573 
    575574      ! nu holds the unfactorised part of the number. 
    576       ! nfax holds the number of factors found. 
     575      ! knfax holds the number of factors found. 
    577576      ! l points to the allowed factor list. 
    578577      ! ifac holds the current factor. 
    579578 
    580       nu   = n 
    581       nfax = 0 
    582  
    583       DO l = ntest, 1, -1 
     579      inu   = kn 
     580      knfax = 0 
     581 
     582      DO jl = ntest, 1, -1 
    584583         ! 
    585          ifac = lfax(l) 
    586          IF(ifac > nu)CYCLE 
     584         ifac = ilfax(jl) 
     585         IF( ifac > inu )   CYCLE 
    587586 
    588587         ! Test whether the factor will divide. 
    589588 
    590          IF( MOD(nu,ifac) == 0 ) THEN 
     589         IF( MOD(inu,ifac) == 0 ) THEN 
    591590            ! 
    592             nfax = nfax+1            ! Add the factor to the list 
    593             IF( nfax > maxfax ) THEN 
    594                ierr = 6 
    595                write (*,*) 'FACTOR: insufficient space in factor array ',nfax 
     591            knfax = knfax + 1            ! Add the factor to the list 
     592            IF( knfax > kmaxfax ) THEN 
     593               kerr = 6 
     594               write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
    596595               return 
    597596            ENDIF 
    598             ifax(nfax) = ifac 
     597            kfax(knfax) = ifac 
    599598            ! Store the other factor that goes with this one 
    600             nfax = nfax + 1 
    601             ifax(nfax) = nu / ifac 
    602             !WRITE (*,*) 'ARPDBG, factors ',nfax-1,' & ',nfax,' are ', & 
    603             !            ifax(nfax-1),' and ',ifax(nfax) 
     599            knfax = knfax + 1 
     600            kfax(knfax) = inu / ifac 
     601            !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    604602         ENDIF 
    605603         ! 
     
    608606   20 CONTINUE      ! Label 20 is the exit point from the factor search loop. 
    609607      ! 
    610       RETURN 
    611       ! 
    612608   END SUBROUTINE factorise 
    613609 
Note: See TracChangeset for help on using the changeset viewer.