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 8528 for trunk/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90 – NEMO

Ignore:
Timestamp:
2017-09-15T16:43:25+02:00 (7 years ago)
Author:
timgraham
Message:

First set of fixes for #1860 (getting rid of GOTO statements)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90

    r7761 r8528  
    596596      ! 
    597597      ! Find the factors of n. 
    598       IF( kn == 1 )   GOTO 20 
    599  
    600       ! nu holds the unfactorised part of the number. 
    601       ! knfax holds the number of factors found. 
    602       ! l points to the allowed factor list. 
    603       ! ifac holds the current factor. 
    604       ! 
    605       inu   = kn 
    606       knfax = 0 
    607       ! 
    608       DO jl = ntest, 1, -1 
    609          ! 
    610          ifac = ilfax(jl) 
    611          IF( ifac > inu )   CYCLE 
    612  
    613          ! Test whether the factor will divide. 
    614  
    615          IF( MOD(inu,ifac) == 0 ) THEN 
     598      IF( kn .NE. 1 ) THEN 
     599 
     600         ! nu holds the unfactorised part of the number. 
     601         ! knfax holds the number of factors found. 
     602         ! l points to the allowed factor list. 
     603         ! ifac holds the current factor. 
     604         ! 
     605         inu   = kn 
     606         knfax = 0 
     607         ! 
     608         DO jl = ntest, 1, -1 
    616609            ! 
    617             knfax = knfax + 1            ! Add the factor to the list 
    618             IF( knfax > kmaxfax ) THEN 
    619                kerr = 6 
    620                write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
    621                return 
     610            ifac = ilfax(jl) 
     611            IF( ifac > inu )   CYCLE 
     612    
     613            ! Test whether the factor will divide. 
     614    
     615            IF( MOD(inu,ifac) == 0 ) THEN 
     616               ! 
     617               knfax = knfax + 1            ! Add the factor to the list 
     618               IF( knfax > kmaxfax ) THEN 
     619                  kerr = 6 
     620                  write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
     621                  return 
     622               ENDIF 
     623               kfax(knfax) = ifac 
     624               ! Store the other factor that goes with this one 
     625               knfax = knfax + 1 
     626               kfax(knfax) = inu / ifac 
     627               !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    622628            ENDIF 
    623             kfax(knfax) = ifac 
    624             ! Store the other factor that goes with this one 
    625             knfax = knfax + 1 
    626             kfax(knfax) = inu / ifac 
    627             !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    628          ENDIF 
    629          ! 
    630       END DO 
    631       ! 
    632    20 CONTINUE      ! Label 20 is the exit point from the factor search loop. 
     629            ! 
     630         END DO 
     631         ! 
     632      ENDIF 
    633633      ! 
    634634   END SUBROUTINE factorise 
Note: See TracChangeset for help on using the changeset viewer.