Ignore:
Timestamp:
2018-08-02T17:08:17+02:00 (2 years ago)
Author:
clem
Message:

solve issues with median averages (greatly increase speed and sort out land issues)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • utils/tools/NESTING/src/agrif_modutil.f90

    r2143 r10027  
    4949  END SUBROUTINE ssort 
    5050  ! 
     51  !*********************************************************** 
     52  !                    --- quicksort --- 
     53  ! Author: t-nissie 
     54  ! License: GPLv3 
     55  ! Gist: https://gist.github.com/t-nissie/479f0f16966925fa29ea 
     56  !*********************************************************** 
     57  RECURSIVE SUBROUTINE quicksort(var, first, last) 
     58     IMPLICIT NONE 
     59 
     60     REAL*8, DIMENSION(:), INTENT(inout) :: var 
     61     INTEGER,              INTENT(in)    :: first, last 
     62     REAL*8  :: x, t 
     63     INTEGER :: ji, jj 
     64      
     65     x = var( (first+last) / 2 ) 
     66     ji = first 
     67     jj = last 
     68     DO 
     69        DO WHILE (var(ji) < x) 
     70           ji=ji+1 
     71        END DO 
     72        DO WHILE (x < var(jj)) 
     73           jj=jj-1 
     74        END DO 
     75        IF (ji >= jj) EXIT 
     76        t = var(ji);  var(ji) = var(jj);  var(jj) = t 
     77        ji=ji+1 
     78        jj=jj-1 
     79     END DO 
     80     IF (first < ji-1) CALL quicksort(var, first, ji-1) 
     81     IF (jj+1 < last)  CALL quicksort(var, jj+1, last) 
     82  END SUBROUTINE quicksort 
     83   
    5184!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    5285  !************************************************************************ 
Note: See TracChangeset for help on using the changeset viewer.