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/SAO_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/SAO_SRC/nemogcm.F90

    r7646 r8528  
    499499      ! 
    500500      ! Find the factors of n. 
    501       IF( kn == 1 )   GOTO 20 
    502  
    503       ! nu holds the unfactorised part of the number. 
    504       ! knfax holds the number of factors found. 
    505       ! l points to the allowed factor list. 
    506       ! ifac holds the current factor. 
    507       ! 
    508       inu   = kn 
    509       knfax = 0 
    510       ! 
    511       DO jl = ntest, 1, -1 
    512          ! 
    513          ifac = ilfax(jl) 
    514          IF( ifac > inu )   CYCLE 
    515  
    516          ! Test whether the factor will divide. 
    517  
    518          IF( MOD(inu,ifac) == 0 ) THEN 
     501      IF( kn .NE. 1 ) THEN 
     502 
     503         ! nu holds the unfactorised part of the number. 
     504         ! knfax holds the number of factors found. 
     505         ! l points to the allowed factor list. 
     506         ! ifac holds the current factor. 
     507         ! 
     508         inu   = kn 
     509         knfax = 0 
     510         ! 
     511         DO jl = ntest, 1, -1 
    519512            ! 
    520             knfax = knfax + 1            ! Add the factor to the list 
    521             IF( knfax > kmaxfax ) THEN 
    522                kerr = 6 
    523                write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
    524                return 
     513            ifac = ilfax(jl) 
     514            IF( ifac > inu )   CYCLE 
     515    
     516            ! Test whether the factor will divide. 
     517    
     518            IF( MOD(inu,ifac) == 0 ) THEN 
     519               ! 
     520               knfax = knfax + 1            ! Add the factor to the list 
     521               IF( knfax > kmaxfax ) THEN 
     522                  kerr = 6 
     523                  write (*,*) 'FACTOR: insufficient space in factor array ', knfax 
     524                  return 
     525               ENDIF 
     526               kfax(knfax) = ifac 
     527               ! Store the other factor that goes with this one 
     528               knfax = knfax + 1 
     529               kfax(knfax) = inu / ifac 
     530               !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    525531            ENDIF 
    526             kfax(knfax) = ifac 
    527             ! Store the other factor that goes with this one 
    528             knfax = knfax + 1 
    529             kfax(knfax) = inu / ifac 
    530             !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) 
    531          ENDIF 
    532          ! 
    533       END DO 
    534       ! 
    535    20 CONTINUE      ! Label 20 is the exit point from the factor search loop. 
     532            ! 
     533         END DO 
     534         ! 
     535      ENDIF 
    536536      ! 
    537537   END SUBROUTINE factorise 
Note: See TracChangeset for help on using the changeset viewer.