Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

QSORT Problem

$
0
0

UBROUTINE call_qsort

I'm having some problems with the QSORT subroutine. I have some code along the lines of the given below. The user-defined ordering function is called "compare".

    SUBROUTINE call_qsort

        USE IFPORT

        IMPLICIT NONE

        INTEGER :: nlett

        CHARACTER (3), ALLOCATABLE :: templett(:)

  INTEGER (kind=2), EXTERNAL :: compare

        ! ..

        ! .. External Functions ..

        nlett = 10

        ALLOCATE(templett(nlett))

        templett = ...

  CALL qsort(templett,nlett,3,compare)

  …

  …

END SUBROUTINE call_qsort 

FUNCTION compare(a,b)

    IMPLICIT NONE

    INTEGER (kind=2) :: compare

    CHARACTER (3) :: a, b

    INTRINSIC LGT

    ! ..

    IF (LGT(a,b)) THEN

        compare = 5

    ELSE IF (LGT(b,a)) THEN

        compare = -5

    ELSE

        compare = 0

    END IF

END FUNCTION compare

When I run the code I get the error 

Fort: (18): Dummy character variable ‘B’ has length 3 which is greater than actual variable length 1

Does anyone have an idea of what is going wrong - have I missed something obvious?!


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>