Skip to content

Conversation

@jeanPerier
Copy link
Contributor

Add support for legacy Fortran intrinsic QSORT from lib3f (used to be described in section 3f of the man pages. The best documentation I could find online is https://docs.oracle.com/cd/E19205-01/820-4180/man3f/index.html).

Since I do not think there is any standard sorting intrinsic in Fortran, this is still a relevant extension.

Example usage:

integer function  icompar(a,b)
 integer :: a, b
 icompar = merge(-1, merge(0, 1, a.eq.b), a.lt.b)
end function

  external :: icompar
  integer :: x(10) = [2,1,10,8,9,5,3,4,6,7]
  call qsort(x, 10,4, icompar)
  print *, x
end

@jeanPerier jeanPerier requested a review from klausler March 19, 2025 14:00
@llvmbot llvmbot added the flang Flang issues not falling into any other category label Mar 19, 2025
@jeanPerier
Copy link
Contributor Author

For the record, here is another link to documentation for the 3F library https://docs.nvidia.com/hpc-sdk/pgi-compilers/20.4/x86/fortran-ref-guide/index.htm#fort-3f-routines

@jeanPerier jeanPerier merged commit cd0a2a3 into llvm:main Mar 19, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants