The length of a character substring is the result of the evaluation of MAX(int_expr2 - int_expr1 + 1,0).
where length is the length of the parent string. If int_expr1 is omitted, its default value is 1. If int_expr2 is omitted, its default value is length.
FORTRAN 77 does not allow character substrings of length 0. Fortran 90 and up does allow these substrings. To perform compile-time checking on substring bounds in accordance with FORTRAN 77 rules, use the -qnozerosize compiler option. For Fortran 90 compliance, use -qzerosize. To perform run-time checking on substring bounds, use both the -qcheck option and the -qzerosize (or -qnozerosize) option. (See the XL Fortran Compiler Reference for more information.)
A substring of an array section is treated differently. See Substring ranges.
CHARACTER(8) ABC, X, Y, Z
ABC = 'ABCDEFGHIJKL'(1:8) ! Substring of a constant
X = ABC(3:5) ! X = 'CDE'
Y = ABC(-1:6) ! Not allowed in either FORTRAN 77 or Fortran 90
Z = ABC(6:-1) ! Z = '' valid only in Fortran 90