https://github.com/sag2021/heapsort
Heapsort for Fortran
https://github.com/sag2021/heapsort
heapsort modernfortran sort sorting
Last synced: about 2 months ago
JSON representation
Heapsort for Fortran
- Host: GitHub
- URL: https://github.com/sag2021/heapsort
- Owner: sag2021
- License: bsd-3-clause
- Created: 2024-10-18T07:45:34.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-10-21T15:15:57.000Z (7 months ago)
- Last Synced: 2025-01-22T12:11:39.339Z (3 months ago)
- Topics: heapsort, modernfortran, sort, sorting
- Language: Fortran
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Heapsort
Heapsort subroutine for Fortran. Developed for a long-forgotten project. Code is Fortran 2003,
because it makes selecting INTEGER easier.Main subroutine: heap_sort(data_in,nsize,perm)
- data_in(nsize): A vector of reals to be sorted. The sorting is performed in place.
- nsize: The number of points in data_in
- perm(nsize): A vector that maps positions in the sorted vector back to the original, i.e. unsorted(perm(i)) = sorted(i)# Test
The test program sorts a random vector of reals and computes the permutation vector too.
It then checks that the sorted vector is actually sorted (in ascending order). It also
checks that the permutation vector performs the correct mapping of indices.Compiled and tested using gfortran 8.3:
- gfortran -O3 heapsort.f90 test.f90 -o test -std=f2003