LF Fortran 95

LGT Function


The LGT function tests whether a string is lexically greater than another string based on the ordering of the ASCII collating sequence.


LGT (string_a, string_b)


string_a is an INTENT(IN) scalar or array of type CHARACTER.

string_b is an INTENT(IN) scalar or array of type CHARACTER.

If string_a and string_b are both arrays, they must have the same shape.


The result is of type default LOGICAL. Its value is true if string_b precedes string_a in the ASCII collating sequence; otherwise the result is false.

Trailing blanks are ignored.

If both strings are of zero length the result is false.


character(len=3) :: a="abc",b="ABC" character(len=0) :: a1,b1 character(len=5) :: c1(2)=(/"abc ","123 "/) character(len=5) :: c2(2)=(/"CBA "," 123"/) write(*,*) lgt(a,b) ! writes T write(*,*) lgt(a,c1) ! writes F T write(*,*) lgt(c2,a) ! writes F F write(*,*) lgt(c1,c2) ! writes T T


ASCII Character Set