c kspectrum (http://www.meso-star.com/en_Products.html) - This file is part of kspectrum c Copyright (C) 2008-2015 - Méso-Star - Vincent Eymet c c This file must be used under the terms of the CeCILL license. c This source file is licensed as described in the file COPYING, which c you should have received as part of this distribution. The terms c are also available at c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt c subroutine ssort(l) implicit none include 'max.inc' include 'arrays3.inc' c c Purpose: to sort input array "a" by increasing values of a(1,*) c c Inputs: c + a: input data array, l lines by nc columns c + l: number of lines c c Outputs: c + a: data array, sorted by increasing values of a(1,*) c c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - c Routine extracted from file "bmatch.f" found on Google Code Search, c from the work of: c Micali, S. and Vazirani, V. V.,"An O(square root of V * E) c Algorithm for Finding Maximum Matching in General Graphs", c Proc. 21st Annual Symposium on Foundation of Computer c Science, IEEE, 1980, pp. 17-27. c c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - integer l,f,n2,s,t,ls,i,is,j,js,jj double precision bh,tmp(1:2) c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - do i=1,l b(i)=i enddo f=1 if (l.le.f) return n2=(l-f+1)/2 s=1023 do 100 t=1,10 if (s.gt.n2) goto 90 ls=l-s do 20 i=f,ls is=i+s do jj=1,2 tmp(jj)=a(is,jj) enddo bh=b(is) j=i js=is 5 if (tmp(1).ge.a(j,1)) goto 10 do jj=1,2 a(js,jj)=a(j,jj) enddo b(js)=b(j) js=j j=j-s if (j.ge.f) goto 5 10 continue do jj=1,2 a(js,jj)=tmp(jj) enddo b(js)=bh 20 continue 90 s=s/2 100 continue return end