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/OPA_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/OPA_SRC/nemogcm.F90

    r8524 r8528  
    752752      ! 
    753753      ! Find the factors of n. 
    754       IF( kn == 1 )   GOTO 20 
    755  
    756       ! nu holds the unfactorised part of the number. 
    757       ! knfax holds the number of factors found. 
    758       ! l points to the allowed factor list. 
    759       ! ifac holds the current factor. 
    760       ! 
    761       inu   = kn 
    762       knfax = 0 
    763       ! 
    764       DO jl = ntest, 1, -1 
     754      IF( kn .NE. 1 ) THEN 
     755 
     756         ! nu holds the unfactorised part of the number. 
     757         ! knfax holds the number of factors found. 
     758         ! l points to the allowed factor list. 
     759         ! ifac holds the current factor. 
    765760         ! 
    766          ifac = ilfax(jl) 
    767          IF( ifac > inu )   CYCLE 
    768  
    769          ! Test whether the factor will divide. 
    770  
    771          IF( MOD(inu,ifac) == 0 ) THEN 
     761         inu   = kn 
     762         knfax = 0 
     763         ! 
     764         DO jl = ntest, 1, -1 
    772765            ! 
    773             knfax = knfax + 1            ! Add the factor to the list 
    774             IF( knfax > kmaxfax ) THEN 
    775                kerr = 6 
    776                write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
    777                return 
     766            ifac = ilfax(jl) 
     767            IF( ifac > inu )   CYCLE 
     768    
     769            ! Test whether the factor will divide. 
     770    
     771            IF( MOD(inu,ifac) == 0 ) THEN 
     772               ! 
     773               knfax = knfax + 1            ! Add the factor to the list 
     774               IF( knfax > kmaxfax ) THEN 
     775                  kerr = 6 
     776                  write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
     777                  return 
     778               ENDIF 
     779               kfax(knfax) = ifac 
     780               ! Store the other factor that goes with this one 
     781               knfax = knfax + 1 
     782               kfax(knfax) = inu / ifac 
     783               !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    778784            ENDIF 
    779             kfax(knfax) = ifac 
    780             ! Store the other factor that goes with this one 
    781             knfax = knfax + 1 
    782             kfax(knfax) = inu / ifac 
    783             !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    784          ENDIF 
     785            ! 
     786         END DO 
    785787         ! 
    786       END DO 
    787       ! 
    788    20 CONTINUE      ! Label 20 is the exit point from the factor search loop. 
     788      ENDIF 
    789789      ! 
    790790   END SUBROUTINE factorise 
Note: See TracChangeset for help on using the changeset viewer.